ZenoModiff
Published © LGPL

Lora Weather Station With Arduino

Simple Weather Station With Lora, Arduino & Sensors

IntermediateFull instructions provided4,046
Lora Weather Station With Arduino

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×2
Bolt IoT LORA RFM95
×2
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Ldr Sensor
×1
MyOctopus i2c Barometric Air Pressure Sensor BMP280
MyOctopus i2c Barometric Air Pressure Sensor BMP280
×1
5 mm LED: Red
5 mm LED: Red
×1
Breadboard (generic)
Breadboard (generic)
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron

Story

Read more

Schematics

Schematics For Lora Reciever

Connect As per Schematics

Schematics For Lora Sender

Connect As Per Schematics

Code

Lora Sender Code

C/C++
Upload The Code To Lora Sender
/*feel free to contact
 * sreeramaj53@gmail.com
 * www.youtube.com/ZenoModiff
 * last updated - time 11:26am - date 12 may 2021
 */

#include <SPI.h>
#include <LoRa.h>

#include "DHT.h"
#include <Adafruit_BMP280.h>

#define DHTPIN 7
#define DHTTYPE DHT11
Adafruit_BMP280 bmp; 

float Pressure;
float Altitude;
int ldr = 4;
int counter = 0;
int Dummyvalue;

DHT dht(DHTPIN, DHTTYPE);
long randNumber; //Create Random Number To Avoid Transmission Loss For First Digit

void setup() 
{
  Serial.begin(115200);
  
 randomSeed(analogRead(0));
 dht.begin();
 
if (!bmp.begin()) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }

   pinMode(ldr, OUTPUT);
  while (!Serial);
  
  Serial.println(" Lora Weather Station By ZenoModiff ");

  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
  }
  else
  {
   Serial.println("Starting LoRa Sucesses!");
  }
}
void loop()
{
 Serial.println();
 Serial.print("Sending packet: ");
 Serial.println(counter);
 randNumber = random(1000);

 
 int randNumber = random(100); Dummyvalue = randNumber;
 double ldrvalue = analogRead(ldr);
 float h = dht.readHumidity();
 float t = dht.readTemperature();
 float f = dht.readTemperature(true);
 float pressure = (bmp.readPressure()/100); Pressure = pressure;
 int altitude =  (bmp.readAltitude(1019.66)); Altitude = altitude; 
  

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  String Datastring = String(Dummyvalue) + (";") + String(t) + (";") + String(h) + (";") + String(ldrvalue) + (";") + String (Pressure) + (";") + String (Altitude);
 
  Serial.println(Datastring);
  LoRa.beginPacket();      
  LoRa.print(Datastring);
  LoRa.print(counter);
  LoRa.endPacket();
  counter++;
  
  delay(3000);
  
}

Lora Reciever Code

C/C++
Upload The Code To Lora Reciever
/*feel free to contact
 * sreeramaj53@gmail.com
 * www.youtube.com/ZenoModiff
 * last updated - time 11:28am - date 12 may 2021
 */

#include <Wire.h> 
#include <SPI.h>
#include <LoRa.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() 
{  
  
  Serial.begin(115200);

  lcd.begin();
  lcd.setCursor(0,0);
  lcd.print("LoRa Weather");
  lcd.setCursor(0,3);
  lcd.print("Station");
  delay(2000);
  lcd.clear();
  lcd.print("By");
  lcd.setCursor(0,3);
  lcd.print("Zeno Modiff");
  delay (2000);
  while (!Serial);

  Serial.println("LoRa Receiver By Zeno Modiff");

  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

void loop() {
  
  String packet = "";
  
  int packetSize = LoRa.parsePacket();
  if (packetSize) {

    Serial.print("Received packet :-- ");

    while (LoRa.available()) {
    
    packet = LoRa.readString();
    }
    
    Serial.println(packet);
    Serial.println();

int firstcommaIndex   = packet.indexOf(';');
int secondCommaIndex  = packet.indexOf(';', firstcommaIndex+1);
int thirdCommaIndex   = packet.indexOf(';', secondCommaIndex+1);
int fourthCommaIndex  = packet.indexOf(';', thirdCommaIndex+1);   
int fifthCommaIndex   = packet.indexOf(';', fourthCommaIndex+1);
int sixthCommaIndex   = packet.indexOf(';', fifthCommaIndex+1);

String firstValue  =  packet.substring( 0, firstcommaIndex);
String secondValue =  packet.substring(firstcommaIndex+1, secondCommaIndex);
String thirdValue  =  packet.substring(secondCommaIndex+1, thirdCommaIndex);
String fourthValue =  packet.substring(thirdCommaIndex +1, fourthCommaIndex);
String fifthValue  =  packet.substring(fourthCommaIndex+1, fifthCommaIndex);
String sixthValue  =  packet.substring(fifthCommaIndex+1,  sixthCommaIndex);

Serial.print("Temp:-"); Serial.println(secondValue);
Serial.print("Humi:-"); Serial.println(thirdValue);
Serial.print("Ldr:-"); Serial.println(fourthValue); 
Serial.print("Pressure:-"); Serial.println(fifthValue);  
Serial.print("Altitude:-"); Serial.println(sixthValue); 
Serial.println();

/*since we can't print the first digit 
it is a dummy value sent by the LoRa String 
in case of transmission Loss*/

lcd.clear(); lcd.setCursor(0,0);
lcd.print("Temp:-"); lcd.println(secondValue);
delay(2000);

lcd.clear(); lcd.setCursor(0,0);
lcd.print("Humi:-"); lcd.println(thirdValue);
delay(2000);

lcd.clear(); lcd.setCursor(0,0);
lcd.print("Ldr:-"); lcd.println(fourthValue);
delay(2000);

lcd.clear(); lcd.setCursor(0,0);
lcd.print("Pres:-"); lcd.println(fifthValue);
delay(2000);

lcd.clear(); lcd.setCursor(0,0);
lcd.print("Alti:-"); lcd.println(sixthValue);
delay(2000);

}
}

Credits

ZenoModiff

ZenoModiff

15 projects • 10 followers

Comments