Arduino and Python

Talking to Arduino over a serial interface is pretty trivial in Python. On Unix-like systems you can read and write to the serial device as if it were a file, but there is also a wrapper library called pySerial that works well across all operating systems.

After installing pySerial, reading data from Arduino is straightforward:

>>> import serial
>>> ser = serial.Serial('/dev/tty.usbserial', 9600)
>>> while 1:
...     ser.readline()
'1 Hello world!\r\n'
'2 Hello world!\r\n'
'3 Hello world!\r\n'

Writing data to Arduino is easy too:

>>> import serial # if you have not already done so
>>> ser = serial.Serial('/dev/tty.usbserial', 9600)
>>> ser.write('5')

Note that you will need to connect to the same device that you connect to from within the Arduino development environment. I created a symlink between the longer-winded device name and /dev/tty.usbserial to cut down on keystrokes.


Python Arduino Prototyping API

Arduino Prototyping API library used to quickly prototype an Arduino based application in Python.


Python Firmata

A Python API for the Firmata protocol. It's based on the Processing Library for Arduino and supports firmata v2.0


Py2B

Implements a simple 2 ASCII Chars protocol.
To start playing with Python and Arduino go to Py2B


arduino_serial.py is a library and command line that allows you to communicate with an Arduino board without installing any additional Python modules.

Turn your arduino into an IRC bot with python.

Control Arduino using HTML forms via Python.

Arduino-Python 4-Axis Servo Control: with a good general explanation of how to coordinate Arduino and Python code.

Here is an arduino serial utility for BSDish systems that is written in python.

Control Arduino using this Python-SimpleMessageSystem library.


Realtime graphing of data over serial

Graphing realtime data from an Arduino using Python and Matplotlib: http://www.blendedtechnologies.com/realtime-plot-of-arduino-serial-data-using-python