Modular Robotics robot auto-detection and I2C mutex utilities
Project description
mr-rfr-tools
Common Python utilities shared across Modular Robotics platforms (GoPiGo3, BrickPi3, GrovePi, PivotPi).
Modules
auto_detect_robot
Detects which Modular Robotics board(s) are connected to the Raspberry Pi. Supports: GoPiGo3, GoPiGo, BrickPi3, BrickPi+, GrovePi, PivotPi.
import auto_detect_robot
robot = auto_detect_robot.autodetect()
print(robot) # e.g. "GoPiGo3"
auto_detect_rpi
Identifies the Raspberry Pi model by reading /proc/device-tree/model — no lookup
table required, works with all current and future Pi hardware.
import auto_detect_rpi
print(auto_detect_rpi.getRPIGenerationCode()) # e.g. "RPI4"
print(auto_detect_rpi.getRPIHardwareRevCode()) # e.g. "Raspberry Pi 4 Model B Rev 1.5"
Generation codes returned: RPI0, RPI0-2, RPI1, RPI2, RPI3, RPI3B+, RPI3A+,
RPI4, RPI5, RPI-COMPUTE-MODULE, RPI-COMPUTE-MODULE3, RPI-COMPUTE-MODULE4.
di_i2c
I2C abstraction layer supporting multiple bus backends:
| Bus name | Hardware |
|---|---|
"RPI_1" |
Raspberry Pi hardware I2C (/dev/i2c-1) via python-periphery |
"RPI_1SW" |
Redirected to RPI_1 (software I2C / wiringpi removed on Trixie) |
"GPG3_AD1" |
GoPiGo3 Grove port AD1 |
"GPG3_AD2" |
GoPiGo3 Grove port AD2 |
"BP3_1" … "BP3_4" |
BrickPi3 sensor ports 1–4 |
from di_i2c import DI_I2C
bus = DI_I2C(bus="RPI_1", address=0x29)
bus.write_reg_8(0x00, 0x01)
value = bus.read_16(0x01)
Multiple sensors on different ports share a single underlying controller instance
automatically — no risk of SPI bus conflicts from duplicate GoPiGo3() constructors.
di_mutex / I2C_mutex
File-based inter-process mutexes that prevent concurrent I2C bus access across multiple Python processes.
di_mutex.DI_Mutex is used internally by di_i2c. I2C_mutex.Mutex is a
compatible alternative used by some legacy tools.
Installation
On the robot (Raspberry Pi)
pip install mr_rfr-tools
Or install directly from the repository for development:
git clone https://github.com/DexterInd/RFR_Tools
cd RFR_Tools/miscellaneous
pip install -e .
Dependencies
| Package | Purpose |
|---|---|
python-periphery |
Hardware I2C on /dev/i2c-1 (Trixie / Debian 12+) |
pyserial |
Serial port scanning in auto_detect_robot |
I2C must be enabled on the Pi before using di_i2c with "RPI_1":
sudo raspi-config # Interface Options → I2C → Enable
# or add dtparam=i2c_arm=on to /boot/firmware/config.txt and reboot
Requirements
- Python 3.7+
- Raspberry Pi running Raspberry Pi OS (Trixie / Debian 12 recommended)
License
MIT — see LICENSE or https://choosealicense.com/licenses/mit/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mr_rfr_tools-2.0.2.tar.gz.
File metadata
- Download URL: mr_rfr_tools-2.0.2.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2593dc6abda2942ab8f1f45391855de7e31eb2a8db84352e82234f7a95b49241
|
|
| MD5 |
8c4b1a89443eae350b03180c0c71379d
|
|
| BLAKE2b-256 |
caa57504b47c437bd0f300bba9a8f19e2e3368e4ff42aaa3b21de0449cb957cd
|
File details
Details for the file mr_rfr_tools-2.0.2-py3-none-any.whl.
File metadata
- Download URL: mr_rfr_tools-2.0.2-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c1ca45ebdcbbb5c6b7c1707a32f448ce39d5ad3612d173254169150815e7fa7
|
|
| MD5 |
b88e8eb846e48611d4861c54e646d90e
|
|
| BLAKE2b-256 |
db0cbed45231a270b98029d34bc72a90292fd146ceb69444f47b5c9ef299a6d7
|