This repository contains the firmware for a simple weather station built on an STM32F407 Discovery Board. The project reads ambient temperature and humidity from a DHT11 sensor and displays the collected data on a 16x2 LCD module.
The core strength of this project is the Bare-Metal implementation. All peripheral control logic (drivers) was developed directly at the register level in C. I did not use the Hardware Abstraction Layer (HAL) or any external third-party libraries; the project relies solely on the standard C library and the stm32f407xx.h header file.
This approach demonstrates a deep understanding of the STM32 architecture and memory-mapped peripherals.
-
Custom-Developed Drivers for:
- RCC: Configuration of the system clock, and enabling peripheral clocks.
- GPIO: Pin configuration (Mode, Speed, Pull-up/down) for all components.
- Basic Timer: Used for precise timing control required by the DHT11 protocol.
-
I²C (PCF8574): Implementation of the full
$\text{I}^2\text{C}$ protocol (Start, Stop, ACK, NACK) for communication. - LCD (HD44780U): Low-level driver for sending commands and data to the display.
- DHT11: Implementation of the single-wire protocol, including bit timing and data decoding.
- EXTI: Configuration for button press detection.
The weather station consists of the following hardware components:
| Component | Function | Connection Pin |
|---|---|---|
| Microcontroller | STM32F407VGT6 | - |
| DHT11 Sensor | Measures temperature ( |
PA0 |
| PCF8574 Expander |
|
PB6 (SCL), PB7 (SDA) |
| 16x2 LCD | Displays the current environmental readings. | Via PCF8574 |
| Push Button | Used for requesting new data from the DHT11 (Triggers measurement via EXTI) | PA3 |
This project utilizes the GCC ARM Toolchain for compilation and an auto-generated Makefile (from STM32CubeIDE) to automate the entire bare-metal build process. This separation ensures the logic is fully decoupled from the build system.
To successfully build and flash the firmware, ensure you have the following tools installed and configured:
- GCC ARM Toolchain (
arm-none-eabi-gcc) - GNU Make
- OpenOCD or an equivalent utility for the ST-Link programmer
- Clone the Repository:
git clone https://github.com/Wkesther2/Weather-Station-Bare-Metal.git cd weather-station-bare-metal - Compile the Project:
The
make allcommand compiles all source files using the custom toolchain and links them into the final executable binary.make all
- Flash the MCU:
This command uses the configured programmer to transfer the compiled firmware to the STM32F407's flash memory.
make flash
Upon a successful power-on or reset:
- The custom LCD driver initializes the display and displays the first reading of the DHT11.
- The station waits for the user input.
- Pressing the Push Button (PA3) triggers an External Interrupt (EXTI), which then calls the custom DHT11 driver to read the latest temperature and humidity values.
- The display updates immediately with the new data.
The project code is organized into modular directories to maintain clarity and driver isolation:
Inc/: Contains the main header file (main.h).Src/: Contains the main application logic (main.c) and system initialization files.Drivers/Inc: All header files (.c) for the custom-developed hardware drivers (e.g.,gpio.h,i2c.h,dht11.h).Drivers/Src: All source files (.c) for the custom-developed hardware drivers (e.g.,gpio.c,i2c.c,dht11.c).
The pictured prototype of the weather station was intentionally built using jumper wires instead of permanent soldering.
This project serves primarily as a learning platform. Due to the specific hardware used—namely the overpowered STM32F407G-DISC1 board and the inaccurate DHT11 sensor for the intended application—this weather station will not be deployed permanently. The components remain unsoldered to allow for quick and flexible reuse in future embedded projects.
The reset button is not connected to the STM32 board in this photo. This is because I could not establish a stable connection using jumper wires on the button itself. However, the corresponding functionality (e.g., resetting sensor values) has been fully implemented and tested and works perfectly once a stable connection is established.
- Gabriel Zuser – https://www.linkedin.com/in/gabriel-zuser-381a95291/
- License: This project is licensed under the MIT License.


