This project uses STM32L4 to control the process of performing indoor measurements (temperature, humidity and pressure) and obtaining various weather data through WiFi module and the API.
This project is designed as a battery-powered system. It utilizes the RTC module to periodically wake up the STM32 from low-power mode, allowing it to perform measurements and obtain weather data via the ESP8266 (which also makes use of its low-power mode) using the OpenWeatherMap API.
The retrieved data is displayed on a 1.3″ OLED screen. A user button allows switching between different displayed information.
The project is mainly motivated by educational purposes, but with future potential improvements it can become practical and useful device.
- STM32Cube
- Visual Studio Code
- Logic (Saleae)
Libraries, frameworks, APIs:
- STM32CubeHAL
- Arduino for ESP8266 (PlatformIO)
- OpenWeatherMap API
- STM32L476RG (Nucleo-L476RG)
- ESP8266 (NodeMCU-V3, ESP-01S)
- Logic Analyzer
- DHT22 (temperature/humidity sensor)
- LPS25HB (pressure sensor)
- 1.3″ OLED display (SH1106 driver)
- Wires, Resistors, Capacitors
During the prototype phase, development boards are powered via USB ports. Therefore, all components and MCUs are powered through the onboard voltage regulators.
| STM32L4 | ESP8266 | Notes |
|---|---|---|
| PA10 | GPIO2 | ESP8266 UART TX1, Add 10kΩ pull-up resistor |
| PB8 | GPIO3 | Request to ESP8266, Add 100kΩ pull-up resistor |
| PC7 | RST | Reset ESP8266 |
| GND | GND | Common Ground |
| STM32L4 | DHT22 | Notes |
|---|---|---|
| PA6 | DATA | Data signal, Add 5kΩ pull-up resistor |
| - | VDD | Connect to 3V3 power supply, Add 100nF capacitor between VDD and GND |
| GND | GND | Common Ground |
| STM32L4 | LPS25HB | Notes |
|---|---|---|
| PC3 | SDA/SDI/SDO | SPI MOSI |
| PB10 | SCL/SPC | SPI Clock |
| PC2 | SDO/SA0 | SPI MISO |
| PB11 | CS | SPI Chip Select |
| GND | GND | Common Ground |
| STM32L4 | Display (SH1106 driver) | Notes |
|---|---|---|
| PC3 | SDA | I2C SDA |
| PB10 | SCK | I2C SCK |
| - | VCC | Connect to 5V power supply |
| GND | GND | Common Ground |
- Flash the ESP8266 firmware:
- The STM32 communicates with the ESP8266, which requires a separate firmware.
- Follow the instructions in the ESP8266 repository to flash the appropriate code.
- Clone this repository using Git command:
git clone https://github.com/Romwierz/weather-station.git
- Alternatively, download the ZIP and extract it.
- Open STM32CubeIDE and open the project:
- Go to File → Open Projects from File System → Directory...
- Select the project folder and Finish.
- Open the
.iocfile and generate the code using the Device Configuration Tool Code from the toolbar. - Build and run the project.
✅ Core Features Implemented:
- Indoor measurements (temperature, humidity, pressure)
- Weather data retrieval via ESP8266
- OLED display
- Periodic system wake up from sleep to perform tasks
🚀 Potential Upgrades:
- Optimize energy consumption:
- Use RTC alarms to wake up the ESP8266 before the STM32, ensuring WiFi data is ready without delay
- Display weather forecasts
- Implement motion detection for brightness control
- Create a web interface for WiFi location settings