I would like to add code to a Python program for my Pi (Raspbian Jessie or Stretch) which will do the equivalent of these command line commands:
- sudo i2cget -y 1 0x6b 0x05
- sudo i2cset -y 1 0x6b 0x05 0xff
I looked at using SMBUS but the more I read the more I get confused.
Any help or Python code examples would be appreciated.....RDK
EDIT: As per Joan's suggestion I grabbed the bull by the horns and tried the following:
#!/usr/bin/env python
import smbus
# sudo i2cget -y 1 0x6b 0x05
# sudo i2cset -y 1 0x6b 0x05 0xff
# bus number = 1
# Chip_Add = 0x6b
# Data_Add = 0x05
MyBus = smbus.SMBus(1)
MyBus.write_byte_data(0x6b,0x05,0xfe)
ReadData = MyBus.read_byte_data(0x6b,0x05)
print ReadData
It seemed to work, although I still not clear on most of the other SMBUS commands. The issue, or maybe my issue with this question was that, while there are lots of web references to SMBUS and to I2C commands, there are none that I found which made a 1:1 connection....