Goal
Build an environment quality monitor.
Powered by FreeRTOS, and a low power IOT device
Global System Design
ESP32
- Low power, dual-core processor
- C/C++ & FreeRTOS support
- WiFi & BLE support
Sensors
- BM280: temperature, humidity & pressure
- SGP40: Volatile Organic Compounds (VOC)
- LTR390-UV-1: UV
- TSL25911: ambient light (infrared & visible)
- PMSA003I : particle concentration by size
Touch E-ink Display
- GT1151: Touch
- Multiple views of live data
- Low power consumption
- User interaction
Open Weather Map
- Exterior realtime data source
- Free API access
- +200'000 cities
Time-Series Database
- Influx DB, open source database system
- Time-Series optimized storage
- Lightweight HTTP client
Network Time Protocol
- Get time from the network
- Compute & display local time
- Keep it up-to-date using internal RTC
I2C
- 2 wires: clock & data
- Targets have unique address
- Bi-directional, half-duplex
- Simple protocol
I2C protocol
- Select target with R/W capability
- Select register
- Send/Read data
Technical specs
- 100kbps usually, up to multiple Mbps
- 120 target devices in 7 bit mode
- Some targets have 10 bit addresses
- Some targets have multi-byte register addresses
SPI
- +4 wires: clock, controller-data, target-data, chip-select
- Target have unique address/CS
- Bi-directional, full duplex
- More complex protocol
SPI protocol
- Multiple configurations (direct or chained, data lines)
- For the EPD, library is provided by constructor
Technical specs
- 1Mbps usually, ~2x the speed of I2C, up to hundreds of Mbps
- Possibility for multiple data lines to increase bandwidth further
- Target number limited by IO in direct configuration
- Target number limited by delay in chained configuration
HTTPS
- Manually imported certificates
- GET from OWM (JSON)
- POST to Telegram & DB (String)
- JSON handled with arduinojson library
ESP32 Configuration
Internal Timer
- Base clock runs at 80Mhz
- We set the scaler to run at 1Mhz
- We trigger IRQ every 1 second
Core Configuration
3 FreeRTOS core pinned tasks
- Sensor read, network get & post (Core 0)
- Touch screen IRQ polling & handling (Core 1)
- E-Ink Display refresh & drawing (Core 1)
Sleep Mode
- After inactivity the device goes into sleep mode
- Wakes up periodically to run measurements
- Returns to standard mode on touch IRQ [WIP]
Task Timing
- List of functions with their run frequency
- On minute tick check if any should have run since last tick
- Not affected by function execution time
Power Consumption
Device |
Default |
Sleep |
ESP32 |
20-200 mA |
10-800 uA |
EPD & Touch |
26 mA |
122 uA |
Sensors |
104.7 mA |
245.4 uA |
|
~330 mA (33mAh) |
~1.1 mA (1mAh) |
(default state for ~30s per 5min, sleep state remaining time: 34mAh in total)
Case Design
Case Design
Future Features
- Improve sleep (wake from touch)
- Improved "Environment quality" metric
- More views & layouts
- Support to automatically control IOT heating/cooling/ventilation
- Solar power by 4-5W cell (~400cm²)