Skip to content

ESP32 based weather station with indoor/outdor readings, DHT22, BME280, MH-Z19B CO2 sensors and big LCD!

License

Notifications You must be signed in to change notification settings

ArtursGailis1995/ESP32-Weather-Station

Repository files navigation

ESP32-Weather-Station

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!

Finished weather station

Parts used for this project

  • ESP32 NodeMCU developement board

ESP32

  • BME280 temperature, humidity, atmospheric pressure sensor

BME280

  • DHT22 temperature and humidity sensor

DHT22

  • MH-Z19B CO2 sensor

MH-Z19B

  • 2004 LCD module with 20 chars * 4 rows

2004 LCD

  • I2C adapter for 2004 LCD module

I2C adapter LCD

  • Junction box 145 x 190 x 70 @ IP65

Junction box

  • 2x RJ45 outlets (for connecting outdoor sensor to main indoor box)

Junction box

Tools used for this project

  • 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.

Setup procedure

  1. Install ESP32 support for Arduino IDE. Version 1.0.3 works for me
  2. Install all required libraries.
  3. 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"
  1. 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");
  1. Choose ESP32 Dev Module in Arduino IDE, connect the module, choose proper COM port and upload the code!

Libraries used for this project