Skip to main content

Python RPI interface to low-level ICs

Project description

PyRPIIC

./icon.png

A [Py]thon 3 addon for [R]aspberry [Pi] that enables [i]nterfacing w/ a variety of low-level board [IC]s.

PyPI

Compatibility

  • Raspberry Pi Models: A, B (revisions 1.0 and 2.0), A+, B+, 2, 3, 3+, 3 A+, 4, Compute Module 3, Zero.
  • Python 3.7+

Install

Install the latest from PyPi:

pip install pyrpiic

-OR- using pipenv:

pipenv install pyrpiic

Install from source:

python3 setup.py install

Modules

Clocks

  • LMK612
  • SI570

EEPROMs

  • Generic
  • M24C02

I2C-GPIO Expanders

  • TCA6416A

Sensors

  • LDC1412
  • LDC1414
  • LDC1612
  • LDC1614

Examples

Clocks (Programmable Oscillators)

from pyrpio.i2c import I2C
from pyrpiic.clock.lmk61e2 import LMK61E2

# Create and open I2C-3 bus
i2c3 = I2C('/dev/i2c-3')
i2c3.open()

# Create clock
clock = LMK61E2(i2c3, 0x5A)

# Perform various clock operations
clock.set_frequency(156_250_000)
freq, regs = clock.get_frequency()
clock.regs2freq(regs)
clock.set_registers(regs)

# Close I2C-3 bus
i2c3.close()

I2C-GPIO Expanders

from pyrpio.i2c import I2C
from pyrpiic.ioexpander.tca6416a import TCA6416A

# Create and open I2C-3 bus
i2c3 = I2C('/dev/i2c-3')
i2c3.open()

# Create gpio expander
gpio_exp = TCA6416A(i2c3, 0x21)

# Set GPIO P00 as output pulled high
gpio_exp.set_gpio_direction('P00', 'OUT')
gpio_exp.set_gpio_output('P00', high=True)

# Set GPIO P01 as input w/ flipped polarity and read value
gpio_exp.set_gpio_direction('P01', 'IN')
gpio_exp.set_gpio_polarity('P01', flipped=True)
gpio_exp.get_gpio_input('P01')

# Close I2C-3 bus
i2c3.close()

Project details


Download files

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

Files for pyrpiic, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size PyRPIIC-1.0.0.tar.gz (13.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page