
Self Watering POT
igokraj/STM32_Cpp_Self_Watering_Pot_Firmware-Hardware
Complete firmware and hardware solution for a self-watering pot, written in C++

IoT Air humidifier controller built around two microcontrollers: an STM32F446RE and an ESP32-S3
AirHumidifier hardware is an open-source printed circuit board by igokraj, from the igokraj/STM32_ESP32_IoT_AirHumidifier_firmware_hardware repository on GitHub, published under the MIT licence. It is a 2-layer board of 48 × 62 mm with 52 parts on 97 nets, routed with 314 tracks and 318 vias.
It is built around the ESP32-S3-WROOM-1-N8, 1812L150/24V and SMBJ15A. Its parts include 16 capacitors, 12 resistors, 6 connectors, 3 ICs and 3 diodes. It belongs with the home automation and IoT boards and the ESP32 and STM32 boards of this library.
Projekt zakładał stworzenie sterownika nawilżacza powietrza opartego na dwóch mikrokontrolerach STM32F446RE oraz ESP32-S3. STM32 odpowiada za sterowanie wentylatorem sygnałem PWM, obsługę czujników oraz maszynę stanów, na której opiera się działanie systemu. ESP32 służy wyłącznie do połączenia urządzenia z Wi-Fi, a następnie chmurą AWS IoT Core (Amazon) poprzez protokół MQTT.
Oba mikrokontrolery komunikują się ze sobą przez UART, wymieniając wiadomości w formacie JSON. STM32 wysyła do ESP32 informacje o aktualnej wilgotności, stanie systemu, prędkości obrotowej wentylatora oraz progu wilgotności ustawionym przez użytkownika. ESP32 przekazuje do STM32 wiadomość JSON przygotowaną wcześniej przez użytkownika, zawierającą żądany próg wilgotności w pomieszczeniu (np. 60%) oraz żądaną prędkość wentylatora, wybieraną poziomami od 0 do 5. Każdy poziom odpowiada innemu wypełnieniu sygnału PWM.
Firmware na STM32 jest napisany w C++, natomiast ESP32 działa na FreeRTOS, który jest natywną częścią frameworka.
Projekt był testowany na płytce stykowej, bez rzeczywistego wentylatora. Pomiar prędkości obrotowej sprawdzałem za pomocą drugiego timera, który generował impulsy i był fizycznie połączony z wejściem timera zliczającego impulsy z wentylatora. Sterowanie wentylatorem testowałem na servo ze zmienionymi parametrami sygnału PWM, ale logika sterowania pozostała taka sama.
This is an air humidifier controller built around two microcontrollers: an STM32F446RE and an ESP32-S3. The STM32 does the actual work. It drives the fan with PWM, reads the sensors and runs the state machine the whole system is based on. The ESP32 has only one job: it connects to Wi-Fi and talks to AWS IoT Core over MQTT.
The two chips talk to each other over UART using JSON messages. The STM32 sends the current humidity, system state, fan RPM and the humidity target set by the user. The ESP32 sends back a JSON message from the user with the target room humidity (e.g. 60%) and the fan speed level, from 0 to 5. Each level is a different PWM duty cycle.
The STM32 firmware is written in C++. The ESP32 runs on FreeRTOS, which comes built into ESP-IDF.
I tested everything on a breadboard without a real fan. To check the RPM measurement, I used a second timer to generate pulses and wired it to the input of the timer that counts the fan pulses. For fan control I used a servo instead, with different PWM settings, but the control logic stayed the same.
Breadboard prototype
Schematic
PCB layout and 3D render
The system has four states: Waiting, Running, EmptyContainer (no water in the tank) and Error.
In the main loop the STM32:
{"hum": 55, "rpm_lvl": 3}) and updates the target humidity and fan speed level,{"CurrentHumidity":48.20,"SetHum":70.00,"Status":1,"RPM":2000}.Fan speed has 6 levels (0 to 5, which means 0 to 100% PWM). The real RPM is measured from the fan's tachometer output using timer input capture. The watchdog (IWDG) resets the MCU if the program hangs.
The ESP32 passes messages between UART (115200 baud) and MQTT (TLS):
humidifier/<client_id>/datahumidifier/<client_id>/cmd (only valid JSON is sent on to the STM32)| Reference | Component | Qty |
|---|---|---|
| U2 | STM32F446RETx | 1 |
| U3 | ESP32-S3-WROOM-1 | 1 |
| U1 | AMS1117-3.3 (3.3 V regulator) | 1 |
| RGB1 | RGB LED | 1 |
| LED1 | LED (power indicator) | 1 |
| J1 | Power jack (barrel jack) | 1 |
| J2 | 4-pin PWM fan connector | 1 |
| J3 | Screw terminal (water level sensor) | 1 |
| J4 | ESP32 programming header | 1 |
| J5 | HTU21D connector | 1 |
| STLink1 | STM32 programmer connector | 1 |
| F1 | Fuse | 1 |
| D1 | Schottky diode B340 (reverse polarity protection) | 1 |
| D2 | TVS diode SMBJ15A (overvoltage protection) | 1 |
| L1 | Ferrite bead (power filtering) | 1 |
| R, C | Resistors and capacitors (filtering, pull-up/down) | ~28 |
The full list (with LCSC part numbers) is in AirHumidifier/hardware/BOM.xlsx and All_BOM.csv.
STM32: written in C++ on top of the C code generated by STM32CubeMX/HAL. The humidifier state logic, humidity sensor, UART, JSON parser and I2C bus recovery are separate classes/modules. The rest (GPIO, I2C, timers, UART, watchdog) is generated HAL code.
ESP32: written in C with ESP-IDF (FreeRTOS), split into WIFI, UART and MQTT modules. To build it you have to add your own main/secrets.h (Wi-Fi credentials, AWS endpoint and client ID) and AWS IoT certificates in main/Cert/. They are not included in the repo.
AirHumidifier/firmware/stm32/: CMake project with the STM32 sourcesAirHumidifier/firmware/esp32/: ESP-IDF project for the ESP32AirHumidifier/hardware/: KiCad schematic and PCB, production files (Gerbers), BOMAirHumidifier/hardware/Images/: schematic and PCB renders| Qty | Value | Footprint | References |
|---|---|---|---|
| 9 | 100nF | Capacitor_SMD:C_0805_2012Metric | C3, C4, C5, C6, C7, C10, C11, C12, C14 |
| 4 | 10k | Resistor_SMD:R_0805_2012Metric | R3, R5, R8, R9 |
| 4 | 330 | Resistor_SMD:R_0805_2012Metric | R2, R10, R11, R12 |
| 4 | MountingHole | MountingHole:MountingHole_2.2mm_M2 | H1, H2, H3, H4 |
| 3 | Conn_01x04_Pin | Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_Vertical | J2, J5, STLink1 |
| 3 | Fiducial | Fiducial:Fiducial_1mm_Mask2mm | FID1, FID2, FID3 |
| 2 | 10uF | Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A | C1, C2 |
| 2 | 4.7k | Resistor_SMD:R_0805_2012Metric | R6, R7 |
| 2 | Fiducial | Fiducial:Fiducial_0.5mm_Mask1mm | FID4, FID5 |
| 1 | 1812L150/24 | Fuse:Fuse_1812_4532Metric | F1 |
| 1 | 1k | Resistor_SMD:R_0805_2012Metric | R4 |
| 1 | 1uF | Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A | C9 |
| 1 | 1uF | Capacitor_SMD:C_0805_2012Metric | C15 |
| 1 | 2.2k | Resistor_SMD:R_0805_2012Metric | R1 |
| 1 | 22uF | Capacitor_SMD:C_0805_2012Metric | C13 |
| 1 | 4.7uF | Capacitor_Tantalum_SMD:CP_EIA-3216-18_Kemet-A | C8 |
| 1 | 4.7uF | Capacitor_SMD:C_0805_2012Metric | C16 |
| 1 | AMS1117-3.3_SOT223 | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U1 |
| 1 | B340_SMA | Diode_SMD:D_SMA | D1 |
| 1 | BEAD(FCM1608KF-601T03) | Inductor_SMD:L_0603_1608Metric | L1 |
| 1 | Barrel_Jack | Connector_BarrelJack:BarrelJack_Horizontal | J1 |
| 1 | Conn_02x03_Odd_Even | Connector_IDC:IDC-Header_2x03_P2.54mm_Vertical | J4 |
| 1 | ESP32-S3-WROOM-1 | RF_Module:ESP32-S3-WROOM-1 | U3 |
| 1 | LED | LED_THT:LED_D5.0mm | LED1 |
| 1 | LED_ARGB | LED_THT:LED_D5.0mm-4_RGB | RGB1 |
| 1 | SMBJ15A | Diode_SMD:D_SMB | D2 |
| 1 | STM32F446RETx | Package_QFP:LQFP-64_10x10mm_P0.5mm | U2 |
| 1 | Screw_Terminal_01x02 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_Horizontal | J3 |

igokraj/STM32_Cpp_Self_Watering_Pot_Firmware-Hardware
Complete firmware and hardware solution for a self-watering pot, written in C++



nuerolynx/embedded-systems-lab
Arduino UNO R4 WiFi and ESP32 prototypes for access control, automation, displays, monitoring, and Bluetooth audio.

ajisrawi/passive-radar-counter-drone
Passive radar for counter-drone using DVB-T, 4G and 5G: simulation, receiver hardware, FPGA micro-Doppler firmware, antennas, enclosure


misko/prompt2device
The separate vNext PCB skill and orchestrator package is available alongside the reference workflow below; existing projects keep their accepted toolchain until an explicit migration.

ConquerToFreedom/SwasthEdge
Low-cost self-diagnosing edge controller for industrial sensor reliability
It measures 48 × 62 mm and has 2 copper layers, 1.6 mm thick.
52 parts, built around the ESP32-S3-WROOM-1-N8, 1812L150/24V and SMBJ15A. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the igokraj/STM32_ESP32_IoT_AirHumidifier_firmware_hardware repository on GitHub, at the commit this page was made from: the board is hardware/AirHumidifier_hardware.kicad_pcb and its schematic hardware/AirHumidifier_hardware.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).