Smart Street Light Management System Using LoRa Module

by Gowri C H in Circuits > Electronics

399 Views, 4 Favorites, 0 Comments

Smart Street Light Management System Using LoRa Module

Garnet 50W LED street light, 6500K 5.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

·      Bharat Pi LoRa module

·      Light Dependent Resistor

·      LED

·      Breadboard

Use of LDR Sensor

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

WhatsApp Image 2023-09-16 at 10.23.05 PM.jpeg
WhatsApp Image 2023-09-16 at 10.23.15 PM.jpeg
WhatsApp Image 2023-09-16 at 10.23.18 PM.jpeg

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):

//LoRa-Hopping-Network
//node1-Transmitter

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

//add more server address to add more number of LoRa nodes
#define CLIENT_ADDRESS 1 //tramsitting Lora node address
#define SERVER_ADDRESS 2 //recieving Lora 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()) { //initiate the LoRa module
Serial.println("LoRa initialization failed.");
while (1);
}
rf95.setFrequency(866.0); // Set the frequency (915 MHz for US)
}

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/GowriHarsha76/LoRa-Hopping-Network

Result

WhatsApp Image 2023-09-16 at 10.23.13 PM.jpeg
WhatsApp Image 2023-09-16 at 10.23.12 PM.jpeg
WhatsApp Image 2023-09-16 at 10.23.11 PM.jpeg

Working Video

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