Problem with 8-Channel 12-Bit ADC / I2C adress and no input value

For those who are lost here with value 0 everywhere. Check if you have the mm32 version (read the MCU ref on the MCU itself). If it’s the case, seems this MCU doesn’t handle all I2C features, especially it seems to don’t like write/read in same sequence.

You have to write first the register you want to read then read it.

I created a very simple snippet with a low level i2C lib for Python : pip install python-periphery
This snippet read the first channel (mV converted value) on register 0x20.

from time import sleep
from periphery import I2C

i2c = I2C("/dev/i2c-1")  # default I2C bus in my Rpi

addr = 0x08  # addr if you have the MM32 version

write_msg = I2C.Message([0x20], read=False)  # [register]
i2c.transfer(addr, [write_msg])

sleep(0.001)  # not sure it's needed

read_buf = bytearray(2)
read_msg = I2C.Message(read_buf, read=True)

i2c.transfer(addr, [read_msg])

print("read_buf: ", [hex(x) for x in read_msg.data])

Hope it helps.

1 Like