Problem with MAX30105

Hi i want to try out the MAX30105 Breakout Bord with Breakout Garden. I used the heartbeat example and got the following error message:

Traceback (most recent call last):
File “/home/pi/breakout-garden-master/examples/heartbeat/heartbeat.py”, line 41, in
max30105.setup(leds_enable=2)
File “/usr/local/lib/python3.7/dist-packages/max30105-0.0.2-py3.7.egg/max30105/init.py”, line 319, in setup
self.soft_reset(timeout=timeout)
File “/usr/local/lib/python3.7/dist-packages/max30105-0.0.2-py3.7.egg/max30105/init.py”, line 353, in soft_reset
while self._max30105.get(‘MODE_CONFIG’).reset and time.time() - t_start < timeout:
File “/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.6-py3.7.egg/i2cdevice/init.py”, line 232, in get
result[field] = self.get_field(register, field)
File “/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.6-py3.7.egg/i2cdevice/init.py”, line 247, in get_field
value = field.adapter._decode(value)
File “/usr/local/lib/python3.7/dist-packages/i2cdevice-0.0.6-py3.7.egg/i2cdevice/adapter.py”, line 26, in _decode
raise ValueError("{} not in lookup table".format(value))
ValueError: 0 not in lookup table

I2c is working, because othe examples are working!

I have the same problem/error.
I installed a clean copy of Raspbian Buster (July 2019 version) and the latest version of the library from github (https://github.com/pimoroni/max30105-python.git)
I’m trying on a Raspberry Pi 4 with 4 GB RAM

Thanks

Hi, did you found a solution to the problem?

I’m having the same error at all example scripts.

What I tried:
Switching between python 2 and 3
Cloning the latest version of the library after installing with pip
Using a fresh installed and updated version of Raspbian Buster

Error:
pi@raspberrypi:~/max30105-python/examples $ python read-heartbeat.py
Traceback (most recent call last):
File “read-heartbeat.py”, line 10, in
max30105.setup(leds_enable=2)
File “/usr/local/lib/python2.7/dist-packages/max30105/init.py”, line 319, in setup
self.soft_reset(timeout=timeout)
File “/usr/local/lib/python2.7/dist-packages/max30105/init.py”, line 353, in soft_reset
while self._max30105.get(‘MODE_CONFIG’).reset and time.time() - t_start < timeout:
File “/usr/local/lib/python2.7/dist-packages/i2cdevice/init.py”, line 232, in get
result[field] = self.get_field(register, field)
File “/usr/local/lib/python2.7/dist-packages/i2cdevice/init.py”, line 247, in get_field
value = field.adapter._decode(value)
File “/usr/local/lib/python2.7/dist-packages/i2cdevice/adapter.py”, line 26, in _decode
raise ValueError("{} not in lookup table".format(value))
ValueError: 0 not in lookup table

I2C is working:

I don’t have the right widgets with me to attempt a fix right now, but this obtuse error is actually i2cdevice trying to convert a value read from the sensor into something meaningful. There has been a pull request recently for i2cdevice that - iirc - makes this error more legible.

Looking at the stack trace though it appears to be a read from the “MODE_CONFIG” register that’s returning a zero in some bitfield that it doesn’t expect.

The MAX30105 library will need modifying to allow a 0 value in this case.

It’s almost certainly going to be the sensor mode:

BitField('mode', 0b00000111,   adapter=LookupAdapter({
    'red_only': 0b010,
    'red_ir': 0b011,
    'green_red_ir': 0b111
}))

The datasheet doesn’t specify any case where this should be read as 0 but perhaps this happens with a new, uninitialised sensor.

A short term fix may be to run:

i2cset -y 1 0x57 0x09 0x07

This will flip the sensor into a known good mode (multi-led mode in this case) and hopefully allow the library to function.

Edit: updated instructions to include the register address MODE_CONFIG = 0x09.

I tried with your short term fix but I always have the exact same error.

Thank you very much for looking into this issue.

I also tried the possible short term fix but the error is still the same. Can you link the pull request so we can follow the status? Is there anything we can do, commenting on the pull request with more information for example?

It looks like the reset state of the MODE_CONFIG register is 0, so it gets reset when the library initialises. Working on a fix now.

1 Like

This should now be fixed as of https://github.com/pimoroni/max30105-python/releases/tag/v0.0.3

After running sudo ./uninstall.sh, cloning the library and running sudo ./install.sh it is working now. Thank you for fixing the library