Hardware components | ||||||
| × | 2 | ||||
| × | 2 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 2 | ||||
Software apps and online services | ||||||
| ||||||
Hand tools and fabrication machines | ||||||
| ||||||
| ||||||
| ||||||
|
Today iam going to show you how to make LoRa (rfm95) Weather Station With Arduino & Sensors this is a simple project does not require high knowledge about arduino and electronics this is an intermediate level project, so its kind of okay to you. I tried my best to document this project to you, to look simple. so you can also make this project as I do, if you appreciate my work, a sub to my youtube channelwill make me happy and keeps me motivated so I can make new projects for you in the near future, so with out further ado lets get started........
/*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);
}
/*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);
}
}
Comments