Arduino to Raspberry Pi with USB Serial Connection

Quick Guide to Connecting your Raspberry Pi to Arduino via USB Cable

There are several ways you can have serial transmission between your Raspberry Pi and your Arduino board – this is one of the laziest.  Quick background – I have a buggy I want to control from the Pi using the Arduino board for sensors and relays.  The Pi fitted with this cheap wireless adapter works perfectly.

Step 1: Shut off all Serial Action going on with the Pi.

You have to edit two places.  The first ‘/boot/cmdline.txt’ – delete

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

Then bounce over to /etc/inittab and we have to comment out the last line by adding the # to the beginning.
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Step 2: Reboot with your Arduino plugged in and make sure you have the proper power.

Step 3: Download a serial terminal like minicom or cu. I like cu.

sudo apt-get install cu

Step 4: Figure out where your Arduino can be accessed. (Also make sure that you have already uploaded a script that is waiting for a serial connection.) Most likely as a Raspberry Pi user it will be ‘/dev/ttyACM0’ but to be sure I did a quick ‘ls -l /etc/serial/by-path’ and got the following answer:
lrwxrwxrwx 1 root root 13 Dec 31  1969 platform-bcm2708_usb-usb-0:1.2:1.0 -> ../../ttyACM0

Step 5: Enjoy the magic of sending bits over the wire. Connect with your serial terminal client – in my case:
cu -l /dev/ttyACM0 -s 9600

and you should see a connected message.

Step 6: Figure out what you are going to do with this new serial knowledge.

Testing Power Wheels Motor Control with Arduino and Relays


Comments

  1. Hallison Fonseca -

    thank you… great post!

    Reply

Leave a Reply to Thomas Cancel reply