raspi-thermal-cam icon indicating copy to clipboard operation
raspi-thermal-cam copied to clipboard

OSError: [Errno 5] Input/output error

Open yuehshienlin opened this issue 1 year ago • 0 comments

Hi. I download the code and try mlx90640_test.py by modify it for keeping running on my raspberry pi 4 64bit When it run 818 sec after start ,I got the error 'OSError: [Errno 5] Input/output error ' Do you know how can I fix it?

here is my code:


##################################
# MLX90640 Test with Raspberry Pi
##################################
#
import time,board,busio,os
import numpy as np
import adafruit_mlx90640

t0 =time.time()
i2c = busio.I2C(board.SCL, board.SDA, frequency=400000) # setup I2C
mlx = adafruit_mlx90640.MLX90640(i2c) # begin MLX90640 with I2C comm
mlx.refresh_rate = adafruit_mlx90640.RefreshRate.REFRESH_2_HZ # set refresh rate

frame = np.zeros((24*32,)) # setup array for storing all 768 temperatures
while True:
    try:
        mlx.getFrame(frame) # read MLX temperatures into frame var
        
    except ValueError:
        continue # if error, just read again
    processtime = time.time()-t0
    os.system('clear')
    print('Average MLX90640 Temperature: {0:2.1f}C ({1:2.1f}F)'.\
    format(np.mean(frame),(((9.0/5.0)*np.mean(frame))+32.0)))
    print('processtime: %d sec'%processtime)

and here is the error report " Traceback (most recent call last): File "/home/pi/raspi-thermal-cam/mlx90640_test.py", line 17, in mlx.getFrame(frame) # read MLX temperatures into frame var File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 126, in getFrame status = self._GetFrameData(mlx90640Frame) File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 140, in _GetFrameData self._I2CReadWords(0x8000, statusRegister) File "/usr/local/lib/python3.9/dist-packages/adafruit_mlx90640.py", line 828, in _I2CReadWords i2c.write_then_readinto( File "/usr/local/lib/python3.9/dist-packages/adafruit_bus_device/i2c_device.py", line 141, in write_then_readinto self.i2c.writeto_then_readfrom( File "/usr/local/lib/python3.9/dist-packages/busio.py", line 192, in writeto_then_readfrom return self._i2c.writeto_then_readfrom( File "/usr/local/lib/python3.9/dist-packages/adafruit_blinka/microcontroller/generic_linux/i2c.py", line 90, in writeto_then_readfrom readin = self._i2c_bus.read_i2c_block_data( File "/usr/local/lib/python3.9/dist-packages/Adafruit_PureIO/smbus.py", line 275, in read_i2c_block_data ioctl(self._device.fileno(), I2C_RDWR, request) OSError: [Errno 5] Input/output error "

yuehshienlin avatar Nov 23 '22 06:11 yuehshienlin