You must use version 1.0 (Adafruit) of the firmware in the Arduino IDE. Looks like your board variant file is not what the demo program is looking for.
Makes sure you have a softdevice installed (should be shipped that way)
Use this on top of the code before setup():
#include <Arduino.h> #include <bluefruit.h>
Use this in the loop() sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
__WFE();
__WFI();
sd_app_evt_wait() ; //SOFT DEVICE “SYSTEM ON” POWER SAVE
Hi, were you able to use ArduinoBLE library with the Seeed nRF52 mbed-enabled Boards version 1.0.0? I am having trouble running the library now as it shows I have other missing libraries in the include section of the ArduinoBLE library
C:\Users\XXXX\Documents\Arduino\libraries\ArduinoBLE\src\utility\HCICordioTransport.cpp:23:10: fatal error: mbed.h: No such file or directory
23 | #include <mbed.h>
| ^~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Seeed XIAO nRF52840 Sense.
@hichiaty & @turing-complete-labs, how did y’all manage to get down to 3-5uA ?? With sd_power_system_off(), it only reaches around 20uA for me (and some other folks here in this thread). I am using regular (not Sense) Xiao BLE.
We have now discarded the original XIAO BLE on-board package (as you experienced, it was very confusing). Some time ago, we updated the new XIAO BLE on-board package. You guys can update the on-board package according to our wiki.
We divided into two XIAO BLE on-board packages, their application scope is different, we have marked which on-board package should be used in front of each case, you can then refer to the content of XIAO BLE low-power mode using the new on-board package to retry again.
After messing around with the board for most of today I can share how to get the power down to a sensible level. I am currently at ~2uA in deep sleep, 3-4uA in light running (e.g. suspendLoop or delay).
Everyone who was stuck at ~20uA, the problem is there is a QSPI flash chip (P25Q16H) that remains powered when powering down the NRF and does not go into deep sleep itself. This flash chip sits there and draws ~18uA all the time. To put it into deep sleep you need to send the command 0xB9 to it.
#include <Adafruit_FlashTransport.h>
Adafruit_FlashTransport_QSPI flashTransport;
//start bluefruit (this also starts the soft device if you don't start the sd then none of your sd_* calls will do anything
Bluefruit.begin();
//before you put the NRF to sleep put the flash to sleep
flashTransport.begin();
flashTransport.runCommand(0xB9);
flashTransport.end();
//map a pin for wakeup
nrf_gpio_cfg_sense_input(g_ADigitalPinMap[D3], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
//shutdown
sd_power_system_off();
This will leave the flash in deepsleep next time you wake up the NRF, the command from the data sheet to turn it back on is 0xAB but I haven’t played with it yet. I used the adafruit sdfat fork to send in the qspi commands as it is much simpler than interfacing with the qspi hardware directly.
Excellent! Thank you. I was ok with 20uA for my project, but I am excited that maybe I am able to use the QSPI for persistent memory. I need to change a value of a variable and make that changed variable available after a hard reboot. I think I found a complicated work-around, but using the QSPI would be much better. Any suggestions for the Arduino IDE? I do not use Python.
Amazing power optimisation there! Kudos for figuring that out in the absence of documentation.
Keen to understand what’s required.to reactivate everything.
Game changer!
I don’t use python either, not sure what you mean, my example code is in C? Anyway I used platformio but if you insist on arduino ide then just install the adafruit sdfat fork library as I suggested.
A further deep sleep discovery. The NRF gpio pin config registers persist through deep sleep, this is so you can setup pin states the are retained whilst deep sleeping.
When you use a GPIO via the arduino core, e.g. pinMode(x, INPUT), the pin state is changed to input direction AND the pin is connected to the NRF GPO input buffer. This connection to the input buffer seems to draw ~6uA per pin. The default state of an NRF pin is DISCONNECTED but you cannot use the arduino pinMode() function to put the pin back into this state having previously used it as an input.
The solution is to do it yourself, you can either set the pin state back to default using:
I haven’t done any testing of pins put into OUTPUT state but these will continue to draw whatever power they were drawing before deep sleep, I discovered the above issue/solution when attempting to disable pins (by setting them to INPUT) when not in use.
Hi,
I patched Circuitpython source for QSPI deep sleep with power consumption 3.6 uA in 5s loop.
From Nano_BLE_MCU-nRF52840_PS_v1.1.pdf datasheet 5.2.1.1 Sleep : ION_RAMON_RTC System ON, full 256 kB RAM retention, wake on RTC(running from LFRC clock) 3.16 μA