SG-2.0 Wireless Weather Station
In this paper we have presented how to implement a Weather Station to monitor different parameters.
Components and supplies
Rotary potentiometer (generic)
Arduino Nano R3
SparkFun Transceiver Breakout - nRF24L01+
DHT22 Temperature Sensor
DS3231M - ±5ppm, I2C Real-Time Clock
BMP180
RGB LCD Shield Kit, 16x2 Character Display
DHT11 Temperature & Humidity Sensor (3 pins)
Tools and machines
Soldering iron (generic)
Apps and platforms
Arduino IDE
Project description
Code
Outdoor Unity
arduino
This is the code for Outdoor Unity
1#include <Adafruit_BMP085.h> 2#include <DHT.h> 3#include <DHT_U.h> 4#include <Adafruit_Sensor.h> 5#include <SPI.h> 6#include <nRF24L01.h> 7#include <RF24.h> 8#include <printf.h> 9#include <RF24_config.h> 10#include <Wire.h> 11 12#define DHTPIN 8 13#define DHTTYPE DHT22 14 15Adafruit_BMP085 bmp; 16 17RF24 myRadio (8, 9); 18byte addresses[][6] = {"0"}; 19const int led_pin = 7; 20 21struct package 22{ 23 float temperature; 24 float humidity; 25 float pressure; 26 float altitude; 27 float bmptemperature; 28 float pressureseelevel; 29}; 30 31typedef struct package Package; 32Package data; 33 34DHT dht(DHTPIN, DHTTYPE); 35 36 37void setup() 38{ 39 Serial.begin(9600); 40 dht.begin(); 41 bmp.begin(); 42 pinMode(led_pin, OUTPUT); 43 44 myRadio.begin(); 45 myRadio.setChannel(115); 46 myRadio.setPALevel(RF24_PA_MAX); 47 myRadio.setDataRate(RF24_250KBPS); 48 myRadio.openWritingPipe(addresses[0]); 49 delay(1000); 50} 51 52 53 54void loop() 55{ 56 digitalWrite(led_pin, HIGH); 57 readSensor(); 58 bmpSensor(); 59 Serial.print("hum"); 60 Serial.print(data.humidity); 61 Serial.print("temp"); 62 Serial.print(data.temperature); 63 myRadio.write(&data, sizeof(data)); 64 digitalWrite(led_pin, LOW); 65 delay(5000); 66} 67 68 69 70void readSensor() 71{ 72 data.humidity = dht.readHumidity(); 73 data.temperature = dht.readTemperature(); 74} 75 76void bmpSensor() 77{ 78 79 data.altitude = bmp.readAltitude(); 80 data.pressure = (bmp.readPressure()/100); 81 data.bmptemperature = bmp.readTemperature(); 82 data.pressureseelevel = (bmp.readSealevelPressure()/100); 83 84 Serial.print(data.altitude, 1); 85 Serial.print(data.pressure,1); 86 87 Serial.print("Temperature = "); 88 Serial.print(bmp.readTemperature()); 89 Serial.print(" *C"); 90 91 Serial.print("Pressure = "); 92 Serial.print(bmp.readPressure()); 93 Serial.print(" Pa"); 94 95 Serial.print("Altitude = "); 96 Serial.print(bmp.readAltitude(), 1); 97 Serial.print(" metri"); 98 99 Serial.print("Alt at Sea Level = "); 100 Serial.print(bmp.readSealevelPressure(), 1); 101 Serial.print(" metri"); 102 103 Serial.println(); 104 delay(1000); 105} 106
Outdoor Unity
arduino
This is the code for Outdoor Unity
1#include <Adafruit_BMP085.h> 2#include <DHT.h> 3#include <DHT_U.h> 4#include <Adafruit_Sensor.h> 5#include <SPI.h> 6#include <nRF24L01.h> 7#include <RF24.h> 8#include <printf.h> 9#include <RF24_config.h> 10#include <Wire.h> 11 12#define DHTPIN 8 13#define DHTTYPE DHT22 14 15Adafruit_BMP085 bmp; 16 17RF24 myRadio (8, 9); 18byte addresses[][6] = {"0"}; 19const int led_pin = 7; 20 21struct package 22{ 23 float temperature; 24 float humidity; 25 float pressure; 26 float altitude; 27 float bmptemperature; 28 float pressureseelevel; 29}; 30 31typedef struct package Package; 32Package data; 33 34DHT dht(DHTPIN, DHTTYPE); 35 36 37void setup() 38{ 39 Serial.begin(9600); 40 dht.begin(); 41 bmp.begin(); 42 pinMode(led_pin, OUTPUT); 43 44 myRadio.begin(); 45 myRadio.setChannel(115); 46 myRadio.setPALevel(RF24_PA_MAX); 47 myRadio.setDataRate(RF24_250KBPS); 48 myRadio.openWritingPipe(addresses[0]); 49 delay(1000); 50} 51 52 53 54void loop() 55{ 56 digitalWrite(led_pin, HIGH); 57 readSensor(); 58 bmpSensor(); 59 Serial.print("hum"); 60 Serial.print(data.humidity); 61 Serial.print("temp"); 62 Serial.print(data.temperature); 63 myRadio.write(&data, sizeof(data)); 64 digitalWrite(led_pin, LOW); 65 delay(5000); 66} 67 68 69 70void readSensor() 71{ 72 data.humidity = dht.readHumidity(); 73 data.temperature = dht.readTemperature(); 74} 75 76void bmpSensor() 77{ 78 79 data.altitude = bmp.readAltitude(); 80 data.pressure = (bmp.readPressure()/100); 81 data.bmptemperature = bmp.readTemperature(); 82 data.pressureseelevel = (bmp.readSealevelPressure()/100); 83 84 Serial.print(data.altitude, 1); 85 Serial.print(data.pressure,1); 86 87 Serial.print("Temperature = "); 88 Serial.print(bmp.readTemperature()); 89 Serial.print(" *C"); 90 91 Serial.print("Pressure = "); 92 Serial.print(bmp.readPressure()); 93 Serial.print(" Pa"); 94 95 Serial.print("Altitude = "); 96 Serial.print(bmp.readAltitude(), 1); 97 Serial.print(" metri"); 98 99 Serial.print("Alt at Sea Level = "); 100 Serial.print(bmp.readSealevelPressure(), 1); 101 Serial.print(" metri"); 102 103 Serial.println(); 104 delay(1000); 105} 106
Indoor Unity
arduino
This is the code for Indoor Unity
1#include <DS3231.h> 2#include <LiquidCrystal.h> 3#include <DHT.h> 4#include <DHT_U.h> 5#include <RF24_config.h> 6#include <Adafruit_Sensor.h> 7#include <SPI.h> 8#include <nRF24L01.h> 9#include <RF24.h> 10#include <printf.h> 11#include <Wire.h> 12 13#define DHTPIN 8 14#define DHTTYPE DHT11 15DHT dht(DHTPIN, DHTTYPE); //initializare senzor DHT11 16 17DS3231 rtc(SDA, SCL); //initializare modul DS3231 18 19RF24 myRadio(8, 9); // initializare modul NRF24L01 20byte addresses[][6] = {"0"}; 21 22const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 23LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //initializare LCD 24 25int chk; //variabila pentru citirea datelor de la DHT!1 26int InTemp, InHum, OutTemp, OutHum, OutPress, OutAlt, bmptemp; //variabile 27 28struct package //packetul de date pe care il primeste 29{ 30 float temperature ; 31 float humidity ; 32 float pressure; 33 float altitude; 34 float bmptemperature; 35 float pressureseelevel; 36}; 37 38typedef struct package Package; 39Package data; 40 41 42 43 44 void setup() 45 { 46 lcd.begin(16, 2); 47 dht.begin(); 48 Serial.begin(9600); 49 50 rtc.begin(); 51 rtc.setDOW(FRIDAY); 52 rtc.setTime(12, 0, 0); 53 rtc.setDate(8, 3, 2022); 54 55 myRadio.begin(); 56 myRadio.setChannel(115); 57 myRadio.setPALevel(RF24_PA_MAX); 58 myRadio.setDataRate( RF24_250KBPS ); 59 myRadio.openReadingPipe(1, addresses[0]); 60 myRadio.startListening(); 61 delay(100); 62 63 lcd.setCursor(0, 0); 64 lcd.print("Arduino Weather"); 65 lcd.setCursor(4, 1); 66 lcd.print("Station"); 67 delay(5000); 68 lcd.clear(); 69 lcd.setCursor(2, 0); 70 lcd.print("Developed By"); 71 lcd.setCursor(2, 1); 72 lcd.print(" Serafim"); 73 delay(3000); 74 lcd.clear(); 75 lcd.print(" Pornire...."); 76 delay(3000); 77 lcd.clear(); 78 } 79 80 81 82 void loop() 83 { 84 85 checkForWirelessData(); 86 87 lcd.setCursor(0,0); 88 lcd.print("Date:"); 89 lcd.setCursor(6, 0); 90 lcd.print(rtc.getDateStr()); 91 92 93 94 lcd.setCursor(0, 1); 95 lcd.print("Time:"); 96 lcd.setCursor(6, 1); 97 lcd.print(rtc.getTimeStr()); 98 delay(1000); 99 100 lcd.setCursor(6, 1); 101 lcd.print(rtc.getTimeStr()); 102 delay(1000); 103 104 lcd.setCursor(6, 1); 105 lcd.print(rtc.getTimeStr()); 106 delay(1000); 107 108 lcd.setCursor(6, 1); 109 lcd.print(rtc.getTimeStr()); 110 delay(1000); 111 112 lcd.setCursor(6, 1); 113 lcd.print(rtc.getTimeStr()); 114 delay(1000); 115 lcd.clear(); 116 117 dht.read(); 118 InTemp = dht.readTemperature(); 119 InHum = dht.readHumidity(); 120 Serial.print("temp"); 121 Serial.print(InTemp); 122 Serial.print("hum"); 123 Serial.print(InHum); 124 125 126 lcd.setCursor(0, 0); 127 lcd.print("InTemp:"); 128 lcd.setCursor(9, 0); 129 lcd.print(InTemp); 130 lcd.print("*C"); 131 132 lcd.setCursor(0, 1); 133 lcd.print("InHum:"); 134 lcd.setCursor(9, 1); 135 lcd.print(InHum); 136 lcd.print("%"); 137 138 delay(5000); 139 lcd.clear(); 140 141 142 143 lcd.setCursor(0, 0); 144 lcd.print("OutTemp:"); 145 lcd.setCursor(9, 0); 146 lcd.print(OutTemp); 147 lcd.print("*C"); 148 149 lcd.setCursor(0, 1); 150 lcd.print("OutHum:"); 151 lcd.setCursor(9, 1); 152 lcd.print(OutHum); 153 lcd.print("%"); 154 delay(5000); 155 lcd.clear(); 156 157 158 lcd.setCursor(2, 0); 159 lcd.print(" Presiune"); 160 lcd.setCursor(4, 1); 161 lcd.print(OutPress); 162 Serial.print(OutPress); 163 lcd.print(" hPa"); 164 delay(5000); 165 lcd.clear(); 166 167 168 lcd.setCursor(1, 0); 169 lcd.print(" Altitudine"); 170 lcd.setCursor(3, 1); 171 lcd.print(OutAlt, 1); 172 Serial.print(OutAlt, 1); 173 lcd.print(" metri"); 174 delay(5000); 175 lcd.clear(); 176 177 178 lcd.setCursor(0, 0); 179 lcd.print("Bmp Temperature"); 180 lcd.setCursor(5, 1); 181 lcd.print(bmptemp); 182 lcd.print("*C"); 183 delay(5000); 184 lcd.clear(); 185 186 } 187 188 189 190void checkForWirelessData() 191{ 192 if ( myRadio.available()) 193 { 194 while (myRadio.available()) 195 { 196 myRadio.read( &data, sizeof(data) ); 197 OutTemp = data.temperature; 198 OutHum = data.humidity; 199 OutPress = data.pressure; 200 OutAlt = data.altitude; 201 bmptemp = data.bmptemperature; 202 } 203 Serial.print(data.temperature); 204 Serial.print(data.humidity); 205 } 206} 207
Downloadable files
Outdoor Unity
This is the scheme for Outdoor Unity
Outdoor Unity

Indoor Unity
This is the scheme of the Indoor Unity
Indoor Unity

Outdoor Unity
This is the scheme for Outdoor Unity
Outdoor Unity

Indoor Unity
This is the scheme of the Indoor Unity
Indoor Unity

Comments
Only logged in users can leave comments