Wirelessly connecting Arduino and Raspberry Pi

Lead Image © Maxim Maksutov , 123RF.com

Dynamic Duo

The Raspberry Pi Wireless Inventors Kit (RasWIK) opens a whole new world of creative possibilities. This article gives you an overview of RasWIK and helps you to get started with this nifty bundle.

Raspberry Pi and Arduino make an ideal combination for all kinds of creative projects – with one significant drawback. To program and interact with Arduino, you have to connect it to the Raspberry Pi via a USB port. This puts limits on what you can do with the combo. RasWIK [1] provides a neat solution to the problem.

Besides an assortment of electronic components, the bundle includes an Arduino-compatible XinoRF board and a Slice of Radio RF transceiver for Raspberry Pi. This combination basically gives you an Arduino board that can communicate with an RF-enabled Raspberry Pi. RasWIK has been designed with beginners in mind, so the package also includes an SD card with a customized version of the Raspbian Linux distribution. The distro comes with the WIK graphical tool for working with the XinoRF board, as well as sample projects and scripts to get you started (also see the "Mix Your Own RasWIK" box).

Mix Your Own RasWIK

If you are only interested in the XinoRF board and the Slice of Radio module, you don't have to splurge on the entire RasWIK bundle; both components are available for purchase separately [2] [3]. All the accompanying software bits, including the WIK tool and example files, are released under an open source license, and they can be downloaded from the company's website [4]. The same goes for the customized version of the Raspbian distribution, which is available for download as well [5]. Even if you purchased a RasWIK bundle, it's worth keeping an eye on both download sites for possible updates.

Setting Up RasWIK

Setting up RasWIK requires no particular skills, and it can be done in a matter of minutes. Snap the Slice of Radio module onto the GPIO port of your Raspberry Pi and boot the computer from the supplied SD card. Use the default pi username and raspberry password to log in, then run the startx command to start the graphical desktop environment. Next, power the XinoRF board. To do this, you can either use the supplied mini-USB cable, or you can plug a standard 9V battery into a power port on the board. If you choose the former, you can use a spare USB port on Raspberry Pi to power the board or opt for a cheap USB battery adapter.

On Raspberry Pi, open the WIK_FILES folder, double-click on the RunMe.py Python script, and press the Execute button when prompted. In the WIK Launcher window, select Basics and press the Launch button to open RasWIK's basic interface (Figure 1). Press Connect to establish a connection between Raspberry Pi and XinoRF, then switch to the Basics section (Figure 2), where you can control and communicate with the XinoRF board through the graphical interface.

Figure 1: The WIK graphical tool makes it easy to establish a connection between Raspberry Pi and XinoRF.
Figure 2: The Basics section of the WIK tool.

First Steps

The classic blinking LED project is a perfect starting point for mastering RasWIK's basics, and the kit provides everything you need for this simple setup. Use the supplied breadboard to connect an LED (you can pick any color you like) and a 470-ohm resistor to the GND and 11 pins on XinoRF (Figure 3).

Figure 3: Simple LED wiring diagram.

In the Basics section of WIK, press the HIGH button next to the D11 entry, which should turn on the LED. Press the LOW button to turn it off. Several pins on the XinoRF board (e.g., 6 and 11) support analog output (PWM). Among other things, this setup allows you to dim the LED in addition to turning it on and off. Because you already have an LED connected to pin D11, you can adjust its brightness by entering a value between 0 (darkest) and 255 (brightest) and pressing the PWM button next to the D11 entry in the Basics section.

If you want to use XinoRF with a servo motor, you'll be pleased to learn that the basic interface can control servos, too. Connect the motor to pin 9 as shown in Figure 4, and you can use the slider next to the D09 entry to control the servo.

Figure 4: Connecting a servo motor to XinoRF.

The WIK application can also be used for more advanced projects. The Advanced Analog section, for example, allows you to read the temperature from the thermistor connected to the XinoRF board. Normally, reading and calculating temperature requires some calculating trickery, but the WIK tool does all the heavy lifting for you. For this project, you need to connect a 10K resistor and a thermistor to the XinoRF board as shown in Figure 5.

Figure 5: Thermistor wiring diagram.

In the Advanced Analog section of the WIK application, press the Read button, and you should see the actual temperature reading in the Temperature field (Figure 6). The application is configured to read temperatures between 0 and 40 degrees Celsius – as values outside this range require more complex calculation and calibration.

Figure 6: Reading temperature using the WIK tool.

Using the WIK tool, you can read not only the temperature, but you can also generate a graph based on the obtained values. To do this, quit the basic interface and choose Graphs from the WIK launcher interface. In the Introduction tab, press Connect to establish a connection between Raspberry Pi and XinoRF. Switch to the Temperature section and press Go. The application then reads the value on XinoRF pin A0 every second for 20 seconds and generates a graph. By adjusting the Delay and Repeat parameters, you can specify the desired interval between readings and the number of times the reading is obtained.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

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