Book Image

Python Programming for Arduino

Book Image

Python Programming for Arduino

Overview of this book

Table of Contents (18 chapters)
Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Bridging pySerial and Firmata


In the Firmata section, we already learned how useful it is to use the Firmata protocol instead of constantly modifying the Arduino sketch and uploading it for simple programs. pySerial is a simple library that provides a bridge between Arduino and Python via a serial port, but it lacks any support for the Firmata protocol. As mentioned earlier, the biggest benefit of Python can be described in one sentence, "There is a library for that." So, there exists a Python library called pyFirmata that is built on pySerial to support the Firmata protocol. There are a few other Python libraries that also support Firmata, but we will only be focusing on pyFirmata in this chapter. We will be extensively using this library for various upcoming projects as well:

  1. Let's start by installing pyFirmata just like any other Python package by using Setuptools:

    $ sudo pin install pyfirmata
    

    In the previous section, while testing pySerial, we uploaded the DigitalSerialRead sketch to...