GL868 IIC python code with ADC reading .

  • Hi


    I am using GL868 and trying to connect with ADC PCF8591.


    Do you guys have any experience wit ADC using IIC python library?
    I have used slave address as 0x48 and control byte as 0x00 to get the analog reading but till now no success.


    If any one has done it before then please guide me how can I read the voltage value using I2C .


    Thanks .

  • Hello Somnath,


    Try this:
    I2C_SDA = 5 #GPIO PIN that is connected to SDA
    I2C_SCL = 6 #GPIO PIN that is connected to SCL
    I2C_ADDR = 0x48
    bus = IIC.new(I2C_SDA, I2C_SCL, I2C_ADDR)
    status = bus.init()


    res = bus.readwrite('\x00', 1)


    The above code will send the following Bytes to the ADC chip
    0x90 0x00 0x91
    And then will read one byte
    0x90 is 7 bits address 0x48 shifted one bit to the left with the R/W bit set to 0 (Write mode)
    0x91 is 7 bits address 0x48 shifted one bit to the left with the R/W set to 1 (read mode)
    You can read mode than one byte of course if you change the second argument in the function bus.readwrite()