The STM32L152RE Sensor Station is an embedded system project that integrates multiple environmental sensors to collect, process, and visualize various environmental parameters. Built around the STM32L152RE microcontroller, it provides a platform for real-time environmental monitoring.
- LMT84LP: Temperature sensor
- DHT22: Temperature and humidity sensor
- NSL19M51: Light intensity sensor
- SGP30: Air quality sensor (VOC and CO₂)
- MODBUS protocol for sensor communication
- I2C interface for digital sensors
- UART interface for data transmission
- Python-based master application for data collection and visualization
The MODBUS implementation features:
- Fixed 8-byte frame size
- Efficient ring buffer for UART reception
- CRC16 verification for data integrity
- Frame validation and error handling
- Support for both raw and processed sensor data
- Customizable addressing scheme for each slave
The Python-based master application provides:
- Modular sensor handling with dedicated classes for each sensor type
- Dynamic MODBUS frame construction and CRC calculation
- Real-time data processing and conversion
- Web-based visualization using Flask
- Responsive dashboard with real-time updates
- Sensor management interface
STM32L152RE-SensorStation/
├── src/
│ ├── Peripherals/ # Hardware interface drivers
│ ├── Sensors/ # Sensor-specific implementations
│ ├── Master/ # Python web application
│ └── main.c # Main firmware entry point
├── Drivers/ # STM32 HAL and CMSIS
└── README.md # This file
- STM32L152RE Nucleo Board
- Supported Sensors:
- LMT84LP Temperature Sensor
- DHT22 Temperature/Humidity Sensor
- NSL19M51 Light Sensor
- SGP30 Air Quality Sensor
- Connection cables and breadboard
- STM32 HAL Drivers
- CMSIS
- Flask (for web interface)
- Pyserial
- Clone the repository
- Open the project in STM32CubeIDE
- Build and flash to the STM32L152RE board
- Navigate to the Master directory:
cd src/Master - Install Python dependencies:
pip install -r pyserial flask
- Run the application:
python app.py
- Access the web interface at
http://localhost:5000
| Sensor | Pin | Interface |
|---|---|---|
| LMT84LP | PA0 | ADC |
| NSL19M51 | PA1 | ADC |
| DHT22 | PA7 | Digital |
| SGP30 | PB8/9 | I2C |
- Power up the system
- Access the web interface
- Add sensors through the management interface
- Monitor real-time data on the dashboard


