So after destroying one Pi, I still managed to salvage the evening. What I wanted to do was read from the UART Serial pins on the Raspberry Pi directly on the Arduino without any magic. Just RX/TX to TX/RX. But in order to avoid frying another Pi I used an Adafruit Bi-directional Logic Level Converter (TXB0108). Adafruit also sells another one (BSS128) for $4, but I have not tested it. The Pi speaks serial at 3.3v and the Arduino likes to chat at 5v. The Raspberry Pi GPIO pins are sensitive to the extra voltage.
The Raspberry Pi automatically spits out data over the serial pins by default. For later use, I will want to comment that out so I can use that serial session for sending command data and receiving sensor data from the Arduino. But for now, I just want to get it working and see some BBS looking scrolling going across my terminal.
Step One, if you are using the default Raspbian distro, you need to slow down the baud rate. The Arduino using the Software Serial class cannot keep up and you will just get gibberish.
The easiest fix is to turn on your Pi and ssh into it and make two changes. First in the /boot/cmdline.txt file, change the two instances of 115200 to 9600. (Sure it might work a little higher but I was too lazy to test at multiple speeds). Then, edit /etc/inittab file. Cruise to what should be the last line, and change the 115200 to 9600.
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100 Becomes: T0:23:respawn:/sbin/getty -L ttyAMA0 9600 vt100
Now you can shutoff your Pi.
Lets prep the Arduino now – you can use this simple sketch to echo all received serial data to the Arduino serial console. Once you upload the sketch to your Arduino, you can unplug that and start hooking the two up.
First on your Pi, Pin 8 is the Tx and Pin 10 is the Rx . You will also need to connect the ground Pin 6 to your voltage stepper board. The overall goal is your Tx -> RX and the Rx -> Tx . So on the other side of your stepper (the 5v side) connect the pins you defined in the sketch above across from the opposite transmission type coming out of the Pi. The ground should also be attached to the Pi ground and the 5v should go to the appropriate location on your stepper board.
Now you are ready to fire it up. Start the Arduino first and open the serial monitor, under tools. If you are set to the right baud rate, 9600, you should see the “Ready to receive Data” message. Now turn on your Raspberry Pi and watch the magic. You should see all of the loading processes and eventually you can log in to your Pi directly through your Arduino.
If you still see gibberish log into your Raspberry Pi via SSH and check that everything is set correctly by typing ‘sudo stty –F /dev/ttyAMA0 –a’. You should see 9600 as the baud rate. If you see something else you can set it by typing ‘sudo stty –F /dev/ttyAMA0 9600’.