Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » LoRa Relay Switch – Control Home Appliances using LoRa
IoT Projects LoRa/LoRaWAN Projects

LoRa Relay Switch – Control Home Appliances using LoRa

Mamtaz AlamBy Mamtaz AlamUpdated:August 21, 20223 Comments5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
LoRa Relay Switch
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: Control Home Appliances using LoRa Relay Switch

In this project, we will make a LoRa Relay Switch or LoRa Based Power Relay Control System using Arduino & RFM98 LoRa Module. The LoRa Relay Node will able able to transmit the data to Gateway. We can press the switch button on Sender or LoRa Node side which can turn OFF/ON the relay remotely.

The LoRa Relay Power Switch is a smart LoRa device for remotely controlling industrial and home appliances remotely. The Remote Power Switch can be used to remotely control the power of external devices or appliances. Appliances include the control of general devices, lighting, irrigation systems, pumps, remote servers, towers, enabling and disabling security systems, access control of gates and doors.

Communication with the Remote Power Switch is done using the integrated loRaWAN module. All you need to do is upload the code using Micro-USB port, connect to your LoRaWAN network, connect the Remote Power Switch to your power outlet, and connect your appliances to the Remote Power Switch.

LoRa Relay Control Switch

Before getting started with this project, you can check our previous LoRa Based Projects, which will clear your all concepts of LoRaWAN Technology.



Bill of Materials

Following are the components required for making this project. All the components can be easily purchased from Amazon. The component purchase link is given below.

S.N.Components NameQuantityPurchase Link
1LoRa Relay Switch1Makerfabs
2LoRa Receiver1Makerfabs
3USB-to-UART Converter1Makerfabs
40.96" I2C OLED Display1Amazon | AliExpress
5Push Button Switch1Amazon | AliExpress
6AC Bulb1-
7Electric Wires1-2 meter-
8Jumper Wires10Amazon | AliExpress
9Micro-USB Cable1Amazon | AliExpress

LoRa Relay Module 30A

This 30A Lora Relay Node or Switch is a relay module that could be controlled by Lora, with max current 30A/240V. Based on LoRa Module RFM98W, it supports max 4~5 km Lora communication.

Lora Relay Module 30A

This Lora relay module is preloaded Arduino Pro Mini(3.3v 8M) bootloader and simple demo firmware Lora Relay V1.1, the users could freely change/update the firmware with Arduino IDE, with a common UART tool.

Features

  • Controller: Atmega328P
  • Arduino bootloader: Pro mini(3.3V/8M)
  • Lora frequency: 433M/ 868M/ 915M
  • Current: 30A@240VAC
  • Input Voltage: 12V




LoRa Receiver: Lora Radio (433M/868M/915M)

The Lora Radio Receiver is a mainboard based on the ATmega328 and 433MHZ/868MHz/915MHz RFM95 LoRa module. The LoRa Radio allows the user to send data and reach extremely long ranges at low data-rates. It provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current consumption. It has Arduino pro mini 3.3V 8MHz bootloader on this board and uses the CP2104 as USB to serial to upload the code using Arduino IDE. In this Lora Relay Control project, we will use it as a Receiver Gateway.

lora agriculture sensor

Features

  • BAT Input Voltage: 3.4-4.2V
  • Integrated Power Control System
  • 127 dB Dynamic Range RSSI
  • Uses the License-free ISM band: “European ISM” @ 433MHz/868MHz/915MHz
  • +5 to +20 dBm up to 100 mW Power Output Capability (power output selectable in software)
  • ~100mA Peak during +20dBm transmit, ~30mA during active radio listening
  • Range of approx. 2Km, depending on obstructions, frequency, antenna, and power output

Setting Up LoRa Relay Receiver

The Lora Power Relay can be used to switch the AC bulb light on or off. I integrated the 30A current relay, which will give you a wide use for the large current devices.

For the demonstration process I use a bulb and connected to the output of the Relay. The device can be powered up either using a 12V Adapter or a 12V Battery. Here is a circuit diagram of the entire connection.

LoRa Relay Module Connection

In order to upload code to the microcontroller, we need a USB-to-TTL or a FTDI Module.

Make a connection between Lora Relay Module and FTDI as shown in the table below.

So the complete connection and setup can be done as shown in the image below.

Relay Bulb Lora




Setting Up LoRa Sender/Controller

Now let us setup the receiver now. The Receiver module has two extra connections. We need to connect a 0.96″ I2C OLED Display and a Push Button Switch.

LoRA OLED Push Button

The Assembly of the circuit can be either done in a breadboard or it can be done using a Custom design PCB.


LoRa Relay Receiver Code

The Receiver Controller Code that need to uploaded to LoRa Relay Node is given below.

The code requires a LoRa Library to compile. So download the LoRa Library and add it to the Arduino IDE.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>
 
 
//define the pins used by the LoRa transceiver module
#define ss 10
#define rst 9
#define dio0 2
 
#define LED 5
 
#define RELAY_IO   4
 
#define BAND 433E6    //433E6 for Asia, 866E6 for Europe, 915E6 for North America
 
 
// Initialize variables to get and save LoRa data
int rssi;
int relayswitch;
String status;
String readingID;
 
 
// Replaces placeholder with RElay values
String processor(const String& var)
{
  //Serial.println(var);
  if(var == "STATUS")
  {
    return status;
  }
  else if (var == "RRSI")
  {
    return String(rssi);
  }
  return String();
}
 
void setup()
{
  Serial.begin(115200);
 
  
  pinMode(RELAY_IO, OUTPUT);
  pinMode(LED, OUTPUT);
  
  int counter;
 
  //setup LoRa transceiver module
  LoRa.setPins(ss, rst, dio0); //setup LoRa transceiver module
 
  while (!LoRa.begin(BAND) && counter < 10) {
    Serial.print(".");
    counter++;
    delay(2000);
  }
  if (counter == 10)
  {
    // Increment readingID on every new reading
    Serial.println("Starting LoRa failed!");
    
  }
    Serial.println("LoRa Initialization OK!");
    delay(2000);
 
}
 
 
// Read LoRa packet and get the sensor readings
void loop()
{
  int packetSize = LoRa.parsePacket();
  if (packetSize)
  {
    Serial.print("Lora packet received: ");
    while (LoRa.available())    // Read packet
  {
    String LoRaData = LoRa.readString();
    Serial.print(LoRaData);
    
    
    int pos1 = LoRaData.indexOf('&');      
    readingID = LoRaData.substring(0, pos1);                   // Get readingID
    status = LoRaData.substring(pos1 +1, LoRaData.length());   // Get status
 
    relayswitch = status.toInt();  //Converts string to integer
 
    if(relayswitch==1)
    {
      digitalWrite (RELAY_IO, relayswitch);
      digitalWrite (LED, relayswitch);
      
      Serial.println("Realy in ON");
    }
    
    else if(relayswitch==0)
    {
      digitalWrite (RELAY_IO, relayswitch);
      digitalWrite (LED, relayswitch);
      Serial.println("Realy in OFF");
    }  
  }
  rssi = LoRa.packetRssi();       // Get RSSI
  Serial.print(" with RSSI ");    
  Serial.println(rssi);
}
}

In order to upload the code, from the top Arduino IDE menu, select Tools-> Board-> Arduino Pro or Pro Mini. Then select the correct COM Port and click the upload button.

If you upload the firmware fails, press and hold the Reset button before uploading the firmware. When the IDE shows below, then release the button that may help to upload the firmware success. That’s we need a reset the MCU when uploading the firmware.



LoRa Sender/Controller Code

The LoRa Sender code for Controlling LoRa Relay Wirelessly is given below. Before uploading code you need to install the OLED Library first along with the LoRa Library.

  1. LoRa Library: Download
  2. Adafruit GFX Library: Download
  3. SSD1306 Library: Download

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
//Libraries for LoRa
#include <SPI.h>
#include <Wire.h>
#include <LoRa.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define SCREEN_WIDTH 128    // OLED display width, in pixels
#define SCREEN_HEIGHT 64    // OLED display height, in pixels
#define OLED_RESET 4        // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
 
#define LOGO_HEIGHT   53
#define LOGO_WIDTH    128
static const unsigned char PROGMEM logo_ON[] =
{ 0x87, 0x87, 0x87, 0xff,  /*Color of index 0*/
  0xf8, 0xf9, 0xf8, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff,
  0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf8, 0xff, 0xff,
  0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0xff,
  0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xcf, 0xff,
  0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf3, 0xff,
  0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfd, 0xff,
  0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0xff,
  0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xbf,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xdf,
  0xf0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xef,
  0xf0, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x78, 0x70, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xef,
  0xe0, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x78, 0x78, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf7,
  0xe0, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x78, 0x78, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xc0, 0x00, 0x00, 0x00, 0x0f, 0x7c, 0x78, 0x78, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfb,
  0xc0, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7c, 0x78, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7c, 0x78, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfd,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7c, 0x78, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfd,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7e, 0x78, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7e, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7e, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7e, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7f, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7f, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7f, 0x78, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7b, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7b, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7b, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x7b, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe,
  0x00, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x79, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x79, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfd,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x79, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfd,
  0x80, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x79, 0xf8, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xc0, 0x00, 0x00, 0x00, 0x0f, 0x3c, 0x78, 0xf8, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfb,
  0xc0, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0x78, 0xf8, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfb,
  0xe0, 0x00, 0x00, 0x00, 0x0f, 0xf8, 0x78, 0xf8, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf7,
  0xe0, 0x00, 0x00, 0x00, 0x07, 0xf8, 0x78, 0x78, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf7,
  0xf0, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x78, 0x70, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xef,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xbf,
  0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f,
  0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0xff,
  0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xfb, 0xff,
  0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf7, 0xff,
  0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xdf, 0xff,
  0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0x7f, 0xff,
  0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf3, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
 
static const unsigned char PROGMEM logo_OFF[] =
{ 0x3b, 0x3b, 0x3b, 0xff,  /*Color of index 0*/
  0xf6, 0xf8, 0xf6, 0xff,   /*Color of index 1*/
 
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0x87, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff,
  0xff, 0xfc, 0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff,
  0xff, 0xf3, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff,
  0xff, 0xef, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,
  0xff, 0x9f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff,
  0xff, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0xfe, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
  0xfd, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
  0xfb, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
  0xf3, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
  0xf7, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0x83, 0xff, 0x7f, 0xe0, 0x00, 0x00, 0x0f,
  0xef, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xc3, 0xff, 0x7f, 0xe0, 0x00, 0x00, 0x07,
  0xef, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xe3, 0xff, 0x7f, 0xe0, 0x00, 0x00, 0x07,
  0xdf, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xe3, 0xff, 0x7f, 0xe0, 0x00, 0x00, 0x03,
  0xdf, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x79, 0xe3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x03,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xfc, 0x7f, 0x80, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xfc, 0x7f, 0x80, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xfc, 0x7f, 0x80, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xfc, 0x7f, 0x80, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xe0, 0x7c, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0x7f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x00,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0xbf, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x78, 0xf3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x01,
  0xdf, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x79, 0xe3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x03,
  0xdf, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xe3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x03,
  0xef, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x3f, 0xe3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x07,
  0xef, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xc3, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x07,
  0xf7, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0x83, 0xc0, 0x78, 0x00, 0x00, 0x00, 0x0f,
  0xf3, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
  0xfb, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f,
  0xfd, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
  0xfe, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
  0xff, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
  0xff, 0x9f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff,
  0xff, 0xef, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff,
  0xff, 0xf3, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff,
  0xff, 0xfc, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff,
  0xff, 0xff, 0x8f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff,
  0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
 
//define the pins used by the LoRa transceiver module
#define ss 10
#define rst 9
#define dio0 2
 
#define BAND 433E6    //433E6 for Asia, 866E6 for Europe, 915E6 for North America
 
int button = 3;    //Push Button
int status = false;
int rssi;
 
//packet counter
int readingID = 0;
 
int counter = 0;
String LoRaMessage = "";
 
 
void setup()
{
  //initialize Serial Monitor
  Serial.begin(115200);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
  
  pinMode(button, INPUT_PULLUP);
 
  LoRa.setPins(ss, rst, dio0); //setup LoRa transceiver module
 
  while (!LoRa.begin(BAND) && counter < 10)
  {
    Serial.print(".");
    counter++;
    delay(500);
  }
  
  if (counter == 10)
  {
    // Increment readingID on every new reading
    readingID++;
    Serial.println("Starting LoRa failed!");
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("LoRa Initialization");
    display.println("");
    display.setTextSize(2);
    display.println("Failed! ");
    display.display();
  }
    Serial.println("LoRa Initialization OK!");
    display.clearDisplay();
    display.setCursor(0,0);  
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.println("LoRa Initialization");
    display.println(" ");
    display.setTextSize(2);
    display.println("OK! ");
    display.display();  
    delay(3000);
}
 
 
void loop()
{
  if (digitalRead(button) == true)
  {
  status = !status;
  
}
  while(digitalRead(button) == true);
  
  LoRaMessage = String(readingID) + "&" + String(status) ;
  //Send LoRa packet to receiver
  LoRa.beginPacket();
  LoRa.print(LoRaMessage);
  readingID++;
 
  rssi = LoRa.packetRssi();       // Get RSSI
  
  Serial.print("Sending packet: ");
  Serial.println(readingID);
  Serial.println(LoRaMessage);  
  
  LoRa.endPacket();
 
  if(status==1)
  {
  display.clearDisplay();
  display.drawBitmap(0, 8, logo_ON, LOGO_WIDTH, LOGO_HEIGHT, 1);
  display.display();
  }  
 
  else if(status==0)
  {
    display.clearDisplay();
    display.drawBitmap(0, 8, logo_OFF, LOGO_WIDTH, LOGO_HEIGHT, 1);
    display.display();
  }  
  
  delay(300);
}

For uploading code select the select Tools-> Board-> Arduino Pro or Pro Mini. Then select the correct COM Port and click the upload button.




Control Home Appliances using LoRa Relay Switch

After setting up and uploading the code in both the LoRa Node & Gateway, you can now check the working of the device. Power ON both the circuit and then strat testing.

When you press the push button on the Sender side the Relay gets activated and Bulb turns ON.

When you press the push button once again on the Sender side the Relay gets disconnected and Bulb turns OFF.


Video Tutorial & Guide

LoRa Based Remote Appliances Control Project | LoRa Power Relay Control Switch
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleInternet with A9G Low Power GPRS+GPS Module & Arduino
Next Article Simple PWM Lamp Dimmer Circuit using IC 555 Timer

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20262K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 3 Comments

3 Comments

  1. awsmonitoring on May 19, 2021 3:03 AM

    Good Day,

    I am trying to modify your code to allow for a solid sate switch. In other words, when DIO 3 is high then relay on and if DIO 3 Low then relay off. Please can you assist me as I only seam to “flash” the light with no control. I know I have done something wrong.

    Thank you

    Reply
  2. aman_uniolabs on September 8, 2021 7:05 PM

    Hi, for how long you have tested your device. I mean by lora connectivity.
    I have made a similar circuit for testing the lora connectivity(point to point communication) using leds but the connectivity sustain only for 3 days after that lora communication is getting disconnected. Even i tried rebooting the controller to setup the connection again but it getting connected again between 1 to 7 times of reboot. Have you faced this issue of lora getting disconnected any time during testing of your project? if yes, then how you solved it?

    Reply
    • Admin on September 8, 2021 7:07 PM

      I didn’t face any such issue. But you can implement watch dog timer reset or a periodic automatic reset after every 30 minutes. This might fix the issue.

      Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • RS-485 Simplex Communication with Arduino & MAX485
    RS-485 Simplex Communication with Arduino & MAX485
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.