Raspberry Pi - Arduino Serial Communication


Introduction: Raspberry Pi - Arduino Serial Communication

About: A candle loses nothing of its light when lighting another

In this project, we will be making a communication between Arduino and Raspberry Pi which transfer vital information by sending data one bit at a time.

Serial communications are essential for every Micro-controllers to communicate between Micro-controllers and another device. The Micro-controller sends these 1 and 0 (bits) that contain necessary information one by one, or Serially. These bits form together and turn into bytes (composed of 8 bits). For further information, check it out sparkfun binary tutorials.

It’s a fairly easy project and can be used either on its own or part of something bigger (Check it Out >> Integrated Weather Station).

Step 1: List of Material

For this project, we will be using:

- Arduino boards (mine Arduino Uno Rev3)

- Raspberry Pi 2

- USB cable cost :~1.00 USD

Step 2: Hardware Connection

In common, the connections are fairly easy. Just connect Arduino USB Plug to Raspberry PI with USB cable and check the connection between Arduino and Raspberry pi by type "ls /dev/tty*" in Raspberry Pi terminal, the result should be content "/dev/ttyACM0" and you are good to go.

Step 3: Raspberry Pi Programming

Below is the Raspberry Pi Serial Communication code. Upload serial_test.ino code to your Arduino (Mine Arduino Uno Rev3) , Run serial_test.py Python code in Raspberry PI, Connect Arduino to Raspberry Pi through USB cable, and you should have no problems.

Step 4: Enjoy!

After making sure that everything works smoothly, you can take this project into bigger project (Check it Out >> Integrated Weather Station)!

Power through batteries or a plug and you’re good to go!

6 People Made This Project!


  • Oil Contest

    Oil Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Clocks Contest

    Clocks Contest

24 Discussions

picocom /dev/ttyUSB0 -b 9600 -r -l

I made it. thanks!

Sir I could send a digital value from the arduino to raspberry pi3.I have to send two sensor values from arduino to the raspberry pi3 but i'm not aware of the process so can you please help me.

i get it why you are having such result. the code goes like this. meaning there will be 2 outputs to be printed.

"print s[0]

print read_serial"


1 year ago

what if i wanna send data from pi to Arduino ; am trying control Stepper motor using arduino and in the other side there is pi with some image processing works , need to send angle / step to stepper to move on from pi to arduino

1 reply

Are you struggling with the sending of data from the Raspberry Pi or the receiving data on the Arduino?


1 year ago

made it but send data from pi3 to arduino to move motor , facing pb of keep serial 9600 connection open to be able to send data from pi3 .


I appreciate that you put this Instructable together, but I could suggest a few improvements:

1. A link to an example USB cable product would be helpful. Is it some kind of special cross-over cable?

2. I'm not sure what this means: 'the result should be content "/dev/ttyACM0" and you are good to go.'

3. Your explanation of serial communication is perhaps a bit over simplified. Do I need to send any initializing sequence or anything?

4. Some Arduino clones have a micro USB cable connector that they also use for power. Can you still use a USB-to-USB connection? How is the Arduino powered then?


1 reply

If you haven't found the answers or if someone else stumbles upon this:

1) No, any ol' USB cable will work

2) That means that if the Arduino is the first Serial connection the Pi OS "sees" that should be the name...if not you'll have to find what the filename of the connection is (everything in Linux is a file, even the keyboard and wifi card! If you know what to look for you can have some fun with this)

3) Serial is an extremely simple protocol, there is some magic that happens when doing Serial over USB but the FDI drivers will handle that. Once you get a hold of it in this method you can act just like you are reading and writing with user input. Reading up on Serial isn't a terrible idea for general knowledge, one hint that might save you some heartache: Serial uses 8 bits to represent characters, so it is NOT exactly ASCII or UTF-8. This can cause some annoying issues, it was my biggest pain point in my first Serial project.

4) The Vin pin and Gnd pin (I use the nearest to Vin, not sure if it matters) can be used to power any Arduino. Some also have other power inputs, but just know by connecting it directly you are taking responsibility for the quality of the power, it won't be converted or protected by the board. Make sure you use the right voltage (5V or 3.3V)!

Happy hacking!


1 year ago

What's the advantage of connecting an Arduino to a RPi if the RPi can read GPIO by itself? Can you please give me an example in which RPi alone won't work without an Arduino?

Thanks in advance,

2 replies

RPi has only one PWM output and GPIO pins are very sensitive (as far as
I know). If you need to control many servos and already own an Arduino,
it's better and cheaper to use it than buy some PWM module. Hope it

If you'd like to just see if it is working before messing with python (and the missing serial module) then you can just run this from to the linux (assuming Rasbian here but should work for others) command line to verify connectivity:

cat /dev/ttyACM0

This will print out what the Arduino device is sending to the console. Then you can go fight with Python.

6. When you connect the USB cable, the Arduino may not come up as device /dev/ttyACM0. Please provide a way to find which device has been assigned to your USB serial port.

5. It may also help to be clear that in this example you are sending fromt he Arduino and receiving with the RasPi. You may want to show how to go the other way, or even how to have two way communication.


1 year ago

Hi! very good tutorial .. but can i only use Data+ and Data- in the usb cable because im powering up my arduino through pololu shield ??

Hi, just one question, how do we make the Pi continuously check for whether an arduino has been connected or not and transfer data when it detects it?

I'm adding this solution for people who make the same mistake as I did.

In most cases: rename your project file 'serial.py' and delete serial.pyc if exists, then you can do simple 'import serial' without attribute error.

Problem occurs when you import 'something' when your python file name is 'something.py'.