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