Robot Framework Library for interfacing I2C devices on Raspberry Pi and other embedded systems
Project description
Robot Framework I2C Library
Robot Framework library for interfacing I2C devices on Raspberry Pi and other embedded systems.
Installation
pip install robotframework-i2c
Requirements
- Robot Framework (>=3.2.2)
- smbus2 (>=0.4.0)
- I2C enabled on the system
Quick Start
*** Settings ***
Library robotframework_i2c.I2CLibrary.I2CLibrary
*** Test Cases ***
Test I2C Communication
Open I2C Bus 1
${devices}= Scan I2C Bus
Log Found devices: ${devices}
Close I2C Bus
Keywords
Bus Management
Open I2C Bus- Opens an I2C bus for communicationClose I2C Bus- Closes the currently open I2C busScan I2C Bus- Scans the I2C bus for connected devices
Device Communication
Read I2C Register- Reads data from a device registerWrite I2C Register- Writes data to a device registerRead I2C Block- Reads a block of data from a deviceWrite I2C Block- Writes a block of data to a deviceI2C Device Present- Checks if a device is present at an address
Utility
Set I2C Delay- Sets a delay between I2C operations
Examples
Basic Device Communication
*** Settings ***
Library robotframework_i2c.I2CLibrary.I2CLibrary
*** Test Cases ***
Read Temperature Sensor
Open I2C Bus 1
${present}= I2C Device Present 0x48
Should Be True ${present}
${temp_raw}= Read I2C Register 0x48 0x00
Log Raw temperature: ${temp_raw}
Close I2C Bus
Block Data Operations
*** Settings ***
Library robotframework_i2c.I2CLibrary.I2CLibrary
*** Test Cases ***
Read Configuration Block
Open I2C Bus 1
${config_data}= Read I2C Block 0x48 0x10 4
Log Configuration: ${config_data}
${new_config}= Create List 0x01 0x02 0x03 0x04
Write I2C Block 0x48 0x10 ${new_config}
Close I2C Bus
Device Discovery
*** Settings ***
Library robotframework_i2c.I2CLibrary.I2CLibrary
*** Test Cases ***
Discover I2C Devices
Open I2C Bus 1
${devices}= Scan I2C Bus
Log Found ${devices.__len__()} devices
FOR ${device} IN @{devices}
Log Device found at: ${device}
END
Close I2C Bus
Supported Platforms
- Raspberry Pi (all models)
- Other Linux-based embedded systems with I2C support
- Any system with
/dev/i2c-*device files
Hardware Setup
Before using this library, ensure I2C is enabled on your system:
Raspberry Pi
- Enable I2C via
raspi-configor adddtparam=i2c_arm=onto/boot/config.txt - Reboot the system
- Verify I2C is working:
ls /dev/i2c-*
General Linux
- Load I2C kernel modules:
modprobe i2c-dev - Ensure your user has access to I2C devices (usually in
i2cgroup)
Error Handling
The library provides detailed error messages for common issues:
- Bus not open: Ensure you call
Open I2C Busbefore other operations - Device not found: Check wiring and device address
- Permission denied: Ensure proper user permissions for I2C devices
- smbus2 not available: Install with
pip install smbus2
License
MIT License. See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please use the GitHub issue tracker.
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 robotframework_i2c-1.0.0.tar.gz.
File metadata
- Download URL: robotframework_i2c-1.0.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49e08c0db266ed56e47a54e3d820424e03ef22ecfb56165c4a25eb86e154eab1
|
|
| MD5 |
6bfe16e01018c59c6ec28abf1cb91563
|
|
| BLAKE2b-256 |
e0f65077356e04e48ba5e064b9d2ff58468e17deccd3798a741320cb888138f6
|
File details
Details for the file robotframework_i2c-1.0.0-py3-none-any.whl.
File metadata
- Download URL: robotframework_i2c-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
112e92e942543320f0df23e695dc81c6270629e29eae45948cf8d0490026f78a
|
|
| MD5 |
0f62a07f27b5d5e3794d120427497e32
|
|
| BLAKE2b-256 |
37596a80670303c24d764b8e1e0260078ce050d4a10214123bbe9b492b119cbc
|