Remote Control Relay Project: Mastering LoRa Technology

To avoid missing my updates, remember to check the public account in the upper right corner and set it as a star, take down the stars and give them to me.

Remote Control Relay Project: Mastering LoRa Technology
Remote Control Relay Project: Mastering LoRa Technology

Today, I will share a LoRa project demonstrating how to use the RYLR896 LoRa module with real-time feedback to create a LoRa Arduino ESP8266 setup for remote control of a relay. Below is the tutorial and demonstration for the project —

(Original English audio, can be combined with the text version below)

The video above mainly covers the following content:

  • ESP8266 Arduino LoRa home automation project;

  • Composition of transmitter and receiver LoRa circuits;

  • How to configure LoRa using AT commands;

  • Introduction to the project’s source code;

  • How to connect the LoRa module with Arduino and ESP8266;

  • How to control high-voltage appliances using LoRa.

Follow all the steps below, and you can easily create this LoRa Arduino project to control any device. Especially useful in remote areas without Wifi and Bluetooth, this can achieve control from up to 10 kilometers away. Of course, LoRa, as a low-power wireless standard, can transmit further than other wireless methods under the same power conditions, achieving a balance between low power consumption and long range, giving it a place in the Internet of Things. If you are interested in LoRa, this project can help you practice.

Components required for the transmitter circuit:

  • RYLR896 LoRa module

  • Arduino Nano

  • 220Ω, 4.7K, 10K resistors

  • LED

Remote Control Relay Project: Mastering LoRa Technology

Components required for the receiver circuit:

  • RYLR896 LoRa module
  • ESP8266 Node processor
  • 5V 4-channel relay module
  • 4.7k, 10k resistors
Remote Control Relay Project: Mastering LoRa Technology

Components required on the receiver circuit PCB:

1. 5V relay (single pole double throw)

2. BC547 transistor

3. PC817 optocouplers

4. 510Ω 0.25w resistors (R1 – R4)

5. 1k 0.25w resistors (R5 – R9)

6. 5mm LED

7. 1N4007 diodes (D1 – D5)

8. Switch button

9. Terminal connectors

10. 5V DC power supply
Transmitter LoRa circuit using Arduino
Remote Control Relay Project: Mastering LoRa Technology
In the transmitter LoRa circuit, an Arduino Nano is used, and a voltage divider with 4.7k and 10k resistors reduces the 5V logic level to a 3.3V logic level. The buttons are connected to digital pins D2, D3, D4, and D5 of the Arduino. The INPUT_PULLUP function is used in the Arduino IDE instead of using pull-up resistors. The LEDs are connected to digital pins D7, D8, and D13 of the Arduino. Any 5V DC power supply or 9V battery can power the circuit.

Receiver LoRa circuit using NodeMCU

Remote Control Relay Project: Mastering LoRa Technology
In the receiver LoRa circuit, NodeMCU is used as the microcontroller, and similarly, the 5V logic level is reduced to 3.3V logic level through a resistor divider. GPIO pins D1, D2, D5, and D6 are used to control four relays.
If RX is grounded during the boot process of NodeMCU, the boot will fail. Connect the LoRa module after powering the NodeMCU.
A 5V power supply is used to power both NodeMCU and the relay module. Proper safety precautions must be taken when working with high voltage.

Using AT commands to configure parameters

First, connect the LoRa module to a serial interface board with FTDI232, and use AT commands to configure some parameters.
Remote Control Relay Project: Mastering LoRa Technology
In the serial tool, select baud rate = 115200 and “NL and CR”.
AT commands for the transmitter LoRa module:
AT+ADDRESS=1AT+NETWORKID=5AT+BAND=865000000
AT commands for the receiver LoRa module:
AT+ADDRESS=1AT+NETWORKID=5AT+BAND=865000000
It is necessary to select the eligible LoRa frequency band available in your country/region.

Code for the LoRa project using Arduino and ESP8266

In this LoRa project, Arduino Nano is used for the transmitter circuit, and NodeMCU is used for the receiver circuit.
First, download the source code. Upload the transmitter circuit code to Arduino and upload the receiver circuit code to NodeMCU.
Remote Control Relay Project: Mastering LoRa Technology

Transmitter code:

/************************************************************************************************************************************************* *  TITLE: This is transmitter LoRa Arduino sketch to send and receive signal *  Click on the following links to learn more.  *  YouTube Video: https://youtu.be/uWCY1CkvhR8 *  Related Blog : https://iotcircuithub.com/esp8266-projects/ *  by Tech StudyCell *************************************************************************************************************************************************/const int pLED = 13;const int rLED = 7;const int gLED = 8;const int pSwitch_1 = 2;const int pSwitch_2 = 3;const int pSwitch_3 = 4;const int pSwitch_4 = 5;int i;String incomingString;boolean state;void setup() {  // put your setup code here, to run once:  Serial.begin(115200);  pinMode(pLED, OUTPUT);  pinMode(rLED, OUTPUT);  pinMode(gLED, OUTPUT);    pinMode(pSwitch_1, INPUT_PULLUP);  pinMode(pSwitch_2, INPUT_PULLUP);  pinMode(pSwitch_3, INPUT_PULLUP);  pinMode(pSwitch_4, INPUT_PULLUP);}void getFeedback(String excpt_str){  i = 0;  incomingString = "";  state = true;  digitalWrite(gLED, LOW);  digitalWrite(rLED, LOW);  //Serial.print("Waiting for feedback");  while(1){    if(Serial.available()>0){      incomingString = Serial.readString();      if(incomingString.indexOf(excpt_str) > 0) {        state = true; break;      }    }          if (i > 60) {      state = false; break;    }    delay(100);    digitalWrite(pLED, !digitalRead(pLED));    i++;    }    if(state){      digitalWrite(gLED, HIGH);      digitalWrite(rLED, LOW);      digitalWrite(pLED, LOW);      //Serial.println("Received");    }    else{      digitalWrite(gLED, LOW);      digitalWrite(rLED, HIGH);      digitalWrite(pLED, LOW);      //Serial.println("Not Received");    }}void loop() {  // put your main code here, to run repeatedly:  if (digitalRead(pSwitch_1) == LOW){      Serial.println("AT+SEND=2,6,R1");      getFeedback("FR1");    }  else if (digitalRead(pSwitch_2) == LOW){      Serial.println("AT+SEND=2,6,R2");      getFeedback("FR2");    }  else if (digitalRead(pSwitch_3) == LOW){      Serial.println("AT+SEND=2,6,R3");      getFeedback("FR3");    }  else if (digitalRead(pSwitch_4) == LOW){      Serial.println("AT+SEND=2,6,R4");      getFeedback("FR4");    }} 

Receiver code:

/********************************************************************************** *  TITLE: LoRa control 4 Relays using NodeMCU ESP8266 with real-time feedback (Receiving end) *  Click on the following links to learn more.  *  YouTube Video: https://youtu.be/uWCY1CkvhR8 *  Related Blog : https://iotcircuithub.com/esp8266-projects/ *  by Tech StudyCell *  Preferences--> Aditional boards Manager URLs :  *  https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json *  Download Board ESP8266 NodeMCU : https://github.com/esp8266/Arduino *   **********************************************************************************/ // define the GPIO connected with Relays and switches#define RelayPin1 5  //D1#define RelayPin2 4  //D2#define RelayPin3 14 //D5#define RelayPin4 12 //D6#define sLed   16   //D0String incomingString;void setup(){  Serial.begin(115200);  pinMode(RelayPin1, OUTPUT);  pinMode(RelayPin2, OUTPUT);  pinMode(RelayPin3, OUTPUT);  pinMode(RelayPin4, OUTPUT);  pinMode(sLed, OUTPUT);  //During Starting all Relays should TURN OFF  digitalWrite(RelayPin1, HIGH);  digitalWrite(RelayPin2, HIGH);  digitalWrite(RelayPin3, HIGH);  digitalWrite(RelayPin4, HIGH);  digitalWrite(sLed, HIGH);}void loop(){   lora_control();}void lora_control(){    if(Serial.available()) {    incomingString = Serial.readString();    digitalWrite(sLed, LOW);    if(incomingString.indexOf("R1") >0) {      digitalWrite(RelayPin1, !digitalRead(RelayPin1));      Serial.println("AT+SEND=1,6,FR1");    }    else if(incomingString.indexOf("R2") >0) {      digitalWrite(RelayPin2, !digitalRead(RelayPin2));      Serial.println("AT+SEND=1,6,FR2");    }    else if(incomingString.indexOf("R3") >0) {      digitalWrite(RelayPin3, !digitalRead(RelayPin3));      Serial.println("AT+SEND=1,6,FR3");    }    else if(incomingString.indexOf("R4") >0) {      digitalWrite(RelayPin4, !digitalRead(RelayPin4));      Serial.println("AT+SEND=1,6,FR4");    }   delay(100);   digitalWrite(sLed, HIGH); }}

PCB designed for receiving LoRa circuit

To make the circuit compact and professional-looking, a PCB was designed after testing all functions of the smart relay module. You can download the Gerber files for this home automation project PCB from the following link:

https://drive.google.com/uc?export=download&id=1Jx4D_DSV_ei1y0a82AbtxbsNhy8sjCmY

Afterward, I soldered all components according to the circuit diagram.

Remote Control Relay Project: Mastering LoRa Technology
Then I connected the NodeMCU board to the PCB.
Remote Control Relay Project: Mastering LoRa Technology
Connect the 4 lights to the relay module according to the circuit diagram.

Connecting the LoRa module with Arduino and ESP8266

After uploading the code, connect the LoRa module with Arduino and NodeMCU. For the receiver circuit, turn on the 5V power supply before connecting the LoRa module.
Now, use the transmitter LoRa circuit to control the devices and monitor real-time feedback from the receiver LoRa circuit.

Original link:

https://www.hackster.io/techstudycell/lora-project-with-esp8266-arduino-control-relay-70c56b

Author:Subhajit
Project material download: Reply “Darwin said” on WeChat: Imitate the fluorescent tube clock
Project Share | Electric Competition Series | Artificial Intelligence | Postgraduate Entrance Examination
Must-know points | Graduation Design | Switch Power Supply | Job Search
We are Nimo, the founder of Darwin, and we only talk about technology without flirting. The Darwin online education platform aims to serve professionals in the electronics industry, providing skill training videos covering popular topics in various subfields, such as embedded systems, FPGA, artificial intelligence, etc. We tailor layered learning content for different groups, such as commonly used knowledge points, breakdown assessments, electric competitions/intelligent cars/postgraduate entrance examinations, etc. Welcome to follow.
Official website: www.darwinlearns.com
Bilibili: Darwin
QQ group: Group 1: 786258064 (full)
Group 2: 1057755357 (full)
Group 3: 871373286Remote Control Relay Project: Mastering LoRa Technology

Leave a Comment

×