XIAO BLE drawing 570uA with Zephyr

I'm working on a project where we're planning to use XIAO BLEs on an OpenThread network, for that we need very low power consumption. I've been trying samples to get low consumption to verify we can use the XIAO on our project, however I just cannot get to lower the consumption on it.

I've been doing multiple tests on different codes, I've tried stuff on the nrf52840DK that uses around 6uA with nrfOnly moded, which is great, but the same code (for example the blinky)  on the XIAO consumes around 550uA. I've also used system_off with the same results, as well as some code some other fellows have posted on other threads.

When I tried sleeping the device using Arduino/bluefruit I was really happy yo see around 22uA consumption on the XIAO, however it just doesn't transfer when using Zephyr projects.

Here's my blinky (with the light off)

/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)

/*
 * A build error on this line means your board is unsupported.
 * See the sample documentation for information on how to fix this.
 */
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);

void main(void)
{
	// int ret;

	// if (!device_is_ready(led.port)) {
	// 	return;
	// }

	// ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
	// if (ret < 0) {
	// 	return;
	// }

	while (1) {
		// ret = gpio_pin_toggle_dt(&led);
		// if (ret < 0) {
		// 	return;
		// }
		k_msleep(SLEEP_TIME_MS);
	}
}

And my prj.conf

CONFIG_GPIO=n
CONFIG_PM_DEVICE=y
CONFIG_SERIAL=n
# nRF board library
CONFIG_DK_LIBRARY=n
#FIX DEL DTS
CONFIG_USB_DEVICE_STACK=n
#LOW POWER CONFIGURATION RELATED
# #Power management
CONFIG_PM=y

Is there anything I'm missing? any XIAO or Zephyr specific configuration I might be missing?

  • Hi,

    There is nothing that sticks out here, and you have disabled serial (logging) which is what I would check first. Which target board do you build for? Can you share the board files? Perhaps you enable something there?

    Also, what about the HW? Have you added anything to the module? Or perhaps the module has an onboard regulator that consumes some power or something else?

  • Thank you for the reply

    I've used the target board xiao_ble, the only thing i've changed in the files is this line

    CONFIG_SERIAL=n

    Here's the complete file (apologies if its not the ones you're asking, I'm still kind of new)

    xiao_ble_defconfig

    # SPDX-License-Identifier: Apache-2.0
    
    CONFIG_SOC_SERIES_NRF52X=y
    CONFIG_SOC_NRF52840_QIAA=y
    CONFIG_BOARD_XIAO_BLE=y
    
    # Enable MPU
    CONFIG_ARM_MPU=y
    
    # Enable hardware stack protection
    CONFIG_HW_STACK_PROTECTION=y
    
    # enable GPIO
    CONFIG_GPIO=y
    
    # enable uart driver
    CONFIG_SERIAL=n
    
    # enable console
    CONFIG_CONSOLE=y
    
    # enable USB
    CONFIG_USB_DEVICE_STACK=y
    
    # Build UF2 by default, supported by the Adafruit nRF52 Bootloader
    CONFIG_BUILD_OUTPUT_UF2=y
    CONFIG_USE_DT_CODE_PARTITION=y
    
    # additional board options
    CONFIG_GPIO_AS_PINRESET=y
    
    CONFIG_PINCTRL=y

    xiao_ble.dts

    /*
     * Copyright (c) 2022 Marcin Niestroj
     * Copyright (c) 2022 Peter Johanson
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /dts-v1/;
    #include <nordic/nrf52840_qiaa.dtsi>
    #include "xiao_ble-pinctrl.dtsi"
    #include "seeed_xiao_connector.dtsi"
    
    / {
    	model = "Seeed XIAO BLE";
    	compatible = "seeed,xiao-ble";
    
    	chosen {
    		zephyr,console = &usb_cdc_acm_uart;
    		zephyr,shell-uart = &usb_cdc_acm_uart;
    		zephyr,uart-mcumgr = &usb_cdc_acm_uart;
    		zephyr,bt-mon-uart = &usb_cdc_acm_uart;
    		zephyr,bt-c2h-uart = &usb_cdc_acm_uart;
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &code_partition;
    		zephyr,ieee802154 = &ieee802154;
    	};
    
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;
    			label = "Red LED";
    		};
    		led1: led_1 {
    			gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
    			label = "Green LED";
    		};
    		led2: led_2 {
    			gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
    			label = "Blue LED";
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    		};
    	};
    
    	/* These aliases are provided for compatibility with samples */
    	aliases {
    		led0 = &led0;
    		led1 = &led1;
    		led2 = &led2;
    		pwm-led0 = &pwm_led0;
    		bootloader-led0 = &led0;
    		mcuboot-led0 = &led0;
    		watchdog0 = &wdt0;
    		spi-flash0 = &p25q16h_spi;
    	};
    };
    
    &adc {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	current-speed = <115200>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &i2c1 {
    	compatible = "nordic,nrf-twi";
    	/* Cannot be used together with spi1. */
    	status = "okay";
    	pinctrl-0 = <&i2c1_default>;
    	pinctrl-1 = <&i2c1_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &pwm0 {
    	status = "okay";
    	pinctrl-0 = <&pwm0_default>;
    	pinctrl-1 = <&pwm0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &spi0 {
    	compatible = "nordic,nrf-spi";
    	/* Cannot be used together with i2c0. */
    	status = "okay";
    	pinctrl-0 = <&spi0_default>;
    	pinctrl-1 = <&spi0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &spi3 {
    	status = "okay";
    	pinctrl-0 = <&spi3_default>;
    	pinctrl-1 = <&spi3_sleep>;
    	pinctrl-names = "default", "sleep";
    	cs-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
    	p25q16h_spi: p25q16h@0 {
    		compatible = "jedec,spi-nor";
    		reg = <0>;
    		wp-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    		hold-gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
    		spi-max-frequency = <104000000>;
    		jedec-id = [85 60 15];
    		sfdp-bfp = [
    			e5 20 f1 ff  ff ff ff 00  44 eb 08 6b  08 3b 80 bb
    			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
    			10 d8 08 81
    		];
    		size = <16777216>;
    		has-dpd;
    		t-enter-dpd = <3000>;
    		t-exit-dpd = <8000>;
    	};
    };
    
    &ieee802154 {
    	status = "okay";
    };
    
    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		sd_partition: partition@0 {
    			label = "softdevice";
    			reg = <0x00000000 0x00027000>;
    		};
    
    		code_partition: partition@27000 {
    			label = "code_partition";
    			reg = <0x00027000 0x000c5000>;
    		};
    
    		/*
    		 * The flash starting at 0x000ec000 and ending at
    		 * 0x000f3fff is reserved for use by the application.
    		 *
    		 * Storage partition will be used by FCB/LittleFS/NVS
    		 * if enabled.
    		 */
    		storage_partition: partition@ec000 {
    			label = "storage";
    			reg = <0x000ec000 0x00008000>;
    		};
    
    		boot_partition: partition@f4000 {
    			label = "adafruit_boot";
    			reg = <0x000f4000 0x0000c000>;
    		};
    	};
    };
    
    zephyr_udc0: &usbd {
    	compatible = "nordic,nrf-usbd";
    	status = "okay";
    
    	usb_cdc_acm_uart: cdc-acm-uart {
    		compatible = "zephyr,cdc-acm-uart";
    	};
    };

    I saw a someone with the exact same issue but no solution in a different post.

    About HW, I have been using the bare retail xiao, sometimes an expansion board for ease of flashing but when measuring consumption just the bare board, the expansion board ends up consuming like 2mA, just the Xiao consumes around 550 or 570uA.

  • Hi

    I see. Please make sure to also set CONFIG_CONSOLE=n.

  • Just did this and it actually got higher to 617uA which is weird, will try to mess with other settings as well.

  • That is strange. Can you upload the .config file under zephyr in your build folder? There we can see what is actually enabled.

Related