1

I have a temperature and humidity sensor connected to my RPi via 3.3v power, GND and SDA and SCL. I am trying to get a temperature reading from it but I keep getting a

"OSerror: [Errno 121] Remote I/O error".

The i2c interface is enabled and everything is up to date. I can see the address of the device using sudo i2cdetect -y 1. Could it be possible that i should be sending some data to it first so that the sensor "knows" that i am about to read from it and it should be sending data ?

This is my code

import smbus
TEMP = 0x40
bus = smbus.SMbus(1)
state = 1

while (state):
      print("1.Read temperature")
      print("2.Exit")

      choice = input("")

      if choice =='1':
            Ctemp = bus.read_byte(TEMP)
            print ("%d" %Ctemp)

      elif choice == '2':
            state = 0

1 Answers1

0

Yes, it's possible you might have to configure your I2C device (you don't mention what you use, so I can't look that up for you) but this error probably means something else. You can try i2cdump -y 1 0x40 to see what data is available, but again, you should read the sensor's chip's datasheet in order to know what to work with.

Zoltán
  • 1,422
  • 17
  • 22