tonilopezmr / tonilopezmr.github.io

My web portfolio.
https://tonilopezmr-github-io.vercel.app
Other
4 stars 1 forks source link

RaspberryPI I2C bus #51

Open tonilopezmr opened 4 years ago

tonilopezmr commented 4 years ago

Example

import smbus 

I2C_ADDRESS = 0x08 

I2Cbus = smbus.SMBus(1) 

def write(message):
    messageBytes = ConvertStringsToBytes(message)
    I2Cbus.write_i2c_block_data(I2C_ADDRESS, 0, messageBytes)

def read():
    return I2Cbus.read_i2c_block_data(I2C_ADDRESS, 0, 14)

Reference

https://www.abelectronics.co.uk/kb/article/1/i2c--smbus-and-raspbian-linux