Skip to main content

JoyIT_MotoPi

Python library for controlling the Joy-IT RB-Moto3 motor/servo expansion board on a Raspberry Pi. The board uses a PCA9685 16-channel, 12-bit PWM controller connected via I²C. The library provides access to the PWM channels, a shared frequency setting, raw PWM counter values and microsecond pulse generation.

This implementation communicates directly with the controller through smbus2 and uses gpiozero for the optional board-enable GPIO. It does not require Adafruit CircuitPython PCA9685. The included servo example uses adafruit-circuitpython-motor, which is a separate package.

Requirements

  • Raspberry Pi with Python 3.9 or later and the I²C interface enabled.
  • Joy-IT RB-Moto3 connected to the appropriate Raspberry Pi GPIO/I²C interface.
  • Python packages: smbus2, gpiozero and adafruit-circuitpython-motor (declared in pyproject.toml).
  • The Linux user must have access to the I²C device and the configured GPIO pin.

Enable I²C using sudo raspi-config (Interface Options → I2C), then reboot if prompted.

Installation

You can install this library from PyPI. To install it for the current user on your Raspberry Pi, use the following command:

pip install JoyIT-MotoPi

Install library into virtual environment:

python -m venv --system-site-packages env
source env/bin/activate
pip install JoyIT-MotoPi

API reference

API Description
MotoPi(...) Open the PWM controller and initialize its channels.
motopi.frequency Read or set the frequency shared by all 16 PWM outputs, in Hz.
motopi.channels[index] Get a channel (0 through 15); slices are also supported.
channel.duty_cycle Read/set a 16-bit duty-cycle value, from 0 (off) to 65535 (fully on).
channel.frequency Read-only shared frequency; cannot be changed per channel.
motopi.set_pwm(channel, on, off) Write raw PWM on/off counter values (0–4095; 0x1000 is a special full-on/full-off flag).
motopi.write_microseconds(channel, duration) Set the high pulse duration in µs at the current PWM frequency; 0 turns the channel off.
motopi.all_off() Turn off all outputs.
motopi.reset() Reinitialize the controller and clock selection; turns all channels off.
motopi.deinit() / motopi.close() Turn outputs off and release resources.

[!Note] Prefer the with MotoPi(...) as motopi: form: it calls deinit() when the block ends, including on exceptions. Without a context manager, call motopi.close() explicitly. When the library opens the I²C bus itself, it closes that bus; when you pass an existing bus object, it leaves ownership of that bus with the caller.

License and attribution

See LICENSE. Portions of the implementation are adapted from the Adafruit CircuitPython PCA9685 library; the corresponding copyright and MIT license notices are retained in the source files.

Metadata

Release files for JoyIT-MotoPi 1.0.1

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

Source distribution (sdist)

Source distribution for JoyIT-MotoPi 1.0.1
File Size Uploaded
joyit_motopi-1.0.1.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for JoyIT-MotoPi 1.0.1
File Interpreter ABI Platform
joyit_motopi-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / joyit_motopi-1.0.1.tar.gz

Download URL joyit_motopi-1.0.1.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7d9cbe13fe56de28e9ddaf9a3c81271bae7e4bed84deb8259ef27123196ccdbe
BLAKE2b-256 checksum
How to use checksums
7d89194ac8656a9b9690f67ed69fef1334e38b260d025cac0e136df8b6a3c103
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / joyit_motopi-1.0.1-py3-none-any.whl

Download URL joyit_motopi-1.0.1-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c9987c2bd54ca74511acf3f757ef7298a5aad19b790bd8a318cc3565d1005af
BLAKE2b-256 checksum
How to use checksums
3cd12388445251b4b18e69d9adf18a6f757e2add385db2ce5645093404934117
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

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