Need help reading AMS5812 from Raspberry Pi/Python

I have a Raspberry Pi W with a nodelynk interface connecting to an HCPA_5V_U3 Humidity and Barometric Pressure sensor at address 0x28 and a AMS5812 Pressure sensor at address 0x78. i2detect sees them both.

$ i2cdetect -q -y -a 1 0x03 0x7f
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- -- 78 -- -- -- -- -- -- -- 

I’ve been using the humid/bar sensor for a long time w/no problems, but the pressure sensor is new and I am unable to read it. This sample python code shows the problem

# Distributed with a free-will license.
# Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
# HCPA_5V_U3
# This code is designed to work with the HCPA-5V-U3_I2CS I2C Mini Module available from ControlEverything.com.
# https://www.controleverything.com/content/Temperature?sku=HCPA-5V-U3_I2CS#tabs-0-product_tabset-2

import smbus
import time

# Get I2C bus
bus = smbus.SMBus(1)

# HCPA_5V_U3 address, 0x28(40)
# Send start command, 0x80(128)
bus.write_byte(0x28, 0x80)

time.sleep(0.5)

# HCPA_5V_U3 address, 0x28(40)
# Read data back, 4 bytes
# humidity msb, humidity lsb, cTemp msb, cTemp lsb
data = bus.read_i2c_block_data(0x28, 4)

# Convert the data to 14-bits
humidity = (((data[0] & 0x3F) * 256) + data[1]) / 16384.0 * 100.0
cTemp = (((data[2] * 256) + (data[3] & 0xFC)) / 4) / 16384.0 * 165.0 - 40.0
fTemp = (cTemp * 1.8) + 32

# Output data to screen
print("Relative Humidity: ",humidity)
print("Temperature (C):",cTemp)
print("Temperature (F):",fTemp)

#Now, try to read the pressure sensor
data = bus.read_i2c_block_data(0x78, 4)

print(data)

results in this output.

$ python test_HumBar_and_Pressure.py 
Relative Humidity:  51.4404296875
Temperature (C): 25.02716064453125
Temperature (F): 77.04888916015625
Traceback (most recent call last):
    File "test_HumBar_and_Pressure.py", line 35, in <module>
        data = bus.read_i2c_block_data(0x78, 4)
OSError: [Errno 121] Remote I/O error

There’s some info on the web that suggests that 0x78 is a reserved address (e.g. see: The List | I2C addresses! | Adafruit Learning System). Frustratingly, the NCD page on this part at https://store.ncd.io/product/ams5812-0008-d-low-pressure-sensor/ claims that this part has a " Programmable I²C Address", but I believe this is a bit of a fiction as it seems to require a USB programmer that is not available.

Has anyone been able to read this device from a Raspberry Pi running python? If the problem is indeed due to the address issue, would one of the NCD
TCA9546A 4-Channel I2C Bus Multiplexer potentially solve this problem?

Any ideas would be appreciated.

Thanks,
Phil

Hi Phil,

If there is an I2C bus address conflict on the Raspberry Pi, then yes, the multiplexer should resolve that issue.

Based on the encouraging comment from Profile - TravisE_NCD_Technica - NCD.io Community, I purchased the multiplexer board and gave it a try. As soon as I took a close look at the API, it became clear that this approach would not solve my problem: whatever i2c conflict that I have is not ‘downstream’ on my nodelynk bus, but rather on the raspberry pi side. Nonetheless, I gave the new board a try and got the exact same behavior: the AMS5812 fails and all my other devices work fine.

As a follow-up question to NCD, as I mentioned above, the NCD page on this part at https://store.ncd.io/product/ams5812-0008-d-low-pressure-sensor/ claims that this part has a " Programmable I²C Address". Indeed, re-programming this address would resolve my problem, but I see no mention in any of the NCD documentation how to do this. Can NCD, or anyone else, provide some guidance on this?

Thanks,
Phil

mux is straightforward hardware.
You will select the port and write to that port.
check page 6

Yes: I understand that. As I said in my post above: “I gave the new board [the mux] a try and got the exact same behavior: the AMS5812 fails and all my other devices work fine”. That is, I can put any of my currently working i2c devices on any of the mux ports, select the appropriate mux port, and they work properly as expected. The behavior of the AMS5812, too, is unchanged and it does not work on any of the mux ports (as I now understand should have been expected). In short, the mux board works great, programming it was straightforward, but it doesn’t solve my problem.

The problem is that the AMS5812 uses i2c address 0x78 which the Raspberry evidently views as a reserved i2c address and does not treat it as it does other i2c addresses. To solve the problem, I believe I need to use the AMS5812 i2c address reprogramming feature, and I’m seeking information about how to do that.

Thanks,
Phil