- Mon Nov 26, 2018 4:43 pm
#201190
Preamble -
I have a SI7021 board from SparkFun attached to a RPiZW using 4 wires (3.3v, ground, SCL, SDA). "i2cdetect -y 1" shows only the SI7021 on the bus at address 0x40. This seems good. Does this mean the connection is correct? I didn't remove the pull-up on the SI7021 board.
The problem -
When running a simple test, I get alternating errors of:
IOError: [Errno 5] Input/output error
IOError: {Errno 121} Remote I/O error
On the line with the first read:
RH_raw = bus.read_word_data(0x40, 0xE5)
Any ideas what would cause this? Better yet, any ideas of how to fix it? I set the bus speed to 400000 and 100000 with no difference in results. I tried different python libraries (smbus, pigpio, adafruit's smbus equivalent, a "home-brew-POS", smbus' I2C interface) and get the same results. I'm a bit frustrated.
Here is the full code:
I have a SI7021 board from SparkFun attached to a RPiZW using 4 wires (3.3v, ground, SCL, SDA). "i2cdetect -y 1" shows only the SI7021 on the bus at address 0x40. This seems good. Does this mean the connection is correct? I didn't remove the pull-up on the SI7021 board.
The problem -
When running a simple test, I get alternating errors of:
IOError: [Errno 5] Input/output error
IOError: {Errno 121} Remote I/O error
On the line with the first read:
RH_raw = bus.read_word_data(0x40, 0xE5)
Any ideas what would cause this? Better yet, any ideas of how to fix it? I set the bus speed to 400000 and 100000 with no difference in results. I tried different python libraries (smbus, pigpio, adafruit's smbus equivalent, a "home-brew-POS", smbus' I2C interface) and get the same results. I'm a bit frustrated.

Here is the full code:
Code: Select all
Thanks for any/all help or ideas.import smbus
# our device is on bus 1.
bus = smbus.SMBus(1)
# read relative humidity (RH)
RH_raw = bus.read_word_data(0x40, 0xE5)
rh_raw = RH_raw[0]<<8 | RH_raw[1]
# 0xE0 retrieves the temperature measurement used for RH instead of measuring again using 0xE3
T_raw = bus.read_word_data(0x40, 0xE0)
t_raw = T_raw[0]<<8 | T_raw[1]
# compute and save humidity and temp values
RH = 125.0*rh_raw/65536.0 - 6.0
Tc = 175.72*t_raw/65536.0 - 46.85
Tf = Tc * 1.8 + 32
print("tempf {0} tempc {1} humidity {2}".format(Tf, Tc, RH))