Skip to main content

Use your Arduino as a data acquisition card under Python

Project description

PyFirmata2 turns your Arduino into a data acquisition card controlled by Python.

Up to 1kHz precise sampling at the analogue ports for digital filtering.

Just upload the default firmata sketch into your Arduino and you are all set.

pyFirmata2 is an updated version of pyFirmata which replaces loops with callbacks. Instead of unreliable “sleep” commands in a loop the Python application registers callbacks which are then called every time after new data has arrived. This means for the analogue channels the callbacks are called at the specified sampling rate while the digital ports call the callback functions after a state change at the port (from 0 to 1 or 1 to 0).

This API has been used in my Digital Signal Processing (DSP) class to practise realtime filtering of analogue sensor data. Examples can be viewed on the YouTube channel of the class: https://www.youtube.com/user/DSPcourse

Installation

Upload firmata

Install the Arduino IDE on your computer: https://www.arduino.cc/en/Main/Software

Start the IDE and upload the standard firmata sketch into your Arduino with:

File -> Examples -> Firmata -> Standard Firmata

Install pyfirmata2

The preferred way to install is with pip / pip3. Under Linux:

pip3 install pyfirmata2 [--user] [--upgrade]

and under Windows/Mac type:

pip install pyfirmata2 [--user] [--upgrade]

You can also install from source with:

git clone https://github.com/berndporr/pyFirmata2
cd pyFirmata2

Under Linux type:

python3 setup.py install

Under Windows / Mac:

python setup.py install

Usage

Please go to https://github.com/berndporr/pyFirmata2 for the documentation and in particular the example code.

Example code

It’s strongly recommended to check out the example code at https://github.com/berndporr/pyFirmata2/tree/master/examples to see how the callbacks work.

Credits

The original pyFirmata was written by Tino de Bruijn. The realtime sampling / callback has been added by Bernd Porr.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyFirmata2-2.5.0.tar.gz (87.9 kB view details)

Uploaded Source

Built Distribution

pyFirmata2-2.5.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file pyFirmata2-2.5.0.tar.gz.

File metadata

  • Download URL: pyFirmata2-2.5.0.tar.gz
  • Upload date:
  • Size: 87.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pyFirmata2-2.5.0.tar.gz
Algorithm Hash digest
SHA256 91148e4cdb0643f4f2f37f3c03b83d81e1d49bf4f01f0d094a8247304364a1f1
MD5 d296cb05936997eab93d778aee8b3cc1
BLAKE2b-256 d1df8a333cb04354b5bb2ffde29561d7d3632346fbc670daa018e7d85f6d2be6

See more details on using hashes here.

File details

Details for the file pyFirmata2-2.5.0-py3-none-any.whl.

File metadata

  • Download URL: pyFirmata2-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pyFirmata2-2.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01d6774cd83aab2a416af41f1cedf27338861512e4d53059a41ccccf2d4780ce
MD5 d0bba4e4a41e946043bf7fca4c407652
BLAKE2b-256 eb17eadd6347ceb147aced4466eac14a7185d780ed8ec7427625063e9743f7ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page