Warning
DISCLAIMER — USE AT YOUR OWN RISK
This software is provided "as is" under the Apache-2.0 license, without warranty of any kind. It is experimental and has not been certified for use in safety-critical applications.
The author(s) shall not be held liable for any damage — including but not limited to loss of beehives, property damage, fire, or personal injury — arising from the use or misuse of this software.
You are solely responsible for validating the correct operation of your installation. A hardware-independent thermal cutoff device (e.g. a mechanical thermostat rated at ~45 °C wired in series with the heater relay) is strongly recommended as an additional safety layer independent of this software.
Bee Sauna is a Zephyr RTOS application that performs thermal treatment of beehives to eliminate Varroa destructor mites. It reads temperature and humidity from an SHT35 sensor over I2C and runs two independent PID control loops:
- Heater relay — maintains hive temperature at 42 °C (the lethal threshold for varroa while safe for bees).
- Humidifier relay — maintains hive humidity at 65 % RH to prevent desiccation of brood during treatment.
The PID outputs drive two relays in on/off mode (bang-bang modulated by PID to smooth thermal cycles).
- Controller board: ESP32-WROOM 2-channel relay board (AliExpress, DC 5-60 V
variant) —
esp32_relay_2chcustom Zephyr board. - Sensor: Sensirion SHT35 breakout on I2C bus (address
0x44).
| Function | GPIO | Notes |
|---|---|---|
| Relay 1 | GPIO 16 | Active high |
| Relay 2 | GPIO 17 | Active high |
| Status LED | GPIO 23 | Active high |
| I2C SDA | GPIO 21 | Expansion |
| I2C SCL | GPIO 22 | Expansion |
| UART TX | GPIO 1 | Console |
| UART RX | GPIO 3 | Console |
The SHT35 sensor is not part of the board definition. It is added via a
devicetree overlay in the application (boards/esp32_relay_2ch_procpu.overlay).
In this project, Relay 1 drives the heater and Relay 2 drives the humidifier.
cd zephyr-workspace/workspace
poetry shell
west build -b esp32_relay_2ch/esp32/procpu applications/bee-sauna
west flashSerial console at 115200 baud will show sensor readings and relay state each second.
Hard-coded setpoints and PID tuning parameters are defined at the top of
src/main.c:
TEMP_SETPOINT_C— target temperature (default 42.0 °C)HUMIDITY_SETPOINT_RH— target humidity (default 65.0 %RH)TEMP_KP,TEMP_KI,TEMP_KD— temperature PID gainsHUM_KP,HUM_KI,HUM_KD— humidity PID gainsRELAY_THRESHOLD— PID output threshold for relay activation (default 0.5)
The firmware implements several software safety mechanisms:
- Over-temperature hard cutoff — if the measured temperature reaches
TEMP_HARD_CUTOFF_C(default 45 °C), the heater relay is immediately turned off and locked out until the temperature drops belowTEMP_RESUME_C(default 40 °C). Uses hysteresis to prevent relay chattering. - Over-humidity hard cutoff — same logic for humidity at
HUMIDITY_HARD_CUTOFF(default 90 %RH) /HUMIDITY_RESUME(80 %RH). - Sensor failure protection — after
SENSOR_FAIL_MAX(default 5) consecutive sensor read failures, all relays are shut down until the sensor recovers. - All safety events are logged at
LOG_ERRlevel for diagnostic traceability.
Important
These are software-only safeguards. Software can fail. Always install a hardware thermal cutoff (mechanical thermostat or thermal fuse) in series with the heater relay as an independent safety layer.
- Bluetooth Low Energy interface for runtime configuration of setpoints and PID parameters.
- Persistent storage of settings via NVS.
- Hardware watchdog integration with automatic relay shutdown on firmware hang.