ESP32 + Microdot + uPy-uasyncio
基于ESP32和micropython制作的家用温湿度计原型机。可通过网页控制GPIO和OLED显示,为HA等其他服务提供访问环境传感器的实时数据API。使用uasyncio的协程实现非抢占式的异步多任务控制,估测效果应该不如基于C的RTOS,但胜在代码量小,写起来简单吧。
This ESP32 and micropython-uasyncio based indoor ambient sensors are basically working as expected, with web-controlled OLED display, and a quite simple http api for other services like home assistant to query the realtime data. The multitasking runs on non-preempt Python coroutine, which is theoretically incompetent against those C + RTOS stuff, but it wins on simplicity from my point of view, so far at least.
Hardware components:
- NodeMCU (ESP32-WROOM-32E)
- 1.3 inch OLED (SH1106, SPI/I2C, 128×64)
- BME280 sensor (ambient temperature, relative humidity, barometric pressure)
Software libs:
- Micropython 1.19.1 (for ESP32)
- Microdot (minimalistic Python web framework which supports uasyncio)
- Driver libs of all hardware components.
HTTP API test works well.
And… another version below also provides wired ethernet support (with an extra LAN8720 module), it looks not that tidy though.
基于micropython的实验基本上就到此为止了,等节假日找机会试试C和RTOS?暂且挖个坑吧。
文章的脚注信息由WordPress的wp-posturl插件自动生成