Agree… I’m trying my home automation phase-next with the $5 RPi zero instead of as usual, grinding out more C. As I said earlier, I was going to use micropython (Viper/ZERYNTH), on the existing STM32F4 port, but too many absent libraries.
First the Xbee 802.15.4 with the Python library for it… though I’ve written the equivalent professionally in C, I wanted to try Python. 56Kbps link to Xbee which links to other XBees in a star toplogy. End nodes w/Xbee have no added microprocessor… I use over the air config of XBee S1 very versatile A/D, D/A,PWM, GPIOs, pin change, sampling then sending batches of samples at my sample rate and batch size, etc. The Xbee receiving is a thread with callbacks from the library. That library uses callbacks from the serial port driver in Linux. No polling loops anywhere.
Example: Sprinkler controller with failsafe and Python + PyQt GUI and Apache web server on the RPi. SSL option. Rapid app.
Next I tried a shaft encoder (grey code). $3. Connected it to GPIO pins of the RPi Zero. Ran the Python GPIO library. It has callbacks for pin change notifications (threaded). The encoder I’m using has 24 steps in one rotation. Very quick Python program to track and time tag each rotation, which direction, up/down count on angular position, etc. Printouts show it keeps up fine with steps I could create by twisting the knob on the encoder… like 50mSec per step as I spun the dial.
Example: I’ve got the encoder connected to the axle of the sectional garage door. Goal is to use an audio-fader type of potentiometer to choose door position. RPi has an opto-isolator to the garage door control button. We leave the garage door ajar a foot or two so when the garage is too warm. It’s an attached garage w/2 cars in it, and washer/dryer. I suppose the automation can close the door if we forget, late night when no one is likely to be in harm’s way. Kind of fun too, I hope, to make door position an “analog” thing instead of mashing on/off/on with the door opener’s button.
This is with both the XBee code and the encoder code as two independent Python apps. And all the Linux stuff. These RPi have WiFi dongles plugged into the USB port, and an SMB share from my shared folder on the LAN for GB of storage. SD card on RPi is not used by my programs. So I use VNC to run the python programs. And the Python IDE (freeware) runs on my desktop and puts the file on shared folder on the LAN for the RPis to get to via WiFi.
There is DMA for all this but I don’t need it.
At some input sampling rate or some such I’d need DMA or off-load to a traditional MCU. Unlikely I’ll need sub-mSec events in this project.
So this is an exercise with some utility.