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.
Metadata
Release files for robotframework-i2c 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| robotframework_i2c-1.0.0.tar.gz | 9.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| robotframework_i2c-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / robotframework_i2c-1.0.0.tar.gz
| Download URL | robotframework_i2c-1.0.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49e08c0db266ed56e47a54e3d820424e03ef22ecfb56165c4a25eb86e154eab1
|
|
BLAKE2b-256 checksum How to use checksums |
e0f65077356e04e48ba5e064b9d2ff58468e17deccd3798a741320cb888138f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / robotframework_i2c-1.0.0-py3-none-any.whl
| Download URL | robotframework_i2c-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
112e92e942543320f0df23e695dc81c6270629e29eae45948cf8d0490026f78a
|
|
BLAKE2b-256 checksum How to use checksums |
37596a80670303c24d764b8e1e0260078ce050d4a10214123bbe9b492b119cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|