The Raspberry Pi – Arduino Connection
The Pi is a fine little computer board, though not nearly as good as
the Arduino when it comes to I/O capabilities. The beautifully-engineered
Gertboard is a plug-in add-on that neatly overcomes this deficiency
by giving the Pi access to an ATMega328, but it’s a very complex and
expensive solution. An alternative would be to interface an Arduino
running at 3.3 volts to the Pi, though this is easier said than done.
But, we won’t let that stop us, will we?
of something similar to this project.
It’s called an AlaMode, and it goes for something like $50.
Our version will cost about a third of that to build.
As a first step, we will build an Arduino plug-in board for the Pi.
It is customary to call Pi boards “plates,” but indulge me and permit
me to name this particular board a hoody. Thank you.
We will be using generic stripboard to build our project. Small (3-3/4″
x 2-1/16″) boards can be obtained on eBay for a bit over a dollar apiece.
It is also possible to use something like a Radio Shack 276-168 protoboard
($3.49). The main component, though, is an 3.3-volt Arduino Pro Mini.
This will permit connecting directly to the Raspberry Pi ports and other
3.3-volt devices without having to do level shifting.
directly to the GPIO pins. This is not a good idea. Use buffer chips,
such as the 74HC4050 hex buffer, between the devices and the GPIO.
This protects the Pi from overvoltages, current surges, and your mistakes.
Far better to blow out a fifty-cent buffer chip than a $35 Pi.
This particular project connects directly to the GPIO Rx and Tx pins.
However, we are connecting to a 3.3 volt device, which limits the risk.
Still, a buffer chip would not be a bad thing here.
This is a moderately complex project, and beginners need not apply.
It requires skill at soldering and in the use of hand tools. Experience
with a continuity tester and a steady hand with a knife blade are also
Ready? Well, then, let’s get on with it!
Step 1: Parts needed
Nothing terribly exotic, folks, and fairly cheap to get, too.
- stripboard $1.25
- wire-wrap socket $1.50
- stacking header $2.00
- jumper cables $4.00 (for set of 40)
- female header strips $1.00
- Nokia display $6.00
- Arduino pro mini (or clone of same), 3.3 volt model $7.00
Total is under $25, if you don’t already have any of the components laying
- Soldering iron
- wire cutters (Plato 170 or similar)
- sharp knife (or optionally a Dremel-type rotary tool)
- continuity tester (preferred) or a multitester
will not fit into the holes. But, you can substitute two 14-pin strips offemale headers.
Some examples of such are the Boarduino and Ardweeny.
Be aware, however, that the ATMega328 chip is not rated to run at 16 MHz powered
at 3.3 volts. So, you would be running it out of spec, or essentiallyoverclocking it.
I’ve done some experimenting with this, and at least some, maybe most ATMega328s
can be programmed and run at 3.3 v. But, of course, your mileage may vary.
Step 2: Building the board : Installing the GPIO header
I used a stripboard to build the Raspberry Pi interface
board/hoody. Stripboard has the advantage of design flexibility —
it does not constrain the component layout to any particular configuration.
It’s also much cheaper than equivalent-sized solderable protoboards.
The chief disadvantage of stripboard is the necessity of extensive cutting
of copper traces on the solder side.
A rough diagram on a sheet of paper helps.
I mounted the 26-pin stacking (long-pin) GPIO header near one edge
of the board, with the female (plug-in) part of the header on the
copper-trace side. The trick is for the header not to mount flush
against the board, but to stand off about 1/4″ high in order to permit
soldering the pins to the copper traces. But, first we need to cut
thirteen rows of traces where the GPIO header will mount, so that adjacent
header pins will not be shorted to each other (see 2nd and 3rd illustrations).
Cutting the traces requires going back and forth with a sharp knife blade
with a fair amount of pressure (caution!), then follow-up checking with
a continuity tester. It’s a fair amount of work, and next time I try
something like this I’ll probably use a Dremel tool with cutting disk,
rather than a knife.
With the thirteen traces cut, carefully mount the GPIO header
approximately 1/4″ in elevation. This will give enough room to maneuver
the tip of the soldering iron between the pins to solder them. A couple
of dabs of poster-mounting putty hold the header in position prior to
soldering. Solder one end pin, then carefully straighten out the header
so it sits perpendicular to the board. Solder the remaining pins, then
use the continuity tester to look for shorts beween pins, both sideways
and across. A good continuity tester with audible indicator is especially
After soldering, the header pins will protrude 1/4″ or a bit more on the perfboard
(non-solder) side. This is convenient, as these will function as posts to attach
patch-cords and jumpers. Each post will be an electrical connection to the
corresponding GPIO pin underneath when the board is mounted on the Pi.
Step 3: Building the board : Installing the Arduino socket
The interface board needs a means of plugging in an Arduino, and
specifically a 3.3-volt mini Arduino Pro. This is where the 24-pin
wire-wrap socket comes in. For some reason, the Arduino Pro module neatly
plugs into a wire-wrap socket, but the pins are too fat for a regular
24-pin socket. Fortunately, wire-wrap sockets are widely-available and
not too expensive. I happened to have a couple laying around from a 2716
EPROM project I was working on several decades back.
Position the socket about an inch down from where the two rows of posts
stick up from the GPIO header on the perfboard side (see pics). Solder
the socket flush onto the board. After soldering, clip the protruding
pins flush on the copper-trace side of the board. Then, cut the rows
of copper traces between the two rows of soldered pins on the socket,
so that adjacent pins do not short together.
From the 40-pin female header strip, clip off two 12-pin strips.
On the perfboard side, position a 12-pin female header strip on each side
of the IC socket. This will provide plug-in points for jumper-wires to
access the Arduino pins. Secure the header strips so they are vertically
positioned relative to the board. Now, turn over the board and solder
There are no notches, as with male header strip, so the clipped-off
strips will usually come out a bit ragged, but this hardly matters. The
trick is to clip in the middle of a hole, and this will either leave
a metal prong hanging, or the prong will just fall out. It wastes one
hole of the strip each time you clip, but there is no avoiding this.
There is a piece of female header strip left over. Clip off an 8-pin
strip from it. You will have to get the second 40-pin strip in order to
be able to clip the second 8-pin strip because one pin always gets wasted
in the clipping process. These two strips will make up a socket for an
optional Nokia 5110 monochrome display for our project. The two rows will
short together on the solder side, so jumper wires can be electrically
connected to the pins of the Nokia display. Position the strips, then
turn over the board and solder them. Finally, cut rows of copper traces,
so that the Nokia socket is electrically isolated from everything else.
I installed two dual-row “utility” socket strips on the periphery of
the board. The installation and soldering procedure is the same as that
for the Nokia socket. The actual number of pins in these socket rows is
arbitrary, but they are useful for power and ground busses, among other
things. After soldering, cut appropriate rows of copper traces to isolate
these strips electrically from the rest of the board.
Step 4: Wiring it up: Part 1
Now that the interface hoody is built, where do we go from here?
We must still plug in the Arduino Pro and the Nokia display into the
sockets we’ve prepared. Then, we’ll run jumper wires and patch-cords —
from the Arduino to the display, and, in the following step, from the
Arduino to the GPIO posts.
to solder a row of male headers to the 8 solder holes for the power
and date lines. Take note of how the holes are labeled.
Nokia 5110 displays, unfortunately, do not have a standard pinout
configuration. They do all have the same complement of pins, but they
are not necessarily in the same position on the display board’s
connector. Even the labeling of the pins varies, though they still
have the standard functions.
- Arduino Nokia display pin name Nokia display pin number
- pin 7 – Serial clock out (SCLK) varies
- pin 6 – Serial data out (DIN) (see pin labels on display)
- pin 5 – Data/Command select (D/C)
- pin 4 – LCD chip select (CS)
- pin 3 – LCD reset (RST)
- Vcc –> Nokia Vcc (3.3 v.)
- Ground –> Nokia Ground
- Vcc –> Nokia backlight
If possible, use different colored jumper wires for each function,
say red for Vcc, black for ground, and appropriate colors for the
data lines. This will make it easier to trace the connections and to
double-check your work. Work slowly and meticulously, and be especially
careful not to make any errors with the Vcc and ground connections.
Note that in the illustration the two end pins in each strip of the Nokia socket
have wire jumpers. This is because I used 10-pin strips, and the Nokia display
uses only 8 pins. The jumpered holes are blocked from use.
We’re almost done with the hardware part of the project, so you can stop
and have a cup of coffee.
Step 5: Wiring it up: Part 2
Time to connect up the GPIO header posts with the Arduino pins.
We will use female-to-male jumper patch-cords.
There are only four, count ’em, four connections to make.
Here is where the two rows of female headers alongside the Arduino socket come
- Vcc (3.3v) on the Arduino connects to the GPIO Vcc (3.3v) pin: Pin #1.
- Ground on the Arduino connects to the GPIO Ground pin: Pin #6.
- TxD on the Arduino connects to the GPIO RxD pin: Pin #10.
- RxD on the Arduino connects to the GPIO TxD pin: Pin #8.
Note that TxD connects to RxD, and vice-versa. The reason for this is that
signal-out on one device goes to signal-in on the other. It’s a bit confusing
at first, but quite logical when you think about it.
To facilitate tracing and troubleshooting, use a red jumper for Vcc and a
black one for ground, and two other colors for TxD/RxD and RxD/TxD.
Check your work, and be especially careful with Vcc and ground. A mistake
here could be costly.
Whew! All done with the hardware! Now, on to the software.
For more detail: The Raspberry Pi – Arduino Connection
We recommend EasyEDA for electronic circuit design.
From Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test