March 6, 2020
There are many methods that can be used to provide communication with a host computer and an Arduino device. ArduinoCmdMessenger is a stable and relatively easy to use choice. It enables simple messages to be sent to the Arduino to control actions and return data.
Command Messenger itself can be installed via the Arduino Library Manager. The latest is version 4.0. It comes with examples in both C# and Visual Basic. My requirement is Python, so the PyCmdMessenger will be used. PyCmdMessenger can be installed via pip3.
Both the projects have not had many updates in the recent years, but I find in combination they address the needs of my projects.
I want to use Raspberry PI for IoT work. I want to use an Arduino to run some sensors that the PI will poll and publish.
True, the PI can handle most sensors and do the work for me. But in this particular case I have one of Adafruit’s CCS811 air quality sensors. The only way to get the sensor to work directly on the Raspberry PI is to slow the i2c bus speed down as described here -> https://learn.adafruit.com/adafruit-ccs811-air-quality-sensor/raspberry-pi-wiring-test .
I don’t really want to slow the i2c bus down on the PI as I have it busy with some other sensors. Plus — the implementation I have in mind is the CCS811 and a BME280 comprise an add on module for other projects. Using an Arduino Leonardo clone, the DF Robot Beetle, I can treat the implementation as a plug and play add on for other projects such as our up coming Raspberry Alarm Clock.
There are other options like Firmata. But I was not looking to couple the Arduino code so closely. I could roll my own implementation, but I’d rather use something that is already available. I just want to be able to reliably pass commands and data back and forth asyhronously. PyCmdMessenger provides a solution for this.
An example project can be found in the m2ag.labs examples repo. The code is documented and can be modified to use alternate sensors.