No Reading from MAX30001 ECG Sensor Using nRF Connect SDK with Zephyr.

I'm currently working on a project using the nRF52840 board with the MAX30001 ECG sensor. I'm using nRF Connect SDK with VS Code version 2.6.1 to develop the project on Zephyr. I've configured the following pins for SPI communication with the MAX30001 sensor:

  • SCK: P0.03
  • MOSI: P0.28
  • MISO: P1.11
  • CS: P1.13

The sensor is supplied with 1.8V.

I attempted to use https://github.com/Protocentral/protocentral_max30001_zephyr_driver this driver file for my project.

I've verified the SPI read and write functions, and they appear to be working correctly. However, after flashing the code to the nRF52840 board, I'm not getting any meaningful readings from the MAX30001 sensor.


Observations:

  • When checking the FIFO register for reading, I receive a 24-bit value of 0x000037.
  • The ECG sample value obtained from the code is 0.0000 in decimal.

Steps to Reproduce:

  1. Set up the project on Zephyr using the nRF Connect SDK with VS Code version 2.6.1.
  2. Configure the SPI pins as mentioned above.
  3. Flash the code to the nRF52840 board.
  4. Observe the output from the MAX30001 sensor.
    ** Expected Behavior**
  • I expect to receive accurate ECG data from the MAX30001 sensor after flashing the code.

Actual Behavior

  • The FIFO register returns a 24-bit value of 0x000037.
  • The ECG sample value read from the sensor is consistently 0.0000 in decimal.

Additional Information

  • Hardware: nRF52840 board, MAX30001 sensor
  • Power Supply to Sensor: 1.8V
  • nRF Connect SDK Version: 2.6.1
  • Zephyr Version: 3.5.99

I am attaching code and the output I receive after flashing the code.

  1. My main file is as follows:
    #include <zephyr/kernel.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/sensor.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/logging/log.h>
    #include "max30001.h"

LOG_MODULE_REGISTER(app);

#define SAMPLING_INTERVAL_MS 6 // Time between samples in milliseconds

const struct device *const max30001_dev = DEVICE_DT_GET_ANY(maxim_max30001);

void main(void)
{
if (!device_is_ready(max30001_dev))
{
printk("MAX30001 device not found! Rebooting !");
// sys_reboot(SYS_REBOOT_COLD);
}
else
{
struct sensor_value ecg_mode_set;

	ecg_mode_set.val1 = 1;
	sensor_attr_set(max30001_dev, SENSOR_CHAN_ALL, MAX30001_ATTR_ECG_ENABLED, &ecg_mode_set);
}

while (1)
{
	k_sleep(K_MSEC(1000));

	// _max30001_read_ecg_fifo(max30001_dev, 6);
	struct sensor_value ecg_sample;

	// Fetch ECG data
	if (sensor_sample_fetch(max30001_dev) == 0)
	{
		if (sensor_channel_get(max30001_dev, SENSOR_CHAN_ECG_UV, &ecg_sample) == 0)
		{
			LOG_INF("ECG Data: %d %d", ecg_sample.val1, ecg_sample.val2);
		}
		else
		{
			LOG_ERR("Failed to get ECG data");
		}
	}
	else
	{
		LOG_ERR("Failed to fetch ECG sample");
	}
}

}

2.In the overlay file, I used the following:
&spi0 {status = "disabled";};
&spi1 {status = "disabled";};
&spi3 {status = "disabled";};
&pwm0 {status = "disabled";};
&i2c0 {status = "disabled";};
&i2c1 {status = "disabled";};

&spi2 {
clock-frequency = <DT_FREQ_M(8)>;
status = "okay";
pinctrl-0 = <&spi2_default>;
// pinctrl-names = "default";
cs-gpios = <&gpio1 13 GPIO_ACTIVE_LOW>;
max30001: max30001@0 {
compatible = "maxim,max30001";
status = "okay";
reg = <0x0>;
spi-max-frequency = <DT_FREQ_M(1)>;
//intb-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
// rtor-enabled;
ecg-enabled;
// bioz-enabled;
ecg-gain = <3>;
ecg-invert;
//ecg-dcloff-enable;
//ecg-dcloff-current = <1>; // 5 nA

};

};

&pinctrl {
spi2_default: spi2_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 3)>,
<NRF_PSEL(SPIM_MOSI, 0, 28)>,
<NRF_PSEL(SPIM_MISO, 1, 11)>;
};
};

spi2_sleep: spi2_sleep {
    group1 {
        psels = <NRF_PSEL(SPIM_SCK, 0, 3)>,
                <NRF_PSEL(SPIM_MOSI, 0, 28)>,
                <NRF_PSEL(SPIM_MISO, 1, 11)>;
        low-power-enable;
    };
};

uart0_default: uart0_default {
    group1 {
        psels = <NRF_PSEL(UART_TX, 0, 29)>;
    };
};

uart0_sleep: uart0_sleep {
    group1 {
        psels = <NRF_PSEL(UART_TX, 0, 29)>;
    };
};

};

3.In the prj.conf file, I included the following configurations:
#log
CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_LOG_BACKEND_RTT=y

#enble sensor
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_SENSOR_MAX30001=y

#mention this if you want to program in external board
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_BOARD_ENABLE_DCDC=n

CONFIG_CBPRINTF_FP_SUPPORT=y

  1. The output which i get after flash the code:
    MAX30001 ID: 52 0 0
    [00:00:00.200,439] SENSOR_MAX30001: Enabling MAX30001 ECG
    *** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
    [00:00:01.102,203] SENSOR_MAX30001: Enabling MAX30001 ECG...

[00:00:02.202,575] app: ECG Data: 0 0
[00:00:03.202,789] app: ECG Data: 0 0
[00:00:04.203,094] app: ECG Data: 0 0
[00:00:05.203,369] app: ECG Data: 0 0
[00:00:06.203,582] app: ECG Data: 0 0
[00:00:07.203,857] app: ECG Data: 0 0
[00:00:08.204,162] app: ECG Data: 0 0
[00:00:09.204,376] app: ECG Data: 0 0

Parents Reply Children
Related