Getting lower power consumption on Seeed XIAO nRF52840

I do not know the cause, but I have observed a phenomenon where the system reboots immediately after entering DeepSleep.
Removing the delay() line for LightSleep seems to avoid this phenomenon. Adding an external 3k3 pull-up resistor may also help.

I checked the Duracell CR2032 datasheet. nRF52840 requires about 7mA (1 sec) of current at startup and about 20mA when transmitting BLE. And the minimum VDDH of the nRF52840 is 2.5V.
Drawing a large current from a CR2032 will result in a voltage drop from 3V due to the internal resistance of a battery.
Considering also the 0.1V voltage drop of the 3.3V on-board regulator, the nRF52840 may not start normally if the battery voltage drops below 2.7V.
Care should be taken when using batteries other than LiPo.

NOTE:If a non-rechargeable battery is left connected to the battery pad and powered from USB, 4.2V will be applied to the battery and it will be charged, which is very dangerous.

1 Like

Try the code below. It worked for me.

  nrf_gpio_cfg_sense_input(PIN_WAKEUP, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);

  __WFE();  // wait for event
  __SEV();  // clear the internal register

  // Deep Sleep Mode
  NRF_POWER->SYSTEMOFF = 1;
1 Like

Thanks for you advice regarding the CR2032! Iā€™ll keep an eye on it! I always disconnect the battery before connecting it to USB. Now, regarding the remaining digital pins, I cycled through them as you suggested. I did it without deep sleep by using pinMode(,INPUT_PULLUP) because I found that this is already sufficient to increase the current from around 5ĀµA to above 30ĀµA (it is a 2 or 3 ĀµA variation day to day). It was only D2 that caused the current to increase. I tried it with a Li ion 18650 cell as well as the CR2032. The current is a bit higher with the Li ion cell (actually consistent with the higher cell voltage), but with both batteries the current increased by about 30ĀµA with pinMode(D2,INPUT_PULLUP). I made this simple sketch to rule out a mistake in the timing of taking the current reading.

//----------------------------------------------------------------------------------------------
// BSP : Seeed nRF52 Borads 1.1.8
// Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense 
//----------------------------------------------------------------------------------------------
// 2025/01/15

#include <Adafruit_SPIFlash.h>    // 4.3.4, NOTE:need to deleted /Documents/Arduino/libraries/SdFat
#include <flash_devices.h>

// for flashTransport definition
Adafruit_FlashTransport_QSPI flashTransport;
Adafruit_SPIFlash flash(&flashTransport);
static const SPIFlash_Device_t my_flash_devices[] = {P25Q16H,};
const int flashDevices = 1;

void setup()
{
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  digitalWrite(LED_BLUE, HIGH);
  digitalWrite(LED_RED, HIGH);
  digitalWrite(LED_GREEN, HIGH);

  // Enable DC-DC converter Mode
  NRF_POWER->DCDCEN = 1;            // Enable DC/DC converter for REG1 stage
  
  // on board Flash enter to Deep Power-Down Mode
  flash.begin(my_flash_devices, flashDevices);
  flashTransport.begin();
  flashTransport.runCommand(0xB9);  // enter deep power-down mode
  delayMicroseconds(5);             // tDP=3uS
  flashTransport.end();

  // Light Sleep Mode (RTOS delay function)
  delay(10000);

  while(true) {
    digitalWrite(LED_BLUE, LOW);
    delay(500);
    digitalWrite(LED_BLUE, HIGH);
    pinMode(D2, INPUT_PULLUP);
    delay(5000);
    pinMode(D2, INPUT);
  
    digitalWrite(LED_RED, LOW);
    delay(500);
    digitalWrite(LED_RED, HIGH);
    pinMode(D3, INPUT_PULLUP);
    delay(5000);
    pinMode(D3, INPUT);
  }
}

void loop()
{
  // nothing to do
}


@msfujino from your comment here on

#define PIN_WAKEUP (28)  // D0:(2), D1:(3), D2:(28), D3:(29), D4:(4)

can I conclude that I could also use not only D3, but also D0, D1 and D4 to wake up? Any special considerations. I donā€™t know where I got this from, but I have in mind that only D2 and D3 can be used for interrupts. I have three buttons and it would be nice if any of them would wake up the device from deep sleep, but I could live with just D3 (if it works without immediate restart, which Iā€™ll try next)

I think my devices are messing with me. I used the test sketch above on the one that I have already wired and I got 80ĀµA and 40ĀµA for D2 and D3, respectively. I desoldered the wires and got 5ĀµA in both cases. Maybe the other one is somehow damaged. But thatā€™s not all. I soldered about 30cm of wire (open end, completely insulated, not touching anything) on D2 and that caused the current to increase to 18ĀµA when D3 was in INPUT_PULLUP mode. The same thing happens with the wire on D3 and D2 in pullup mode, and soldering a wire to each increases the current even more. :exploding_head: At least that is consistent with the higher readings when it was wired. But why? :scream:

D0 to D10 can be used for wake-up pins.

1 Like

If I write pinMode(PIN_WAKEUP, INPUT_PULLUP); the current increases. I do not know why.
However, pinMode() does not need to be written to specify the wakeup pin, and the pin mode specification is included in the following:

rf_gpio_cfg_sense_input(PIN_WAKEUP, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_ SENSE_LOW);
1 Like

I had the pin mode in my code to read when the device is awake. I switched from D2, D3 and D4 to D3, D6 and D8, soldered the wires again and now I have 5ĀµA light sleep and 2ĀµA deep sleep and waking up worked as well. Beats me! Letā€™s hope it will stay that way even with the code that actually does something when awake! :crossed_fingers:

Hi there,

Excellent threadā€¦ if i might add, certain pins are only usable because the rtc ,Vcc keeps them alive in the silicon. The currents change also based on latched or pulse catching the interrupt register.

One reason the vcc is very important for wakeup and sleep. The week pullups aremeant to aliviate some of this AFAIK, Some config with a combo may keep it low and be more flexible.
My.02
HTH

GL :smiley: PJ :v:

Ahā€™ Iā€™m on mobile ,as im currently was locked out from the spam lock,BACK on.:v:

The ppk2 is a great help in measuring sleep currents and solving problems. It is a little expensive.
I suggest you research Sleep mode in the datasheet. If you have problems, please post them.

The on-chip pull-up resistor seems to be weak and sometimes wakes up on its own. Connecting an external pull-up resistor of about 3k3 is very stable. Sleep current does not increase either.

1 Like