Smart Street Light Management System Using LoRa Module

by 1ay20ec094 in Circuits > Electronics

286 Views, 2 Favorites, 0 Comments

Smart Street Light Management System Using LoRa Module

light.jpg

Street light provide clear illumination that enhances road safety and security also reduces the risk of accidents by providing improved visibility during night.

LoRa is a long range communication used for low power consumption in wide area network technology for the internet of things. LoRa significantly provides greater communication with low bandwidths than other wireless data transmission technology.

This project delivers prototype of the street light management using LoRa technology in which LDR sensor helps in distinguishing between day/night and switches the light on/off accordingly.

Supplies

  1.     Bharat Pi LoRa module
  2.     Light Dependent Resistor
  3.     LED
  4.     Breadboard

Use of LDR Sensor

on.jpg
off.jpg

Automatic ON/OFF:

This module consists of LDR (light dependent resistor), processing unit and LoRa transceiver. The LDR detects the presence of environmental illumination. Whenever the illumination is dull, the sensed signal of LDR enables the process to trigger the relay circuit connected to the lamp to switch ON.

The reverse condition will switch OFF the lamp. Thus automatic ON/OFF is realized on the basis of the environmental illumination.

Bharat Pi LoRa Module

LoRa technology:


LoRa is an RF modulation technology for low-power, wide area networks (LPWANs). The name, LoRa, is a reference to the extremely long-range data links that this technology enables. created by Semtech to standardize LPWANs, LoRa provides for long-range communications: up to three miles (five kilometers) in urban areas, and up to 10 miles (15 kilometers) or more in rural areas (line of sight). A key characteristic of the LoRa-based solutions is ultra-low power requirements, which allows for the creation of battery-operated devices that can last for up to 10 years. Deployed in a star topology, a network based on the open LoRaWAN protocol is perfect for applications that require long-range or deep in-building communication among a large number of devices that have low power requirements and that collect small amounts of data.


Bharat Pi LoRa module:


 Bharat Pi LoRa board has a RFM95w 868MHZ lora long range trans receiver module chip along with ESP32 microcontroller which will make it compatible with using Arduino IDE based programming. All exiting ESP/Ardunio programs are compatible and can be programmed to Bharat Pi board without any code changes. Bharat Pi board has multiple network connectivity option like LoRa, Wi-Fi and Bluetooth. All network connectivity options on a single board to build any Smart metering use case/project. The LoRa board can act as a node or a gateway as it has ESP onboard for internet connectivity. It can be powered using a 9V power adapter or by connectivity a Type-C USB cable. 


Connections

node1.jpg
node2.jpg
node3.jpg

Led has two ends. One end is connected to ground pin other end is connected to bharat pi pin number 14 through 3.3k resistor.

LDR has three terminals whose 1 end is connected to ground, second terminal is connected to pin number 15 and the other terminal is connected to 5V power supply.

Code

Node 1(Master):

#include <SPI.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2 
RH_RF95 rf95(4, 2);
RHMesh manager(rf95, CLIENT_ADDRESS);
void setup() {
 Serial.begin(115200);
 if (!manager.init()) { //initiate the LoRa module
   Serial.println("LoRa initialization failed.");
   while (1);
 }
 rf95.setFrequency(866.0);
}
void loop() {
 String dataToSend = "Streetlight 1 is ON";
 String dataToSend1 = Serial.readString(); //Enter the data to be sent
 //in our project we have specified "On" to switch on light in node 3,"off" to turn off led remotely
 
 // Send data to Node 2
 manager.sendtoWait((uint8_t*)dataToSend.c_str(), dataToSend.length(), SERVER_ADDRESS); //Transmission line code
 delay(1000);
 manager.sendtoWait((uint8_t*)dataToSend1.c_str(), dataToSend1.length(), SERVER_ADDRESS);
 
 Serial.println("Data sent to Node 2: " + dataToSend);
 
 Serial.println("Data sent to Node 2: " + dataToSend1);

 // delay(1000); // Send data every 5 seconds
}


Node 2(Relay):

node 2
#include <SPI.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>

//imcrease the servers and respective server address to add more devices.
#define CLIENT_ADDRESS 2 //transmitter node address.
#define SERVER_ADDRESS 3 //reciever node address.

RH_RF95 rf95(4, 2); // Set the LoRa module pins

RHMesh manager(rf95, CLIENT_ADDRESS);

void setup() {
 Serial.begin(115200); //set the Baud rate
 if (!manager.init()) {
   Serial.println("LoRa initialization failed.");
   while (1);
 }
 rf95.setFrequency(866.0); // Set the frequency (915 MHz for US)
}

void loop() {
 uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
 uint8_t len = sizeof(buf);
 uint8_t from;

 if (manager.recvfromAck(buf, &len, &from)) { // reciever code line   
   String receivedData = (char*)buf;//recieved data is stored in variable buf
   Serial.println("Received data from Node " + String(from) + ": " + receivedData);

   // Process the received data
   // Implement your logic here if any functionality is required from node 2 or relay.

   // Forward the data to Node 3
   manager.sendtoWait(buf, len, SERVER_ADDRESS);// sender code line
 }
}


Node-3 (Receiver):

//node_3 reciever node
#include <SPI.h>
#include <RHRouter.h>
#include <RHMesh.h>
#include <RH_RF95.h>

#define CLIENT_ADDRESS 3 //Receiever address

RH_RF95 rf95(4, 2); // Set the LoRa module pins

RHMesh manager(rf95, CLIENT_ADDRESS);

void setup() {
 pinMode(14, OUTPUT); // Set the LED pin as an output
 Serial.begin(115200);
 if (!manager.init()) {
   Serial.println("LoRa initialization failed.");
   while (1);
 }
 rf95.setFrequency(866.0); // Set the frequency (915 MHz for US)
}

void loop() {
 uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
 uint8_t len = sizeof(buf);
 uint8_t from;

 if (manager.recvfromAck(buf, &len, &from)) {
   String receivedData = (char*)buf;
   Serial.print("Received data from Node " + String(from) + ": " + receivedData);
//Remote on and off street light logic
   if (receivedData == "on") {
     digitalWrite(14, HIGH);
     Serial.println(" - LED ON");
   } else if (receivedData == "off") {
     digitalWrite(14, LOW);
     Serial.println(" - LED OFF");
   } else {
     Serial.println(" - Invalid command");
   }
 }
}


https://github.com/vijay1ay20ec094/Smart-Street-Light.git

Result

l1.jpg
l2.jpg
stright light.jpg

Working Videos

Creating a mesh using lora of Bharatpi
Control of LED using LDR( LoRa of Bharatpi )
Duplex Communication of lora board ( Bharatpi )