Joining Raspberry Pi and Arduino applications with SIMPL

Lead Image © Daniel Villeneuve, 123RF.com

Micro-Marriage

,

We show how to use the SIMPL messaging toolkit to facilitate communication between Pi programs and Arduino software modules.

In a previous article [1], we introduced the SIMPL toolkit – a messaging toolkit developers can use to facilitate communication between programs or software modules. The economy and simplicity of the network-transparent SIMPL toolkit makes it an ideal choice for the Raspberry Pi. In this article, we describe how to use the SIMPL toolkit to communicate between a Rasp Pi and an Arduino board.

The Arduino is a very capable and inexpensive single-board microcontroller. Arduino greatly extends the Raspberry Pi by adding and managing all sorts of I/O with little overhead. However, the Arduino lacks a sophisticated operating system, such as that sported by the Raspberry Pi. The Rasp Pi and Arduino therefore complement each other well, and sometimes it makes sense to put them both to work on the same project. The glue that can help join the Arduino to the Raspberry Pi is the SIMPL toolkit.

We will show a simple example showing how to use the SIMPL toolkit with Raspberry Pi and Arduino to illuminate eight LEDs. Once you get to know the SIMPL toolkit, you can easily adapt these techniques to address other challenges in your own Raspberry Pi environment.

Eight LED Example

The simplest configuration for a SIMPL application hosted by a Rasp Pi and Arduino is shown schematically in Figure 1.

Figure 1: Raspberry Pi and Arduino connectivity.

This communication will instruct the Arduino to illuminate any combination of eight LEDs, as shown in Figure 2.

Figure 2: Arduino Uno with Ethernet shield and an eight-LED PCB.

This example illustrates three elements of the SIMPL toolkit:

  • tclSurrogate [2] and accompanying protocol
  • Arduino receiver sketch connecting via the tclSurrogate protocol
  • Python-SIMPL module connection using the normal channel

We will discuss each of these in turn, but before we do, some code needs to be installed on the Rasp Pi and the Arduino development host.

Code Installation

Installation of the SIMPL toolkit with the Python extensions was covered in the previous article [1]. You will find a self-installing archive for the Raspberry Pi at the project online [3]. Some updates have occurred in the SIMPL-Python libraries since the previous article was written, so if you installed the SIMPL toolkit back then, we recommend upgrading to the latest version.

The SIMPL website also contains a link to the SIMPL-Arduino self-installing archive [4]. This archive contains two components. The first component is the implementation of the tclSurrogate protocol in the form of an Arduino library. You need to install this component on the Arduino development host to support SIMPL communication over TCP/IP.

The second component in the archive is a couple of examples. One of these examples is the eight-LED project described in this article.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content