Wireless Weather Station
In this project we will see how to create dialogue 2 Arduino UNO board via a wireless network in a simple and economical with 2 nRF24L01 modules. These modules will communicate with each other the two Arduino boards via two-way radio frequency to 2.4 GHz. The first board will be electrically connected in the home, the second (external) will be powered by a battery charged via wireless. We display it on a LCD display the temperature and humidity outside.
Code for Arduino TX:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <DHT11.h>
int pin = A0;
DHT11 dht11(pin);
float temperature[2];
double Fahrenheit(double celsius) {
return ((double)(9 / 5) * celsius) + 32;
}
double Kelvin(double celsius) {
return celsius + 273.15;
}
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
radio.begin();
radio.openWritingPipe(pipe);
}
void loop(void)
{
float temp, humi;
dht11.read(humi, temp);
temperature[0] = temp;
temperature[1] = humi;
radio.write(temperature, sizeof(temperature));
delay(1000);
}
Code for Arduino RX
#include <Wire.h>
#include <DHT11.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity
float temperature[2];
RF24 radio(9, 10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.print(“Umid & temp”);
delay(1000);
lcd.clear();
lcd.print(“Start…..”);
delay(1000);
}
void loop(void)
{
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read(temperature, sizeof(temperature));
lcd.clear();
delay(500);
lcd.setCursor(0, 0);
lcd.print(“Temp”);
lcd.setCursor(0, 1);
lcd.print(“Umid”);
lcd.setCursor(9, 0);
lcd.print(temperature[0]);
lcd.print(” C”);
lcd.setCursor(9, 1);
lcd.print(temperature[1]);
lcd.print(” %”);
delay(5000);
}
}
}