A useful i2c package for Pi
Project description
A useful i2c Python3 package for Pi
Based on smbus2
Installation
Via pip
pip3 install pyi2c
How to use?
Example
from pyi2c import I2C
# Create i2c
BUS_N = 0 # 0 or 1 or 2. Change this to yours
i2c = I2C(BUS_N)
# Write
ADDR = 0x38 # Change this to yours
WRITE1 = 0x00 # Change this to yours
i2c.write(ADDR, WRITE)
# or write multi bytes, up to 64 bytes
WRITE0 = 0x01 # Change this to yours
i2c.write(ADDR, [WRITE0, WRITE1])
# Read
read_data = i2c.read(ADDR)
# or set length of reading bytes
bytes_n = 2
read_data = i2c.read(ADDR, byte_n)
# First write and read rapidly
read_data = i2c.writeread(ADDR, WRITE0)
# These also work
read_data = i2c.writeread(ADDR, [WRITE0, WRITE1])
read_data = i2c.writeread(ADDR, [WRITE0, WRITE1], bytes_n)
Reference
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
pyi2c-0.0.1.tar.gz
(3.2 kB
view details)
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
pyi2c-0.0.1-py3-none-any.whl
(3.4 kB
view details)
File details
Details for the file pyi2c-0.0.1.tar.gz.
File metadata
- Download URL: pyi2c-0.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
699c6ff402fbb55b4418e466bbe92e52bb87e0de77623fa527c5c52c664fbfab
|
|
| MD5 |
e4c35726ae1a013bddc26bc32fc1e1cc
|
|
| BLAKE2b-256 |
55916f2c3f4d71dec831b5c25bdd80c74bf2cfa1890eab9a452b1c6f0b0b0ff2
|
File details
Details for the file pyi2c-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyi2c-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1050eb182ee2e7267af6e065907428ad273d41c3931ec844c941de1bef365138
|
|
| MD5 |
888bff9fb9ff2ea5de8b41c330eeaa19
|
|
| BLAKE2b-256 |
bffd9665bd314e7c2f4630c8a28c4d16b78e2884bcc5108915df7d11e86e6d58
|