MCP3428 reads 0 on all channels

Hi all,

I have a sensor (a pyranometer) plugged into my MCP3428 (4 channels), itself linked to a raspberry pi. I tested with a multimeter, and the sensor does send current to the MCP3428.

Here is what I tried:
for all possible addresses for my device (it should be 0x68 but I try a range of 0 to 0x100 just in case), for all channels (1 to 4), I try to acquire the data using the SMBus.read_i2c_block_data function.
I read a solid zero in every configuration, even with addresses that are not my device’s (given that they don’t cause an InvalidArgument exception)

I did try to use the code found here GitHub - ncdcommunity/Raspberry_Pi_MCP3428_16Bit_4Channel_ADC_Python_library: MCP3428 16Bit 4Channel Analog To Digital Converter Interfacing with Raspberry Pi
but with no different results.
I tried another MCP3428 in case the hardware was faulty, but still no change. What could I possibly be forgetting/what could be broken without me knowing?

Thank you for your time!

ps: in case that helps, here is the code:

import SMBus

i2cbus = SMBus(1) # tried i2cdetect -y 1, the device is here

def get_adc(channel=1; rate=26, gain=2, adress=0x68): #this is the default adress in the doc
    if channel == 0:
        bitchannel = "00"
    elif channel == 1:
        bitchannel="01"
    elif channel == 2:
        bitchannel = "10"
    elif channel == 3:
        bitchannel = "11"
    else:
        bitchannel = "00"
    
    if rate == 16:
        bitrate="00"
        base = 0b00000111
        index = 0b00001000
        total = 2047
    # lets assume that rate is 16 and not do the other cases
    if gain == 2:
        bitgain="00"

    cmd = "0" + bitchannel + "1" + bitrate + bitgain
    result = i2cbus.read_i2c_block_data(adress, int(cmd, 2), 3)
    print(result) # [0, 0, 0] every time
    time.sleep(0.1)
    data= i2cbus.read_i2c_blokc_data(adress, int(cmd, 2), 2)
    print(data) # [0, 0] every time

for address in range(0, 0x100):
    for channel in [1, 2, 3, 4]:
        try:
           get_current(channel=channel, address=address) 
        except:
            print("This adress was invalid")

Here is my setup: (the cables are not very easy to show, sorry about that)




Do you have i2ctools installed on the Pi? If so what do you get as a result to:

i2cdetect -y 0
i2cdetect -y 1

Also please provide photos of your hardware setup.

Thank you for the quick response. I edited the original question with pictures!

The result to your i2cdetect -y 1 command does not look right. Did you enable I2C on the RPi? Only addresses which have devices present should appear in the result. I recommend googling Enable I2C on Raspberry Pi.

1 Like

alright. I did a bit of research based on what you said.

Turns out, not only my first ADC was malfunctioning, but so was the one I used to test I the issue was from a malfunctioning ADC, as well as the shield mounted on the RPi.
Thank you for pointing me into the right direction! Have a great day.

1 Like