Joining Raspberry Pi and Arduino applications with SIMPL
Internet of Things
We touched on another important feature of a SIMPL application in the first article in this series: the ability to move modules to different network nodes, including the Linode cloud. This application provides another possible dimension of relocation, because the Arduino sketch is already running on a separate node.
Figure 5 shows what it might look like if the tclSurrogate daemon on the Linode were used to connect a Rasp Pi application (eightLeds.py
) to an Arduino sketch.
Because the Arduino sketch is inherently an embedded application, it would have to be reconfigured to tell it to connect to the Linode at icanprogram.ca by commenting out line 20 in Listing 1 and commenting line 21, as in:
// char *serverName = "10.0.1.32"; // Rasp Pi host where tclSurrogate lives char *serverName = 'www.icanprogram.ca";
Because the eightLeds.py
module accepts a command-line parameter, it is simply a matter of rerunning it as:
python eightLeds.py icanprogram.ca
We cannot overemphasize how powerful this ability is. Neither the Arduino sketch nor the Python GUI code needed any substantial change to make this happen. Such is the power of the SIMPL toolkit.
Conclusion
In this article, we showed how the SIMPL toolkit can be used to glue a Raspberry Pi to an Arduino and make it appear as a single SIMPL application. We discussed and illustrated another SIMPL surrogate: tclSurrogate. As with all SIMPL surrogates, the tclSurrogate fully encapsulates the networking and messaging details associated with connecting an Arduino to the Raspberry Pi. Once again, the SIMPL developer can focus energy on the business logic of the application at hand.
We also touched on a powerful feature of the modular SIMPL design: the ability to swap out modules for test stubs. This feature greatly enhances the ability to design, develop, and debug a complex application.
Finally we illustrated once again how easy it is to reconfigure SIMPL modules and spread them out into the cloud.
Infos
- "SIMPL Is as SIMPL Does" by Bob Findlay, Raspberry Pi GEEK, Issue 4, 2014: http://www.raspberry-pi-geek.com/Archive/2014/04/SIMPL-is-as-SIMPL-does
- tclSurrogate protocol: http://www.icanprogram.com/simpl/tclSurrogate.html
- SIMPL-Python self-installing archive for Rasp Pi: http://www.icanprogram.com/simpl/pythonraspibin.self.html
- SIMPL-Arduino self-installing archive: http://www.icanprogram.com/simpl/arduino.self.html
Buy this article as PDF
(incl. VAT)