Skip to main content

firmatazero

Project description

firmatazero Code style: black

The simplest Python interface for controlling pins on Arduino by using Firmata protocol.

This project aims to bring GPIO Zero's excellent Python interface from Raspberry Pi's to Arduinos, while making only minor adjustments that make sense in due to different hardware. This means that in some cases existing gpiozero code can work on Arduino by simply changing imports and pin numbers.

Firmatazero automatically detects Arduino's port and on default expects Arduino Uno, and is thread safe.

Blink example:

from firmatazero import LED
from time import sleep

led = LED(13) # 13 == LED_BUILTIN

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)

Servo example:

from firmatazero import Servo
from time import sleep

servo = Servo(9)
while True:
    servo.min()
    sleep(1)
    servo.mid()
    sleep(1)
    servo.max()
    sleep(1)

Needless to say, this project is heavily inspired by GPIO Zero. This means that the project structure and docstrings are very related, even if the underlying code is different.

This project is build with pyFirmata2 and pySerial libraries.

Currently has very limited amount of devices. Used in botafar.com for making shareable, realtime global remote controls possible for robotics projects.

Installation

Python side:

pip install firmatazero --upgrade

Arduino side: on Arduino IDE select File > Examples > Firmata > StandardFirmata.

Then select your board and port from Tools > Board and Tools > Port. Then press Upload.

Supported devices

You can use GPIO Zero's docs, if you take changes intpo account:

LED

Same as GPIO Zero's LED, except:

  • pin parameter has a default value of 13, the buildin LED
  • blink() function and active_high parameter not implemented
  • pin_factory does not have an effect

Servo

Same as GPIO Zero's Servo, except:

  • pin parameter has a default value of 9, the pin used in Knob and Sweep examples
  • min_pulse_width and max_pulse_width have default values from Arduino Servo.h library, this means that most hobby servos move 180 degrees out of the box
  • detach() function not implemented, so Servo.value = None is not allowed
  • pin_factory does not have an effect

New functions

  • detect_port() detects and returns the first Arduino port it finds, or raises RuntimeError
  • set_port(port) allows skipping port autodetection, for example: set_port("COM1")
  • set_board(board) allows setting another pyFirmata2 board or settings compared to the default one, for example: set_board(pyFirmata2.ArduinoMega("COM4"))
  • get_board get pyFirmata2 board shared with all devices, to run some custom code with

Contributing

Contributions are very welcome. Anything that makes this project to support more GPIO Zero's Devices are very welcome.

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

firmatazero-0.0.2.tar.gz (88.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firmatazero-0.0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file firmatazero-0.0.2.tar.gz.

File metadata

  • Download URL: firmatazero-0.0.2.tar.gz
  • Upload date:
  • Size: 88.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for firmatazero-0.0.2.tar.gz
Algorithm Hash digest
SHA256 319a66a4442a0c46d68526722c2aa120bdcf9601edc43c800c882c897efd479c
MD5 14b43aa005ef14e6d9b2d8aebce25ea3
BLAKE2b-256 fe27c33573c53e195562186c8ea3e3cdef213d12426adb7ec283d21c4b60cbec

See more details on using hashes here.

File details

Details for the file firmatazero-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: firmatazero-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for firmatazero-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ffebefddacc9a71c761e88f66b65161a9036c85e1fbd08c87dfc9f085e086a00
MD5 6dd31f4ed6f7a830740c6c3dd7007980
BLAKE2b-256 89a043ff2109075e86a7f4d2a51501e871e881993a80b479e8bc55b8218f7193

See more details on using hashes here.

Supported by

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