2

I am trying to get the MAX30102 heart sensor to run and have recompiled the kernel with the necessary module. I have loaded the follwing modules to be sure

i2c_dev
i2c-bmc2708
i2c-bmc2835
industrialio
max30102

I can verify this with lsmod

Module                  Size  Used by
max30102               16384  0
kfifo_buf              16384  1 max30102
regmap_i2c             16384  1 max30102
industrialio           73728  2 max30102,kfifo_buf
i2c_dev                20480  0

I have now found this device tree documentation and have tried adding

dtparam=interrupts=4,compatible=maxim,max30102,reg=0x57

to my /boot/config.txt as they are mentioned under the section "required" in the documentation. I just need to pass my interrupt pin which is connected to GPIO 4. But when I look under

$ for file in /sys/bus/i2c/devices/i2c-1/of_node/*; do ( echo $file; cat $file; echo "\n" )  ; done

/sys/bus/i2c/devices/i2c-1/of_node/#address-cells

/sys/bus/i2c/devices/i2c-1/of_node/clock-frequency ��

/sys/bus/i2c/devices/i2c-1/of_node/clocks

/sys/bus/i2c/devices/i2c-1/of_node/compatible brcm,bcm2711-i2cbrcm,bcm2835-i2c

/sys/bus/i2c/devices/i2c-1/of_node/interrupts u

/sys/bus/i2c/devices/i2c-1/of_node/name i2c

/sys/bus/i2c/devices/i2c-1/of_node/phandle 5

/sys/bus/i2c/devices/i2c-1/of_node/pinctrl-0

/sys/bus/i2c/devices/i2c-1/of_node/pinctrl-names default

/sys/bus/i2c/devices/i2c-1/of_node/reg ~�@

/sys/bus/i2c/devices/i2c-1/of_node/#size-cells

/sys/bus/i2c/devices/i2c-1/of_node/status okay

I still get the same values in the device tree. They are either empty or wrong.

neolith
  • 147
  • 1
  • 4
  • You might like to read the following post to see the root cause of the problem, and one way to fixt it: *How can Rpi read the MAX30100 / MAX30102 Oximeter?* Asked 1 year, 3 months ago Active 10 months ago Viewed 6k times: https://raspberrypi.stackexchange.com/questions/111955/how-can-rpi-read-the-max30100-max30102-oximeter. – tlfong01 Aug 17 '21 at 09:21
  • 1
    Thanks, I have already stumbled across this, but all of it is for Python and I want a C/C++ implementation utilizing the Linux kernel driver for the MAX30102 instead of using the Python library. – neolith Aug 17 '21 at 09:33
  • Ah, I see. C/C++ might have another problem. Good luck. Cheers. – tlfong01 Aug 17 '21 at 11:01

1 Answers1

1

After a lot of research I found out that you have to create a device tree overlays for the driver module

// Overlay for max30102 heart rate sensor

/dts-v1/; /plugin/;

/ { compatible = "brcm,bcm2835";

fragment@0 {
    target = <&i2c_arm>;

    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;

        max30102: heart-rate@57 {
            compatible = "maxim,max30102";
            reg = <0x57>;
            maxim,red-led-current-microamp = <7000>;
            maxim,ir-led-current-microamp  = <7000>;
            interrupt-parent  = <&gpio>;
            interrupts = <4 2>;
        };
    };
};

__overrides__ {
    int_pin = <&max30102>, "interrupts:0";
};

};

You can then configure the overlay in /boot/config.txt like this

# The default interrupt GPIO is still 4
dtoverlay=max30102
# Or to specify a different interrupt GPIO, e.g. 18
dtoverlay=max30102,int_pin=18
neolith
  • 147
  • 1
  • 4