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