ESP32 based weather station with indoor/outdoor readings, DHT22, BME280, MH-Z19B CO2 sensors and big LCD!
This is a personal weather station based on ESP32 NodeMCU module (should work on ESP8266 too). Outdoor data are collected from DHT22 sensor. Indoor data are collected from BME280 and MH-Z19B sensors. Data is displayed on 2004 LCD module and sent over WiFi to home server where InfluxDB and Grafana are hosted.
Warning:
This project requires advanced knowledge and home server with InfuxDB, Grafana set up, most of the time running on Linux! If you are not familiar with such environments, you will have to change my code and remove any references to InfluxDB and sending/storing the data!
- ESP32 NodeMCU developement board
- BME280 temperature, humidity, atmospheric pressure sensor
- DHT22 temperature and humidity sensor
- MH-Z19B CO2 sensor
- 2004 LCD module with 20 chars * 4 rows
- I2C adapter for 2004 LCD module
- Junction box 145 x 190 x 70 @ IP65
- 2x RJ45 outlets (for connecting outdoor sensor to main indoor box)
- Cheap Dremel-like drill/saw with accessories to cut holes for LCD, sensors and ports;
- Punch tool for punching cables to RJ45 jacks;
- Soldering iron for soldering the cables. I don't trust breadboards;
- Heat shrink tubing and lighters to cover soldered wires;
- RJ45 crimp tool and 2x RJ45 Cat5e connectors to make cable for indoor->outdoor connection;
- Electrical tape for extra covering some contacts.
- Install ESP32 support for Arduino IDE. Version 1.0.3 works for me
- Install all required libraries.
- Edit ESP32-Weather-Station.ino and specify your credentials:
const char* ssid = ""; //WiFi SSID, ex. myRouter-WiFiName
const char* password = ""; //WiFi password, ex. mySecureRouterPassword123
const char* influxdb_host = ""; //InfluxDB server IP address, ex. 192.168.1.10
const int influxdb_port = ; //InfluxDB server port, ex. 8086
const char* influxdb_database = ""; //InfluxDB database name, ex. "arduino"
- If you use Basic HTTP authentication in your InfluxDB setup, change your code (add the Authorization line):
client.print(String("POST ") +
http + " HTTP/1.1\r\n" +
"User-Agent: ESP32/0.1\r\n" +
"Host: 192.168.1.10:8086\r\n" +
"Authorization: Basic username:password (must be base64 encoded)\r\n" +
"Accept: */*\r\n" +
"Content-Length: " + String(vaicajums.length()) + "\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Connection: close\r\n\r\n" + vaicajums + "\r\n");
- Choose ESP32 Dev Module in Arduino IDE, connect the module, choose proper COM port and upload the code!
- Adafruit BME280 Library Version 1.0.10 works for me
- Adafruit Sensor Version 1.0.3 works for me
- Arduino LiquidCrystal I2C Library Version 1.1.2 works for me
- MH-Z19 CO2 Sensor Library Version 1.4.3 works for me
- DHT ESP Library Version 1.0.13 works for me
- ESP Software Serial Version 5.0.4 or OLDER works for me