Today’s the last day of my summer holiday, and I had some free time on my hands. So I decided to see if I could get my Arduino Uno and Raspberry Pi to talk to each other. It turned out the task was even easier than my previous Pi to RS-232 project – all that was needed between the two devices was some jumper wire and two 1 kOhm resistors to form a voltage divider between Arduino TX pin and Pi RX pin – Arduino understands Pi’s 3.3V signal levels just fine so Pi TX to Arduino RX needed no voltage shifting at all.
IMPORTANT UPDATE! It turns out that the RX pin on the Arduino is held at 5V even when that pin is not initialized. I suspect it is due to the fact that the Arduino is programmed via these same pins every time you flash it from Arduino IDE, and there are external (weak) pullups to keep the lines to 5V at other times. So the method described below may be risky – I suggest either add a resistor in series to the RX pin, or use a proper level converter (see this post for details how to accomplish that). And if you do try the method below, never connect the Pi to Arduino RX pin before you have already flashed the program to Arduino, otherwise you may end up with a damaged Pi!!!
Setting Raspberry Pi up for serial communications
In order to use the Pi’s serial port for anything else than as a console, you first need to disable getty (the program that displays login seen) by commenting the serial line out of Pi’s
1:2345:respawn:/sbin/getty 115200 tty1 # Line below commented out # 2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 3:23:respawn:/sbin/getty 115200 tty3 4:23:respawn:/sbin/getty 115200 tty4 5:23:respawn:/sbin/getty 115200 tty5 6:23:respawn:/sbin/getty 115200 tty6
If you don’t want the Pi sending stuff over the serial line when it boots, you can also remove the statements
/boot/cmdline.txt. You’ll need to reboot the Pi in order for the changes to take effect.
Continue reading Arduino and Raspberry Pi Serial Communication