Error reading SHT31-D value on RaspberryPi 3B +

What I used this time

--Main: Raspberry Pi 3 Model B + --Language: Python --Sensor: SHT31-D

CENTER_0002_BURST20200614012610275.jpg

Referenced page

I referred to this page this time.

Get the temperature and humidity from the sensor using Raspberry Pi!

Problems this time

It was very easy to understand, but when I wrote the code as it was, I got an error.

Traceback (most recent call last):
 File "SHT31D.py", line 16, in <module>
  i2c.write_byte_data(i2c_addr, 0x21, 0x30)
OSError: [Errno 121] Remote I/O error

When I looked it up, it seems that I2C cannot be used because the slave address is incorrect.

$ sudo i2cdetect -y 1

I typed this in the terminal image.png

I'm not sure how to read the table now, It turns out that it seems to be the address 44 on the device connected by I2C. 14th line

i2c_addr = 0x45

From

i2c_addr = 0x44

It worked when I changed it to. ... error, not line 16 ...

After that, although there were spelling mistakes, I corrected it and it worked. image.png

I wasn't sure why the addresses were different, so The future issue is clear.

Recommended Posts

Error reading SHT31-D value on RaspberryPi 3B +
Step 2 to install Xenomai on RaspberryPi 3 model B +
Procedure for installing Xenomai on RaspberryPi 3 model B + Part 1
Power on/off the USB port on the RaspberryPi 4 Model B