Introduction: Communication Between Raspberry Pi and Arduino Via Usb #firmata #python

hello, guys, in this Instructable will show how to make communication between raspberry pi & Arduino via USB for this we are using firmata protocol.

Firmata is a protocol for communicating with microcontrollers from software on a computer.

I believe this is the easiest way to control Arduino via USB.
I found this, method in this old magazine . & this method really works great.

In this method, you have to upload a sketch in Arduino only one time & you get full access on your raspberry pi.

basically raspberry pi act as Master & Arduino act as a slave.

Must watch this video for detail guidance-

like & subscribe for more such videos.

Step 1: Upload Sketch to Arduino

connect your Arduino your computer & upload StandardFirmata will found this sketch in

Examples / Firmata / StandardFirmata and Upload the sketch.

Step 2: Installing Firmata to Raspberry Pi

pyFirmata is the magic that allows your
Arduino running Firmata to talk to Python. run this commands in terminal to install required modules.

sudo apt-get install python-serial mercurial
pip install pyfirmata

to check is this install properly on not.
open python idle & run

  import pyfirmata

if you get any error then pyfirmata is not installed properly

try another method:

sudo apt-get install python-serial mercurial
git clone
cd pyfirmata
sudo python install

Step 3: Simple Blinking LED Code

now build the circuit.
connect led to pin D13 of Arduino

connect Arduino to raspberry pi via USB.

by entering this command in terminal you will get a list of all USB devices

ls /dev/tty*

in my case, ACM0 is my Arduino.

now create new python file in idle copy & past this sketch.

you will get properly formatted sketch here Blinking LED code

import pyfirmata
import time board = pyfirmata.Arduino('/dev/ttyACM0')
pin13 = board.get_pin('d:13:o') 
while True:


important links

Magpi magzin==
firmata ==


About This Instructable




More by Saurabh Gangamwar47:Make a Python Powered ChatBot #Raspberry PiWATER SUPPLY ALERT & MONITORING SYSTEM #Blynk Communication Between Raspberry Pi and Arduino Via Usb #firmata #python
Add instructable to: