

This project is a WiFi-enabled ESP32 weather station that displays indoor and outdoor temperature and humidity, as well as outdoor air quality (PM2.5 and PM10) and pressure. The ESP32 fetches outdoor data from a local air quality station near my location and displays it on an OLED screen. The device also supports OTA (Over-The-Air) updates, making it easy to deploy updates without requiring a physical connection.
Note: There is also version with Supla integration! Checkout supla branch here
3D printed enclosure: https://makerworld.com/en/models/838882#profileId-784647
- WiFi Connectivity: Connects to a WiFi network using credentials stored in a separate
config.h
file. - OTA (Over-The-Air) Updates: Allows for remote firmware updates via WiFi.
- Indoor Temperature and Humidity: Reads data from a DHT22 sensor.
- Outdoor Data: Fetches temperature, humidity, PM2.5, PM10 levels, and air pressure from a local air quality station.
- OLED Display: Displays data on a 128x64 OLED screen, alternating between indoor and outdoor data every 5 seconds.
- WiFi.h: For WiFi connectivity.
- HTTPClient.h: For making HTTP requests to fetch outdoor weather data.
- Arduino_JSON.h: For parsing JSON data from the API.
- Adafruit_SSD1306: For controlling the OLED screen.
- DHT.h: For interfacing with the DHT22 temperature and humidity sensor.
- ArduinoOTA: For enabling OTA updates.
- ESP32: Microcontroller with WiFi capabilities.
- DHT22 Sensor: Measures indoor temperature and humidity.
- 128x64 OLED Display: Displays weather data.
To use this project, you need to create a config.h
file in the project directory. This file should contain your WiFi SSID and password.
- Clone this repository.
- Install the required libraries (listed above).
- Create the
config.h
file with your WiFi credentials as described in the Configuration section. - Upload the code to your ESP32 using the Arduino IDE or VS Code with PlatformIO.
- View data on the OLED screen once the ESP32 connects to your WiFi network and retrieves weather data.
The ESP32 is set up for OTA updates. To update the firmware:
Arduino IDE:
- Connect the ESP32 to your WiFi network - WiFi network must be the same as your computer's network.
- In the Arduino IDE, select the ESP32's IP address from the Port menu.
- Upload new firmware directly over WiFi.
VS Code with PlatformIO:
- Connect the ESP32 to your WiFi network - WiFi network must be the same as your computer's network.
- Change the
upload_port
in theplatformio.ini
file to the ESP32's IP address (displayed on startup on the OLED screen). - Upload new firmware using the PlatformIO upload button with OTA environment selected.
During an OTA update, progress is displayed on the OLED screen, and normal operation resumes after the update completes.
- Setup: Initializes the WiFi, OLED display, DHT sensor, and OTA.
- Loop:
- OTA Handling: Checks for OTA updates.
- Weather Data Fetching: Calls
fetchWeatherData()
every 5 minutes to get updated outdoor data. - DHT Sensor Reading: Reads indoor temperature and humidity every 5 seconds.
- Display Toggle: Switches between indoor and outdoor data every 5 seconds.
The code fetches outdoor weather data from the API endpoint (thanks to "InPost Green City" ❤) https://greencity.pl/shipx-point-data/317/KRA357M/air_index_level
. Replace this URL in the code if needed.
Indoor:
Temp: 23.5°C
Humidity: 45%
Outdoor: GOOD
Temp: 22.8°C
Humidity: 50%
PM2.5: 10%
PM10: 20%
Pressure: 1013 hPa