In this project, I designed and implemented a complete embedded IoT system using STM32 and ESP32, with SPI communication and secure cloud connectivity.
System Architecture:
Sensors:
AM2302 → Temperature & Humidity
MQ-9 → Gas / CO (ppm)
MCU Internal Temperature Sensor (ADC channel)
Main Controller:
STM32F401RE (Nucleo board)
Bare-metal + FreeRTOS
Sensor tasks and data acquisition
Custom drivers (ADC, UART, SPI, AM2302)
Acts as SPI Master
Communication:
SPI bus (1 MHz, Mode 0)
Packed data structure
Pins: PB10 / PB14 / PB15
Gateway:
ESP32
SPI Slave (data reception + checksum verification)
JSON data formatting
WiFi (STA mode)
MQTT client using mbedTLS
Cloud:
AWS IoT Core (eu-north-1)
MQTT over TLS 1.2 (port 8883)
X.509 certificate-based authentication
Topic: stm32/sensors
Data Flow:
Sensors → STM32 (processing) → SPI → ESP32 → MQTT → AWS IoT Core
Technologies Used:
STM32 (HAL / Bare-metal)
FreeRTOS
ESP32 (ESP-IDF)
SPI Protocol
MQTT Protocol
TLS (mbedTLS)
AWS IoT Core
Source Code:
STM32 Project: https://github.com/hosseinb1994/ecohive
ESP32 Gateway: https://github.com/hosseinb1994/Echohive_E...
This project demonstrates:
Embedded system architecture design
Real-time task management
Inter-MCU communication (SPI)
Secure IoT communication (MQTT over TLS)
Cloud integration with AWS