Lora Weather Station With Arduino
Simple Weather Station With Lora, Arduino & Sensors
Components and supplies
DHT11 Temperature & Humidity Sensor (4 pins)
Arduino Nano R3
Breadboard (generic)
MyOctopus i2c Barometric Air Pressure Sensor BMP280
I2C 16x2 Arduino LCD Display Module
LORA RFM95
Ldr Sensor
5 mm LED: Red
Tools and machines
Soldering iron (generic)
PCB Holder, Soldering Iron
Solder Flux, Soldering
Solder Wire, Lead Free
Apps and platforms
Arduino IDE
Project description
Code
Lora Sender Code
c_cpp
Upload The Code To Lora Sender
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 * last updated - time 11:26am - date 12 may 2021 5 */ 6 7#include <SPI.h> 8#include <LoRa.h> 9 10#include "DHT.h" 11#include <Adafruit_BMP280.h> 12 13#define DHTPIN 7 14#define DHTTYPE DHT11 15Adafruit_BMP280 bmp; 16 17float Pressure; 18float Altitude; 19int ldr = 4; 20int counter = 0; 21int Dummyvalue; 22 23DHT dht(DHTPIN, DHTTYPE); 24long randNumber; //Create Random Number To Avoid Transmission Loss For First Digit 25 26void setup() 27{ 28 Serial.begin(115200); 29 30 randomSeed(analogRead(0)); 31 dht.begin(); 32 33if (!bmp.begin()) { 34 Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 35 while (1); 36 } 37 38 pinMode(ldr, OUTPUT); 39 while (!Serial); 40 41 Serial.println(" Lora Weather Station By ZenoModiff "); 42 43 if (!LoRa.begin(915E6)) { 44 Serial.println("Starting LoRa failed!"); 45 } 46 else 47 { 48 Serial.println("Starting LoRa Sucesses!"); 49 } 50} 51void loop() 52{ 53 Serial.println(); 54 Serial.print("Sending packet: "); 55 Serial.println(counter); 56 randNumber = random(1000); 57 58 59 int randNumber = random(100); Dummyvalue = randNumber; 60 double ldrvalue = analogRead(ldr); 61 float h = dht.readHumidity(); 62 float t = dht.readTemperature(); 63 float f = dht.readTemperature(true); 64 float pressure = (bmp.readPressure()/100); Pressure = pressure; 65 int altitude = (bmp.readAltitude(1019.66)); Altitude = altitude; 66 67 68 if (isnan(h) || isnan(t) || isnan(f)) { 69 Serial.println(F("Failed to read from DHT sensor!")); 70 return; 71 } 72 73 String Datastring = String(Dummyvalue) + (";") + String(t) + (";") + String(h) + (";") + String(ldrvalue) + (";") + String (Pressure) + (";") + String (Altitude); 74 75 Serial.println(Datastring); 76 LoRa.beginPacket(); 77 LoRa.print(Datastring); 78 LoRa.print(counter); 79 LoRa.endPacket(); 80 counter++; 81 82 delay(3000); 83 84}
Lora Reciever Code
c_cpp
Upload The Code To Lora Reciever
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 * last updated - time 11:28am - date 12 may 2021 5 */ 6 7#include <Wire.h> 8#include <SPI.h> 9#include <LoRa.h> 10#include <LiquidCrystal_I2C.h> 11 12LiquidCrystal_I2C lcd(0x27, 16, 2); 13 14void setup() 15{ 16 17 Serial.begin(115200); 18 19 lcd.begin(); 20 lcd.setCursor(0,0); 21 lcd.print("LoRa Weather"); 22 lcd.setCursor(0,3); 23 lcd.print("Station"); 24 delay(2000); 25 lcd.clear(); 26 lcd.print("By"); 27 lcd.setCursor(0,3); 28 lcd.print("Zeno Modiff"); 29 delay (2000); 30 while (!Serial); 31 32 Serial.println("LoRa Receiver By Zeno Modiff"); 33 34 if (!LoRa.begin(915E6)) { 35 Serial.println("Starting LoRa failed!"); 36 while (1); 37 } 38} 39 40void loop() { 41 42 String packet = ""; 43 44 int packetSize = LoRa.parsePacket(); 45 if (packetSize) { 46 47 Serial.print("Received packet :-- "); 48 49 while (LoRa.available()) { 50 51 packet = LoRa.readString(); 52 } 53 54 Serial.println(packet); 55 Serial.println(); 56 57int firstcommaIndex = packet.indexOf(';'); 58int secondCommaIndex = packet.indexOf(';', firstcommaIndex+1); 59int thirdCommaIndex = packet.indexOf(';', secondCommaIndex+1); 60int fourthCommaIndex = packet.indexOf(';', thirdCommaIndex+1); 61int fifthCommaIndex = packet.indexOf(';', fourthCommaIndex+1); 62int sixthCommaIndex = packet.indexOf(';', fifthCommaIndex+1); 63 64String firstValue = packet.substring( 0, firstcommaIndex); 65String secondValue = packet.substring(firstcommaIndex+1, secondCommaIndex); 66String thirdValue = packet.substring(secondCommaIndex+1, thirdCommaIndex); 67String fourthValue = packet.substring(thirdCommaIndex +1, fourthCommaIndex); 68String fifthValue = packet.substring(fourthCommaIndex+1, fifthCommaIndex); 69String sixthValue = packet.substring(fifthCommaIndex+1, sixthCommaIndex); 70 71Serial.print("Temp:-"); Serial.println(secondValue); 72Serial.print("Humi:-"); Serial.println(thirdValue); 73Serial.print("Ldr:-"); Serial.println(fourthValue); 74Serial.print("Pressure:-"); Serial.println(fifthValue); 75Serial.print("Altitude:-"); Serial.println(sixthValue); 76Serial.println(); 77 78/*since we can't print the first digit 79it is a dummy value sent by the LoRa String 80in case of transmission Loss*/ 81 82lcd.clear(); lcd.setCursor(0,0); 83lcd.print("Temp:-"); lcd.println(secondValue); 84delay(2000); 85 86lcd.clear(); lcd.setCursor(0,0); 87lcd.print("Humi:-"); lcd.println(thirdValue); 88delay(2000); 89 90lcd.clear(); lcd.setCursor(0,0); 91lcd.print("Ldr:-"); lcd.println(fourthValue); 92delay(2000); 93 94lcd.clear(); lcd.setCursor(0,0); 95lcd.print("Pres:-"); lcd.println(fifthValue); 96delay(2000); 97 98lcd.clear(); lcd.setCursor(0,0); 99lcd.print("Alti:-"); lcd.println(sixthValue); 100delay(2000); 101 102} 103}
Lora Sender Code
c_cpp
Upload The Code To Lora Sender
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 * last updated - time 11:26am - date 12 may 2021 5 */ 6 7#include <SPI.h> 8#include <LoRa.h> 9 10#include "DHT.h" 11#include <Adafruit_BMP280.h> 12 13#define DHTPIN 7 14#define DHTTYPE DHT11 15Adafruit_BMP280 bmp; 16 17float Pressure; 18float Altitude; 19int ldr = 4; 20int counter = 0; 21int Dummyvalue; 22 23DHT dht(DHTPIN, DHTTYPE); 24long randNumber; //Create Random Number To Avoid Transmission Loss For First Digit 25 26void setup() 27{ 28 Serial.begin(115200); 29 30 randomSeed(analogRead(0)); 31 dht.begin(); 32 33if (!bmp.begin()) { 34 Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 35 while (1); 36 } 37 38 pinMode(ldr, OUTPUT); 39 while (!Serial); 40 41 Serial.println(" Lora Weather Station By ZenoModiff "); 42 43 if (!LoRa.begin(915E6)) { 44 Serial.println("Starting LoRa failed!"); 45 } 46 else 47 { 48 Serial.println("Starting LoRa Sucesses!"); 49 } 50} 51void loop() 52{ 53 Serial.println(); 54 Serial.print("Sending packet: "); 55 Serial.println(counter); 56 randNumber = random(1000); 57 58 59 int randNumber = random(100); Dummyvalue = randNumber; 60 double ldrvalue = analogRead(ldr); 61 float h = dht.readHumidity(); 62 float t = dht.readTemperature(); 63 float f = dht.readTemperature(true); 64 float pressure = (bmp.readPressure()/100); Pressure = pressure; 65 int altitude = (bmp.readAltitude(1019.66)); Altitude = altitude; 66 67 68 if (isnan(h) || isnan(t) || isnan(f)) { 69 Serial.println(F("Failed to read from DHT sensor!")); 70 return; 71 } 72 73 String Datastring = String(Dummyvalue) + (";") + String(t) + (";") + String(h) + (";") + String(ldrvalue) + (";") + String (Pressure) + (";") + String (Altitude); 74 75 Serial.println(Datastring); 76 LoRa.beginPacket(); 77 LoRa.print(Datastring); 78 LoRa.print(counter); 79 LoRa.endPacket(); 80 counter++; 81 82 delay(3000); 83 84}
Lora Reciever Code
c_cpp
Upload The Code To Lora Reciever
1/*feel free to contact 2 * sreeramaj53@gmail.com 3 * www.youtube.com/ZenoModiff 4 5 * last updated - time 11:28am - date 12 may 2021 6 */ 7 8#include <Wire.h> 9 10#include <SPI.h> 11#include <LoRa.h> 12#include <LiquidCrystal_I2C.h> 13 14LiquidCrystal_I2C 15 lcd(0x27, 16, 2); 16 17void setup() 18{ 19 20 Serial.begin(115200); 21 22 23 lcd.begin(); 24 lcd.setCursor(0,0); 25 lcd.print("LoRa Weather"); 26 lcd.setCursor(0,3); 27 28 lcd.print("Station"); 29 delay(2000); 30 lcd.clear(); 31 lcd.print("By"); 32 33 lcd.setCursor(0,3); 34 lcd.print("Zeno Modiff"); 35 delay (2000); 36 while 37 (!Serial); 38 39 Serial.println("LoRa Receiver By Zeno Modiff"); 40 41 if 42 (!LoRa.begin(915E6)) { 43 Serial.println("Starting LoRa failed!"); 44 while 45 (1); 46 } 47} 48 49void loop() { 50 51 String packet = ""; 52 53 54 int packetSize = LoRa.parsePacket(); 55 if (packetSize) { 56 57 Serial.print("Received 58 packet :-- "); 59 60 while (LoRa.available()) { 61 62 packet = LoRa.readString(); 63 64 } 65 66 Serial.println(packet); 67 Serial.println(); 68 69int 70 firstcommaIndex = packet.indexOf(';'); 71int secondCommaIndex = packet.indexOf(';', 72 firstcommaIndex+1); 73int thirdCommaIndex = packet.indexOf(';', secondCommaIndex+1); 74int 75 fourthCommaIndex = packet.indexOf(';', thirdCommaIndex+1); 76int fifthCommaIndex 77 = packet.indexOf(';', fourthCommaIndex+1); 78int sixthCommaIndex = packet.indexOf(';', 79 fifthCommaIndex+1); 80 81String firstValue = packet.substring( 0, firstcommaIndex); 82String 83 secondValue = packet.substring(firstcommaIndex+1, secondCommaIndex); 84String 85 thirdValue = packet.substring(secondCommaIndex+1, thirdCommaIndex); 86String 87 fourthValue = packet.substring(thirdCommaIndex +1, fourthCommaIndex); 88String 89 fifthValue = packet.substring(fourthCommaIndex+1, fifthCommaIndex); 90String 91 sixthValue = packet.substring(fifthCommaIndex+1, sixthCommaIndex); 92 93Serial.print("Temp:-"); 94 Serial.println(secondValue); 95Serial.print("Humi:-"); Serial.println(thirdValue); 96Serial.print("Ldr:-"); 97 Serial.println(fourthValue); 98Serial.print("Pressure:-"); Serial.println(fifthValue); 99 100Serial.print("Altitude:-"); Serial.println(sixthValue); 101Serial.println(); 102 103/*since 104 we can't print the first digit 105it is a dummy value sent by the LoRa String 106in 107 case of transmission Loss*/ 108 109lcd.clear(); lcd.setCursor(0,0); 110lcd.print("Temp:-"); 111 lcd.println(secondValue); 112delay(2000); 113 114lcd.clear(); lcd.setCursor(0,0); 115lcd.print("Humi:-"); 116 lcd.println(thirdValue); 117delay(2000); 118 119lcd.clear(); lcd.setCursor(0,0); 120lcd.print("Ldr:-"); 121 lcd.println(fourthValue); 122delay(2000); 123 124lcd.clear(); lcd.setCursor(0,0); 125lcd.print("Pres:-"); 126 lcd.println(fifthValue); 127delay(2000); 128 129lcd.clear(); lcd.setCursor(0,0); 130lcd.print("Alti:-"); 131 lcd.println(sixthValue); 132delay(2000); 133 134} 135}
Downloadable files
Schematics For Lora Reciever
Connect As per Schematics
Schematics For Lora Reciever

Schematics For Lora Reciever
Connect As per Schematics
Schematics For Lora Reciever

Schematics For Lora Sender
Connect As Per Schematics
Schematics For Lora Sender

Comments
Only logged in users can leave comments