Always zero read from Grove I2C ADC

I have a Grove I2C ADC that connected to Raspberry Pi. i2cdetect -y 1 shows me address 50. I successfully accept my write to config register and readback appears to be correct. But it always read zeros. Where I can see schematics for this simple module? I assume it has capacitor at it’s input thus I can’t read constant levels, such as VCC, or slowly changing values. Am I right? Is it safe to remove capacitor? I saw cap in “typical application circuit” in datasheet for ADC 121C021.

I used to connect VCC to it’s input for testing purposes, which allowed to apply up to 5.5 volts.

read= 0xE0
0: adc= 0x0000 -> 0
1: adc= 0x0000 -> 0
2: adc= 0x0000 -> 0
3: adc= 0x0000 -> 0
4: adc= 0x0000 -> 0

Here is my simple program below:

#!/usr/bin/env python3

ADDR_ADC121 = 0x50

REG_ADDR_RESULT = 0x00
REG_ADDR_ALERT = 0x01
REG_ADDR_CONFIG = 0x02
REG_ADDR_LIMITL = 0x03
REG_ADDR_LIMITH = 0x04
REG_ADDR_HYST = 0x05
REG_ADDR_CONVL = 0x06
REG_ADDR_CONVH = 0x07

import smbus, os, sys
import time

adc = smbus.SMBus(1)
#adc.write_byte_data(ADDR_ADC121, REG_ADDR_CONFIG, 0x20)
adc.write_byte_data(ADDR_ADC121, REG_ADDR_CONFIG, 0xE0)
r = adc.read_byte_data(ADDR_ADC121, REG_ADDR_CONFIG)
print(“read= 0x%02X” % r)

def read_adc():
rw = adc.read_word_data(ADDR_ADC121, REG_ADDR_RESULT)
w = (((rw & 0xFF)<<8) | (rw & 0xFF00)>>8)
print(“adc= 0x%04X -> %d” % (w, w))
return w

count = 0
while True:
print("%5d: " % count, end = “”)
read_adc()
count += 1
time.sleep(0.5)

from Adafruit_I2C import Adafruit_I2C
import time
 
ADDR_ADC121 = 0x50
 
REG_ADDR_RESULT = 0x00
REG_ADDR_ALERT = 0x01
REG_ADDR_CONFIG = 0x02
REG_ADDR_LIMITL = 0x03
REG_ADDR_LIMITH = 0x04
REG_ADDR_HYST = 0x05
REG_ADDR_CONVL = 0x06
REG_ADDR_CONVH = 0x07
 
i2c = Adafruit_I2C(ADDR_ADC121)           
 
class I2cAdc:
    def __init__(self):
        i2c.write8(REG_ADDR_CONFIG, 0x20)
 
    def read_adc(self):
        "Read ADC data 0-4095."
        data_list = i2c.readList(REG_ADDR_RESULT, 2)
        #print 'data list', data_list
        data = ((data_list[0] & 0x0f) << 8 | data_list[1]) & 0xfff
        return data
 
if __name__ == '__main__':
    # Connect the Grove - I2C ADC to I2C Grove port of Beaglebone Green.
    adc = I2cAdc()
    while True:
        print 'sensor value ', adc.read_adc()
        time.sleep(.2)

Does this Python code work?

Where I can get Adafruit_I2C module? Which repo https://github.com/adafruit exactly? The only repo I found with Adafruit_I2C name was for C/C++, not for Python3 :roll_eyes:

Problem solved, may be it was a bad connection? Strange. It started to work without modification of the i2c adc board.