OSError: [Errno 5] EIO I2C based MAX30102 (Heart-rate sensor)

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
AlbertLong
Posts: 2
Joined: Mon Jan 24, 2022 6:51 am

OSError: [Errno 5] EIO I2C based MAX30102 (Heart-rate sensor)

Post by AlbertLong » Mon Jan 24, 2022 7:13 am

:cry:
Hi,

Guys, I am trying to write and read data from I2C based MAX30102 (Heart-rate sensor). When I try to execute i2c.mem_write in the initial reset, I get the following OS Error "OSError: [Errno 5] EIO". I have already added some delays before and after this statement.

However, when I try the same code without reset it runs fine and it doesn't give me an error.

Below I have given my code.

Code: Select all

def __init__(self,i2c_id=1,address=0x57, pin='X1'):
        print("intpin: {0}, address: {1}".format(pin, address))
        self.i2c = I2C(i2c_id,I2C.MASTER, baudrate=400000)
        self.address = address
        self.interrupt =Pin(pin,Pin.IN)    
        pyb.delay(100)                              
        self.reset()                                                     #soft reset
        pyb.delay(100)
        utime.sleep_ms(5000)
        self.setup()

Code: Select all

def reset(self, led_mode=b'\x40'):
        """
        Reset the device, this will clear all settings,
        so after running this, run setup() again.
        """
        self.i2c.mem_write(led_mode, self.address, REG_MODE_CONFIG)
Have anyone faced the same issue, then please tell me how to resolve it? :D

The most incredible thing is that I can use i2c.mem_write statement somewhere else, like in setup, except for resetting the module MAX30102.

Post Reply