LoRa control Relay circuit:
Here Reyax RYLR890 Lora module to design a Lora Arduino circuit that can control a relay module from 10 KM distance.

Components:
1. Reyax RYLR896 LoRA module: 2no
2. Arduino Nano: 2no
3. 10k resistor: 1no
4. 4.7k resistor: 1no
5. LED 5mm: 2no
6. Push Switch: 1no
7. 9volt Battery: 2no
8. Relay Module: Single Channel Relay.

LoRA Transmitter circuit:
The LORA transmitter circuit will send to signal to LORA receiving circuit.

Transmitter circuit:
In the transmitter circuit, the RX pin of the Arduino is connected with the TX pin of the LORA module through a voltage divider.
As the Arduino sends the signal at 5V logic level but the RYLR896 Lora module can receive the signal at 3.3V logic level.
So the voltage divider is required to drop down 5v to 3.3V.
Transmitter Code:

#define ledPin 2
#define pSwitch 13
int toggleState_1 = 0; 

void setup() 
{
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  pinMode(pSwitch, INPUT);  
}

void loop() 
{

  if (digitalRead(pSwitch) == HIGH)
{
    if (toggleState_1 == 0)
 {
      Serial.println("AT+SEND=1,6,LEDON");
      digitalWrite(ledPin, HIGH);
      toggleState_1 = 1;
      delay(500);
 }
    else
{
      Serial.println("AT+SEND=1,6,LEDOFF");
      digitalWrite(ledPin, LOW);
      toggleState_1 = 0;
      delay(500);
    }
  }  
}

Receiver circuit:
The LORA receiver circuit will receive the signal from the LORA transmitter circuit and accordingly control the Relay module.

Receiver circuit:
In the receiver Lora circuit, the Arduino RX pin is connected with the TX pin of the LOAR module.
As Arduino can receive the signal at 3.3v logic level from the LORA RYLR896 Module, so no voltage divider is required for the Receiving LoRA circuit.

Receiver Code:

#define ledPin 2
String incomingString;
void setup() 
{
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT); 
}

void loop() 
{
  if(Serial.available())
 {
    incomingString = Serial.readString();
    if(incomingString.indexOf("LEDON") >0) 
{
      digitalWrite(ledPin, HIGH);
    }
    else if(incomingString.indexOf("LEDOFF") >0) 
{
      digitalWrite(ledPin, LOW);
    }
  }
}

AT COMMAND FUNCTION:
1. Use “AT+ADDRESS” to set the ADDRESS. The ADDRESS is used for the identification of the transmitter or specified receiver.

2. Use “AT+NETWORKID” to set the ID of the Lora network. As this is a group function so the modules can communicate with each other only by setting the same NETWORK ID. If the ADDRESS of the specified receiver belongs to a different group, it can not communicate with each other. The recommended value is 1~15

3. Use ”AT+BAND” to set the frequency of the wireless band. The transmitter and the receiver should use the same frequency to communicate with each other.

4. Use ”AT+PARAMETER” for setting the RF wireless parameters. To communicate with each other, the transmitter and the receiver should set the same parameters.

Working details:
In this project whenever we press the push button on the transmitter circuit, it will send the signal to the Receiving circuit by using AT command.
At the receiving end, it will read the AT command from the signal and accordingly turn on and off the LED connected with the Receiving circuit, Arduino.

About the Author

Subramanian

Hello! My Dear Friends. I am Subramanian. I am writing posts on androiderode about Electronics testing and equipments.

View All Articles