Skip to main content

PyMata

PyMata is a high performance, multi-threaded, non-blocking Python client for the Firmata Protocol that supports the complete StandardFirmata protocol.

A new version for Python 3.5, pymata_aio, can be found here.

The API can be viewed on the wiki.

Major features

  • Implements the entire Firmata 2.4.1 protocol.
  • Python 2.7+ and Python 3.4+ compatibility through a shared code set. (If you are running Python 3.4 on Linux, please see note below).
  • Easy to use and intuitive API. You can view the PyMata API Documentation here or view in the Documentation/html directory.
  • Custom support for stepper motors, Sonar Ping Devices (HC-SR04), Piezo devices and Rotary Encoders.
    • Requires the use of FirmataPlus for PyMata - installation instructions may be found here.
  • Wiring diagrams are provided for all examples in the examples directory.
  • Digial and Analog Transient Signal Monitoring Via Data Latches:
    • They provide "one-shot" notification when either a digital or analog pin meets a user defined threshold.
    • Analog latches compare each data change to a user specified value.
      • Comparison operators are <, >, <= and >=
    • Digital latches compare a data change to either a high or low, specified by the user.
    • Latches can easily be re-armed to detect the next transient data change.
    • Latches can be either manually read or a callback can be associated with a latch for immediate notification.
  • Optional callbacks provide asynchronous notification of data updates.

Callbacks

Check out the example code on the wiki.

  • Digital input pins.
  • Analog input pins.
  • Encoder changes.
  • I2C read data changes.
  • SONAR (HC-SR04) distance changes.
  • Analog latch condition achieved.
  • Digital latch condition achieved.
  • Callbacks return data reports in a single list format.
  • Polling methods and callbacks are available simultaneously and can be used in a mixed polled/callback environment.
  • Callbacks return data in a single list.

The callback data return values

Callback Type List Element 0 List Element 1 List Element 2 List Element 3
Analog ANALOG MODE Pin Number Data Value Not Applicable
Digital DIGITAL MODE Pin Number Data Value Not Applicable
I2C I2C MODE I2C Device Address Data Value Not Applicable
Sonar Trigger Pin Distance in Centimeters Not Applicable Not Applicatble
Encoder Encoder MODE Pin Number Data Value Not Applicable
Latched Analog LATCHED ANALOG MODE Pin Number Data Value Time Stamp
Latched Digital LATCHED DIGITAL MODE Pin Number Data Value Time Stamp

Control-C Signal Handler

Below is a sample Control-C signal handler that can be added to a PyMata Application. It suppresses exceptions being reported as a result of the user entering a Control-C to abort the application.

import sys
import signal
# followed by another imports your application requires

# create a PyMata instance
# set the COM port string specifically for your platform
board = PyMata("/dev/ttyACM0")

# signal handler function called when Control-C occurs
def signal_handler(signal, frame):
    print('You pressed Ctrl+C!!!!')
    if board != None:
        board.reset()
    sys.exit(0)

# listen for SIGINT
signal.signal(signal.SIGINT, signal_handler)

# Your Application Continues Below This Point

Misc

Special Note For Linux Users Wishing to Use Python 3.5

pymata_aio is now available and for Python 3.5.

Check out the pymata_aio wiki!

This project was developed with Pycharm logo

Metadata

Release files for PyMata 2.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyMata 2.20
File Size Uploaded
PyMata-2.20.tar.gz 23.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyMata 2.20
File Interpreter ABI Platform
PyMata-2.20-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 57.7 kB

Release files / PyMata-2.20.tar.gz

Download URL PyMata-2.20.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3a8d16aba2c4eedde10d4f4d21932333f80d3e269a34824430f4f1291a0fb618
BLAKE2b-256 checksum
How to use checksums
de02174fceebefe3f74715f44e82a896b11f73ec782f0401eebd4baeb3c491cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.16

Release files / PyMata-2.20-py2.py3-none-any.whl

Download URL PyMata-2.20-py2.py3-none-any.whl
Size 34.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b6b38fecd18176919caf2366bf6b361a6215115baaad323c642d9ed5eeaad254
BLAKE2b-256 checksum
How to use checksums
8e2b3bf95129f96761afe201d8381dd2af636b4ed4a7e40520342634def2fa2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.16

Release history Release notifications | RSS feed

This release

2.20 This release

2 release files

2.18

3 release files

2.17

3 release files

2.16

2 release files

2.15

2 release files

2.14

1 release file

2.13

1 release file

2.12

1 release file

2.11

1 release file

2.10

1 release file

2.09

1 release file

2.08

1 release file

2.07

1 release file

2.06

1 release file

2.05

1 release file

2.04

1 release file

2.03

1 release file

2.02

1 release file

2.01

1 release file

1.58

1 release file

1.57

1 release file

1.56

1 release file

1.55

1 release file

1.54

1 release file

1.53

1 release file

1.52

1 release file

1.51

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page