High current consuption using BME280 on Seeed Xiao BLE (nRF52840) in Zephyr RTOS

Hi,

I'm developing an IoT product using nRF52840 provided by Seeed (Xiao BLE) with a BME280 sensor connected via I2C on a custom PCB, without another peripheral that BME280 and passive components for I2C connection. I can't get low power consumption, even if I try the system_off Zephyr example.

When I try the bme_280 example of Zephyr and enable the PM/PM_DEVICE features, the consumption is still so high (about 1mA). I need that it consumes a few hundred uA . An strange ripple between BME280 measurements is seen when I measure current using PPK2:

  • My config file:

-

CONFIG_SENSOR=y
CONFIG_PM=y
CONFIG_PM_DEVICE=y

  • I2C circuit Diagram (VCC=3V3):

  • Overlay file:

&i2c1 {
	status = "okay";
	bme280@76 {
		compatible = "bosch,bme280";
		reg = <0x76>;
	};
};

  • Zephyr version: 3.2.99
  • nRF Connect version:2.3.0

I also tried:

I don't know what can I try.

Thanks

  • Hi Jared,

    I'm using Zephyr API to measure each 15 min battery level:

    int adc_init(void)
    {
    	int err;
    
    	gpio_pin_configure_dt(&vbat_pin, GPIO_OUTPUT);
    
    	if (!device_is_ready(adc_chan7.dev))
    	{
    		printk("ADC controller device not ready\n");
    		return -EINVAL;
    	}
    
    	err = adc_channel_setup_dt(&adc_chan7);
    	if (err < 0)
    	{
    		printk("Could not setup channel (%d)\n", err);
    		return err;
    	}
    }
    
    uint8_t get_battery_level(void)
    {
    	uint8_t err;
    	int16_t buf;
    	struct adc_sequence sequence = {
    		.buffer = &buf,
    		/* buffer size in bytes, not number of samples */
    		.buffer_size = sizeof(buf),
    	};
    	double vbat;
    
    	int32_t val_mv;
    	(void)adc_sequence_init_dt(&adc_chan7, &sequence);
    
    	err = adc_read(adc_chan7.dev, &sequence);
    	if (err < 0)
    	{
    		printk("Could not read (%d)\n", err);
    		return 1;
    	}
    	/* conversion to mV may not be supported, skip if not */
    	val_mv = buf;
    	err = adc_raw_to_millivolts_dt(&adc_chan7,
    								   &val_mv);
    	if (err < 0)
    	{
    		printk(" (value in mV not available)\n");
    		return 1;
    	}
    	else
    	{
    		vbat = val_mv * (1510.0 / 510.0); //Resistive divider
    		uint8_t bat_level = (vbat - VBAT_MIN) * 100 / (VBAT_MAX - VBAT_MIN);
    		return bat_level;
    	}
    }

    Has nrfx driver power management implementation? Or can I fix it with a workaround in Zephyr?

    Thanks

  • Hi,

    jelsesser said:
    Has nrfx driver power management implementation?

    No not quite, but you can easily disable the peripheral by calling the un init function. Unfortuantly, the Zephyr API lacks this kind of function which makes it difficult to disable the peripheral.

    regards

    Jared

  • Ok Jared, I'll try ASAP with the uninit/init funciton (I guess that I will use SAADC driver functions, because of NRF52840 has not ADC peripheral), instead of using Zephyr API, then I'll back with news.

    Maybe this is an opportunity to propose PM improvements in Zephyr API, I'll try it later.

    Regards

    Julian 

  • Hi, I'm back with news. 
    I could solve it for Seeed Xiao, using SAADC NRFX drivers, and was not necessary to use the uninit() function, provided by SAADC NRFX driver:

    	status = nrfx_saadc_init(NRFX_SAADC_DEFAULT_CONFIG_IRQ_PRIORITY);
    	if (status != NRFX_SUCCESS)
    	{
    		LOG_INF("SAADC init failed: %d\n", status);
    	}
    	else
    		LOG_INF("SAADC init successful");
    
    	status = nrfx_saadc_channel_config(&saadc_channel);
    	if (status != NRFX_SUCCESS)
    	{
    		LOG_INF("SAADC config failed: %d\n", status);
    	}
    	else
    		LOG_INF("SAADC config successful");
    	uint32_t channels_mask = nrfx_saadc_channels_configured_get();
    	status = nrfx_saadc_simple_mode_set(channels_mask,
    										NRF_SAADC_RESOLUTION_12BIT,
    										NRF_SAADC_OVERSAMPLE_DISABLED,
    										NULL);


    And here is the PPK2 trace, with low power consumption during SAADC standby:



    For some reason, Zephyr RTOS ADC API not manage well power consumption.

    Thanks a lot!!

Related