I'm interested in IoT stuff, so far I've used Raspberry Pi mini computers and their GPIO. I'd like find out if microcontrollers can replace "heavy" Raspberry Pi with Linux for IoT sensors&controls use cases.
I ordered three microcontrollers: Rapsberry Pi Pico, NodeMCU ESP8266 board and M5Stack Atom lite box with ESP32. Will find which one fits HW&SW to the needs.
An ideal state would be to program it with golang, however not sure how capable are go-based environments. Possible choices are Gobot, TinyGo or MicroPython.
Gobot looks quite nice, but with less common firmware setup (Firmata protocol) and supports only ESP8266. TinyGo doesn't support WiFi on ESP controllers, so it is out. MicroPython supports everything, requires firmware update, but not complicated. However firmata looks as a promising technology, The MicroPython seems to be save and reasonable choice for (hopefully) smoothly working setup.
An example project is needed to verify HW&SW capabilities. Something related to self-driving vehicles looked to be ineteresting, so why not start with an Ultrasonic Radar distance measure with servo moving it to different directions (max.range few meters).
See Makefile.
I've missed that the ulrasonic measure unit (HY-SRF05) uses 5V voltage, so the M5Stack Atom with ESP32 seems to be only suitable controller with Wifi. ESP itself works with 3,3V, RPi Pico doesn't have embedded Wifi and reading the Radar output remotely is a nice-to-have feature.
Measure works on ping-pong scheme and reflection roundtrip time is measured, so the distance can be calculated. The ultrasonic unit has specified to have 15° receiving angle, howeer it seems to be more in practical usage.
Threads are needed (and luckily are supported on the ESP chips) for handling measures capture and providing it via e.g. network socket. For time reasons I deffered providing measures nearly real-time via Wifi, but it is a first improvement I'd do next.
I learned that (at least) ESP-based microcontrollers are nice and it is easy to start working with it. It is reasonable use "bundled" boards which make easier integration with peripherals (different voltage, less accessible pins, but can supply more power) and such boards can replace full Raspberry Pi in some of my home automation use cases.
The MicroPython is well supported, simple and quite smoothly working. I'm looking forward to see golang microcontrollers tooling more mature.
Check today's work result in action at https://youtu.be/TSi9DF0nxwA
https://docs.micropython.org/en/latest/esp32/quickref.html
https://micropython.org/download/esp32/ esp32-idf4-20210202-v1.14.bin