An IoT firmware project for ESP8266/ESP32 microcontrollers that provides remote monitoring and control of ventilation systems with integrated environmental sensing.
- π‘οΈ Environmental Monitoring - Temperature, humidity, and pressure sensing via BME280
- π Relay Control - Remote ON/OFF control of ventilation equipment
- π‘ WiFi Connectivity - Dual-mode operation (AP and Station)
- π HTTP REST API - Simple web interface for control and monitoring
- π MQTT Integration - Automatic publishing of sensor data to MQTT broker
- π OTA Updates - Over-the-air firmware updates
- πΎ Persistent Configuration - SPIFFS-based settings storage
- ESP8266 (ESP-12E)
- ESP32
- BME280 Sensor - I2C environmental sensor (address 0x76)
- Relay Module - Connected to GPIO26 (ESP32) or D5 (ESP8266)
- Power Supply - Appropriate for your ESP board
- BME280 SDA β D2 (GPIO4)
- BME280 SCL β D1 (GPIO5)
- Relay Control β D5 (GPIO14)
- BME280 SDA β GPIO21
- BME280 SCL β GPIO22
- Relay Control β GPIO26
- PlatformIO (recommended) or Arduino IDE
- USB drivers for your ESP board
- Clone the repository:
git clone <repository-url>
cd VentilationController- Install dependencies (automatic with PlatformIO):
pio lib install- Build the project:
pio run- Upload to your board:
# For ESP8266
pio run -e esp8266dev -t upload
# For ESP32
pio run -e esp32dev -t upload-
Install required libraries via Library Manager:
- ArduinoJson
- Adafruit BME280 Library
- Adafruit Unified Sensor
-
Open
src/main.cppin Arduino IDE -
Select your board and port
-
Upload
On first boot, the device creates a WiFi access point:
- SSID:
VENTILATOR_AP - Password:
ud8ejr9304
Connect to this network and configure your WiFi credentials.
Send a POST request to configure WiFi:
curl -X POST http://192.168.4.1/configNetwork \
-H "Content-Type: application/json" \
-d '{"ssid":"YourWiFiSSID","networkSecret":"YourPassword"}'Or use GET parameters:
http://192.168.4.1/configNetwork?ssid=YourWiFiSSID&networkSecret=YourPassword
After configuration, the device will restart and connect to your network.
Configure MQTT broker connection to enable automatic sensor data publishing:
POST Request:
curl -X POST http://<device-ip>/configMQTT \
-H "Content-Type: application/json" \
-d '{
"broker":"mqtt.example.com",
"port":1883,
"user":"username",
"password":"password",
"clientId":"ventilator_01"
}'GET Request:
http://<device-ip>/configMQTT?broker=mqtt.example.com&port=1883&user=username&password=password&clientId=ventilator_01
MQTT Topics:
ventilator/sensor/temperature- Temperature readings (Β°C)ventilator/sensor/humidity- Humidity readings (%)ventilator/sensor/pressure- Pressure readings (hPa)ventilator/status- Device status (online/offline)
Data is published every 60 seconds automatically once MQTT is configured.
Once connected to your network, access the device via its IP address:
| Endpoint | Method | Description |
|---|---|---|
/on |
GET | Turn ventilator ON |
/off |
GET | Turn ventilator OFF |
/temperature |
GET | Get current temperature |
/humidity |
GET | Get current humidity |
/reset |
GET | Restart the device |
/configNetwork |
POST/GET | Update WiFi configuration |
/configMQTT |
POST/GET | Configure MQTT broker connection |
# Turn ventilator on
curl http://<device-ip>/on
# Get temperature
curl http://<device-ip>/temperature
# Get humidity
curl http://<device-ip>/humidity
# Turn ventilator off
curl http://<device-ip>/offThe device supports Over-The-Air updates via ArduinoOTA:
- Ensure the device is connected to your network
- Use PlatformIO or Arduino IDE OTA upload feature
- Select the device from the network ports list
# PlatformIO OTA upload
pio run -e esp8266dev -t upload --upload-port <device-ip>VentilationController/
βββ src/
β βββ main.cpp # Entry point
β βββ application/
β β βββ core.cpp # Main application logic
β β βββ core.hpp
β βββ config/
β β βββ config.cpp # Configuration management
β β βββ config.hpp
β βββ network/
β β βββ wlan.cpp # WiFi and HTTP server
β β βββ wlan.hpp
β β βββ HTTPRequest.cpp # HTTP request parser
β β βββ HTTPRequest.hpp
β βββ ota/
β β βββ ota.cpp # OTA update handler
β β βββ ota.hpp
β βββ webserver/
β βββ webserver.hpp # Web server interface
βββ platformio.ini # PlatformIO configuration
βββ README.md
# ESP8266
pio run -e esp8266dev
# ESP32
pio run -e esp32devpio device monitor -b 115200- Relay Pin: Modify
RELAY0_PINincore.cpp - BME280 Address: Change in
core.cppif using alternate address - AP Credentials: Update in
wlan.hpp - Server Port: Modify in
wlan.cpp
- Check I2C wiring (SDA/SCL)
- Verify sensor address (default 0x76, some use 0x77)
- Check power supply to sensor
- Verify credentials are correct
- Check signal strength
- Reset configuration via
/resetendpoint - Reflash firmware if needed
- Ensure device is on same network
- Check firewall settings
- Verify device IP address
- Try serial upload instead
- Use on trusted networks only
- Implement authentication before production use
- Consider HTTPS for sensitive deployments
- Change default AP password in code
[Specify your license here]
Contributions are welcome! Please feel free to submit pull requests or open issues.
- Built with PlatformIO
- Uses ArduinoJson
- Sensor support via Adafruit BME280 Library