0

I am working off of a Raspberry Pi 4B. I have recently connected this temperature/RH sensor, but I am having trouble to with the python code. This is the datasheet for the sensor (Pg. 11-18 are most relevant). I believe that this is a 16-bit sensor, would that have any influence on SMbus?

At this point, I am receiving [Errno 121] Remote I/O Error, but I am sure that every is connected and i2cdetected so I think the issue is with how the temperature register is being written to the sensor. I haven't had a chance to write further because of this error.

If you can, I am very novice to python so please be explicit if possible. Thank you for your time!

Python Code:

import smbus
import time

sensor_address = 0x40
bus = smbus.SMBus(1)

# Configuration Register Address
config_reg = 0x02

def do_write(address, reg): 
    try: 
        bus.write_byte_data(address, config_reg, reg)
    except Exception as e:
        print("Error writing to sensor:", e)

def do_read(address, reg):
    try:
        data = bus.read_i2c_block_data(address, reg)
        return data
    except Exception as e:
        print("Error reading from sensor:", e)
        return None



4
  • The Raspberry Pi overlay system supports many temperature sensors. Unfortunately, the CHT8305C does not seem to among them. You can probably overcome that in Python, but it may require some effort on your part - you'll need to read & understand the operational details of the sensor.
    – Seamus
    Commented Jun 7 at 0:38
  • The error [Errno 121] Remote I/O Error typically indicates a communication issue between the Raspberry Pi and the sensor.Use the i2cdetect command to verify the sensor's I2C address.
    – liaifat85
    Commented Jun 7 at 15:05
  • @Seamus What does it mean that the Pi overlay doesn't support the CHT8305C, could you be more specific on what I would need to overcome this?
    – Jack
    Commented Jun 12 at 19:26
  • All overlays are listed HERE. If an overlay is not listed, that simply means there is no overlay, which in turn means that device is not included in the device tree, which in turn means it will be difficult to use that device on a RPI. Is there a possibility that you have the sensor name/PN wrong - or is it known under another name?
    – Seamus
    Commented Jun 13 at 2:33

1 Answer 1

1

A short checklist to address your Remote I/O Error:

  • Are you sure you've connected (wired) the sensor to your RPi properly?

  • Have you enabled the I2C bus in sudo raspi-config?

  • Have you enabled i2c1 or i2c0 in config.txt and re-booted?

  • Have you installed i2c-tools?

  • After installing i2c-tools, have you run sudo i2cdetect -y 0 or sudo i2cdetect -y 1

  • Have you checked the README file RPi GitHub site to see if an overlay is available for your sensor?

4
  • I have completed all of these steps to receive the same error, running i2cdetect -y 1 presents the sensor at 0x40 as expected.
    – Jack
    Commented Jun 12 at 19:25
  • @Jack: In that case, I would have to guess that the sensor actually is at address 0x40. That being the case, the error in your Python code must be due to something else! Is the device at 0x40 indicated by a UU - or something else?
    – Seamus
    Commented Jun 13 at 2:36
  • Nope, it simply appears in the 0 column and 40 row as 40 @Seamus
    – Jack
    Commented Jun 20 at 18:20
  • @Jack: In that case, the device is detected on the I2C bus, but has not been picked up by a driver. WRT a driver: As I mentioned, I did not see the 8305 T&H sensor mentioned in the README file which suggests that your sensor is not supported by the RPi. However, you should check with the vendor to determine driver availability under Linux.
    – Seamus
    Commented Jun 21 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.