Getting Started with an aLaMode Board and a Raspberry Pi
You want to use an aLaMode board to interface external electronics with the Raspberry Pi.
The aLaMode board (see “Modules” on page 381) shown in Figure 14-18 is a wonderful board that is essentially an Arduino Uno with a Raspberry Pi GPIO socket in one corner. The aLaMode fits neatly onto the Raspberry Pi and allows you to use Arduino shields without the need for lots of extra wires.
Note that the board shown in Figure 14-18 is without the header sockets needed to attach Arduino shields.
The installation instructions in Recipe 14.1 will also set up aLaMode in your Arduino environment. From the Tools menu of the Arduino IDE, choose Board Type and then ALaMode (Figure 14-19).
You also need to set the serial port to /devttyS0 before programming the aLaMode, which takes place through the serial connection. This means that you will need to disable the console logging (Recipe 8.7).
Discussion
All the Firmata recipes in this chapter will work with the aLaMode, along with the custom serial communication example of Recipe 14.10. The only modification necessary is in the Python programs communicating with the aLaMode, as they must use the serial port rather than the USB port.
The aLaMode is hardwired to the Arduino’s Tx and Rx pins, in a configuration that is much the same as Recipe 14.5 but with built-in level conversion.
When using Firmata, you need to change the port from /dev/ttyACM0 to /dev/ttyAMA0:
board = pyfirmata.Arduino(‘/dev/ttyAMA0’) |
Similarly, if you are writing your own custom code, you will need to change the line that opens the serial connection so that it looks like this:
ser = serial.Serial(‘/dev/ttyAMA0’, 9600) |
To try the aLaMode, just load the Standard Firmata sketch onto the aLaMode and then run the Python program ardu_flash_ser.py (Recipe 14.5).
Some of the interesting features of the aLaMode board are:
• It can be powered from the 5V line of the Raspberry Pi GPIO connector or a separate 5V power adapter connected to its micro-USB socket.
• The RTC is connected directly to the Raspberry Pi rather than the Arduino side of the board.
• Arduino shields can be attached, with a high degree of compatibility (see Recipe 14.14).
• It can be an I2C slave. As well as being linked by serial, the aLaMode’s I2C connections are also connected to those of the Raspberry Pi (Recipe 14.11).
• It has a micro SD card reader.
• It has headers for direct connection to servo motors (Recipe 14.9).
The aLaMode does suffer from one minor design flaw—with the Arduino shield headers soldered in place, the analog inputs A0 to A5 can easily touch the bare metal of the RJ45 Ethernet socket of the Raspberry Pi. To avoid this, place a couple of layers of electrical insulating tape over the top surface of the Ethernet socket on the Raspberry Pi before attaching the aLaMode (Figure 14-20).
See Also
The official aLaMode instructions can be found at http://bit.ly/1d2YMxh.
Table A-8. Modules | |
Raspberry Pi camera module | Adafruit: 1367, MCM: 28-17733, CPC: SC13023 |
Arduino Uno | SparkFun: DEV-11021, Adafruit: 50, CPC: A000066 |
Level converter, four-way | SparkFun: BOB-11978, Adafruit: 757 |
Level converter eight-way | Adafruit: 395 |
LiPo boost converter/charger | SparkFun: PRT-11231 |
PowerSwitch tail | Adafruit: 268 |
16-channel servo controller | Adafruit: 815 |
Motor driver 1A dual | SparkFun: ROB-09457 |
RaspiRobot board | Sparkfun: KIT-11561, raspirobot.com |
PiFace digital interface board | MCM: 83-14472, CPC: SC12827 |
Humble Pi | MCM: 83-14637, CPC: SC12871 |
Pi Plate | Adafruit: 801 |
Gertboard | MCM: 83-14460, CPC: SC12828 |
Breakout board with paddle terminals | MCM: 83-14876, CPC: SC12885 |
PIR motion detector | Adafruit: 189 |
Venus GPS module | SparkFun: GPS-11058 |
Methane sensor | SparkFun: SEN-09404 |
Gas sensor breakout board | SparkFun: BOB-08891 |
ADXL335 triple-axis accelerometer | Adafruit: 163 |
4×7-segment LED with I2C backpack | Adafruit: 878 |
Bicolor LED square-pixel matrix with I2C backpack | Adafruit: 902 |
PiLite interface board | Ciseco, CPC: SC13018 |
aLaMode interface board | Makershed: MKWY1, Seeedstudio: ARD10251P |
Freetronics Arduino LCD shield | www.freetronics.com |
RTC module | Adafruit: 264 |
16 x 2 HD44780 compatible LCD module | SparkFun: LCD-00255, Adafruit: 181 |