A Python library for DLN2 I2C adapters with an SMBus-style API. Originally developed for Pico USB IO Board.
Project description
DLN2 I2C Wrapper
A Python library for interfacing with DLN2 USB-to-I2C adapters with an SMBus-style API.
It targets the Pico USB I/O Board firmware and packages the host-side I2C access layer as a
standalone Python project.
Features
- SMBus-style API for common byte, word, and I2C block operations
- Low-level DLN2 USB client built on
pyusb - BME280 helper for chip ID, calibration, and measurement reads
- I2C scan and BME280 example scripts
- Pure Python, no compiled extension
Important Limitation
The firmware exposes separate DLN2 read and write commands. It does not expose a single combined repeated-start transaction through the USB protocol, so register reads are performed as:
- Write register pointer
- Start a separate read transaction
That works for many devices, but it is not identical to Linux i2c-dev combined transfers.
i2c_rdwr() in this wrapper also executes messages sequentially for the same reason.
Installation
From source:
git clone https://github.com/syabyr/dln2_i2c_wrapper.git
cd dln2_i2c_wrapper
pip install .
For development:
pip install -e ".[dev]"
Quick Start
from dln2_i2c_wrapper import SMBus
with SMBus(1) as bus:
device_addr = 0x50
register = 0x00
value = bus.read_byte_data(device_addr, register)
print(hex(value))
bus.write_byte_data(device_addr, register, 0x12)
BME280 Example
from dln2_i2c_wrapper import BME280
with BME280(bus=1, address=0x76) as sensor:
print(hex(sensor.check_chip_id()))
sensor.read_calibration()
sensor.configure()
print(sensor.read_measurements())
Command-Line Tools
dln2-i2c-test --help
dln2-i2c-scan --help
dln2-bme280-test --help
Use register-based probing when scanning devices that do not ACK a bare read, for example:
dln2-i2c-scan --register 0xD0 --read-len 1
Low-Level API
from dln2_i2c_wrapper import Dln2Usb, find_device
device = find_device()
client = Dln2Usb(device, debug=True)
client.i2c_enable()
client.i2c_write(0x50, b"\x00")
data = client.i2c_read(0x50, 4)
print(data.hex())
client.i2c_disable()
client.close()
Development
make test
make build
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 dln2_i2c_wrapper-0.1.0.tar.gz.
File metadata
- Download URL: dln2_i2c_wrapper-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a41754db30ce4bf4542280c57dffaf576bb7caea6af30116ee5471477c2455d9
|
|
| MD5 |
e4e61101b84021161abd9e566fe50db2
|
|
| BLAKE2b-256 |
73aa0ab8043ccaea4e41b9975d43e82d8f6f32fd81ec47bbb5d765fd3e96e389
|
File details
Details for the file dln2_i2c_wrapper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dln2_i2c_wrapper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f269b54ed6324a2defad310ce9935ad9a160aada63ac725e29b121eb0075f340
|
|
| MD5 |
cfa62fdc11c54e2d29705b5f2df8a560
|
|
| BLAKE2b-256 |
c9b65606f28f6c8a59350a79e0d9ca731aecbefc2e72679b7c5c105af3b26690
|