Skip to main content

Robot Framework Library for interfacing I2C devices on Raspberry Pi and other embedded systems

Project description

Robot Framework I2C Library

PyPI version License: MIT

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 communication
  • Close I2C Bus - Closes the currently open I2C bus
  • Scan I2C Bus - Scans the I2C bus for connected devices

Device Communication

  • Read I2C Register - Reads data from a device register
  • Write I2C Register - Writes data to a device register
  • Read I2C Block - Reads a block of data from a device
  • Write I2C Block - Writes a block of data to a device
  • I2C 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

  1. Enable I2C via raspi-config or add dtparam=i2c_arm=on to /boot/config.txt
  2. Reboot the system
  3. Verify I2C is working: ls /dev/i2c-*

General Linux

  1. Load I2C kernel modules: modprobe i2c-dev
  2. Ensure your user has access to I2C devices (usually in i2c group)

Error Handling

The library provides detailed error messages for common issues:

  • Bus not open: Ensure you call Open I2C Bus before 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework_i2c-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

robotframework_i2c-1.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

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

Hashes for robotframework_i2c-1.0.0.tar.gz
Algorithm Hash digest
SHA256 49e08c0db266ed56e47a54e3d820424e03ef22ecfb56165c4a25eb86e154eab1
MD5 6bfe16e01018c59c6ec28abf1cb91563
BLAKE2b-256 e0f65077356e04e48ba5e064b9d2ff58468e17deccd3798a741320cb888138f6

See more details on using hashes here.

File details

Details for the file robotframework_i2c-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_i2c-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 112e92e942543320f0df23e695dc81c6270629e29eae45948cf8d0490026f78a
MD5 0f62a07f27b5d5e3794d120427497e32
BLAKE2b-256 37596a80670303c24d764b8e1e0260078ce050d4a10214123bbe9b492b119cbc

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