non mbed, BSP versoin 1.1.8 have you tried 1.1.1 ?
do you know how to roll it back (select older one in boards)?
GL PJ
You’re close ,you’ll get there.
I have installed 1.1.1, but there is no change. The current is still at 10mA. Additionally, Adafruit_FlashTransport.h is no longer usable.
Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib wird verwendet
have now flashed another nRF52 board with the same code. On that board, the current drops to 0.01mA. I can’t explain why the other board does not go below 10mA.
Hi there,
Look for shorts to the can on that board, Magnifier from any of the pins. they are BLE’ versions NOT the Sense version with PDM mic on it?
GL PJ
I have a board that flew too close to the sun (battery mishap) it stays at 60ma. so
Hi
I just soldered 2Pins and the battery to the board. Everything works fine. (deepsleep dos not work fine )
Its like 2 Days old
they are BLE’ versions NOT the Sense version with PDM mic on it? on all boards I have bought…no
Hi there,
I’ve tested with this one , whenever I’m looking to save Power. usually les than 13 ua.
// Lowest power BSP 1.1.8 less than 20 ua.
// d:\Users\Dude\Pictures\ppk-LoPower_ Sketch_.png
//
#include "Adafruit_SPIFlash.h"
#include <nrf52840.h>
#define DO_WORK_PIN D2
#define SHUTDOWN_PIN D3
Adafruit_FlashTransport_QSPI flashTransport;
SemaphoreHandle_t xSemaphore;
bool gotoSystemOffSleep = false;
int work_LED_status = HIGH;
void setup()
{
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_RED, HIGH);
digitalWrite(LED_GREEN, HIGH);
digitalWrite(LED_BLUE, work_LED_status);
pinMode(DO_WORK_PIN, INPUT_PULLUP_SENSE);
attachInterrupt(digitalPinToInterrupt(DO_WORK_PIN), doWorkISR, FALLING);
pinMode(SHUTDOWN_PIN, INPUT_PULLUP_SENSE);
attachInterrupt(digitalPinToInterrupt(SHUTDOWN_PIN), shutdownISR, FALLING);
//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();
QSPIF_sleep();
xSemaphore = xSemaphoreCreateBinary();
// Flash green to see power on, reset, and wake from system_off
digitalWrite(LED_GREEN, LOW);
delay(1000);
digitalWrite(LED_GREEN, HIGH);
delay(1000);
digitalWrite(LED_GREEN, LOW);
delay(1000);
digitalWrite(LED_GREEN, HIGH);
NRF_POWER->DCDCEN = 1;
NRF_POWER->TASKS_LOWPWR = 1;
uint32_t dcdcen = NRF_POWER->DCDCEN;
//uint32_t tasks_lowpwr = NRF_POWER->TASKS_LOWPWR;
//Serial1.print("DCDCEN: 0x");
//Serial1.println(dcdcen, HEX);
//Serial1.print("TASKS_LOWPWR: 0x");
//Serial1.println(tasks_lowpwr, HEX);
}
void doWorkISR()
{
xSemaphoreGive(xSemaphore);
}
void shutdownISR()
{
gotoSystemOffSleep = true;
xSemaphoreGive(xSemaphore);
}
void loop()
{
// FreeRTOS will automatically put the system in system_on sleep mode here
xSemaphoreTake(xSemaphore, portMAX_DELAY);
if (gotoSystemOffSleep)
{
//Flash red to see we are going to system_off sleep mode
digitalWrite(LED_RED, LOW);
delay(1000);
digitalWrite(LED_RED, HIGH);
NRF_POWER->SYSTEMOFF=1; // Execution should not go beyond this
//sd_power_system_off(); // Use this instead if using the soft device
}
// Not going to system off sleep mode, so do work
work_LED_status = !work_LED_status;
digitalWrite(LED_BLUE, work_LED_status);
//Serial.println(" working");
}
void QSPIF_sleep(void)
{
flashTransport.begin();
flashTransport.runCommand(0xB9);
flashTransport.end();
}
getting this PPK power on battery…
here is the DUT…
HTH
GL PJ
Add the D2 D3 jumper to ground (touch) to switch modes, Work , and Power down.
Works well.
Power down average is 2.72uA.
Hi
Now everything works fine. Just one laste thing. I am using connection led but it will not shut off.
If the board is advertising and you shut the board in deepsleep the light stays on.
digitalWrite(XX, HIGH); dos not work.
Bluefruit.Advertising.stop(); no effect on the light.
void enter_deep_sleep() {
// Print a message before entering deep sleep
Serial.println("Entering deep sleep...");
pinMode(BUTTON_PIN, INPUT_PULLDOWN_SENSE); // Set the pin to pull-down and sense high level
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
delay(500);
Serial.println("Qspif");
Bluefruit.Advertising.stop(); // Stop advertising
delay(100);
Serial.end();
QSPIF_sleep();
// Enter deep sleep mode
//NRF_POWER->SYSTEMOFF=1;
sd_power_system_off();
}
It is not the lowest consumption if the led stays on.
edit:
Bluefruit.autoConnLed(true);
Bluefruit.autoConnLed(false);
found it
Hi everyone. This seems like great progress. I noticed however that still while the controller is not in deep sleep the Interrupts still consume extra power. If I was for instance broadcasting BLE Beacon data and I wanted to attach an interrupt on a pin. How would I go by not having the power usage increase?
Hi there,
So I read that some of the interrupt pins use more power if latched or if Edge vs, level for the interrupt to be generated there’s that and also if you use the pull up or pull down during sleep.
HTH
GL PJ
Hi everyone! I’m here looking for some advice because my Seeed XIAO nRF52840 are using 1.8 mA in deep sleep. I want to power them using coin cells so that’s a problem because I’d be using one up in a matter of days instead of several months.
I used the code by @PJ_Glasso to toggle between awake and deep sleep using two buttons and I tested it on all three devices. They are using 4.3 mA awake and 1.8 mA asleep. Before trying the button solution, I ran the code from this thread Sleep Current of XIAO nRF52840, Deep Sleep vs. Light Sleep and got the same result, except the first time I did it on the second device it only needed 8µA. I tested the third, which also needed 1.8 mA (actually 1.9 mA that day but that could just be the multimeter). When I went back to the second device it then also consumed 1.8 mA and does so ever since. I am not sure what’s going on there. What can I do to investigate the root cause? I am a decent programmer and have some knowledge of electric circuits, but when it gets down to electronics know-how that I read here by people that squeezed out the last microamps I am lost. I’ll do my best to follow but please dumb it down if possible.
My device information is the same as already given above:
UF2 Bootloader 0.6.1 lib/nrfx (v2.0.0) lib/tinyusb (0.10.1-293-gaf8e5a90) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7)
Model: Seeed XIAO nRF52840
Board-ID: Seeed_XIAO_nRF52840_Sense
SoftDevice: S140 version 7.3.0
Date: Nov 12 2021
I use the Arduino IDE and it shows up with the suffix Sense there for whatever reason.
Cheers, Daniel
Hi dt10,
The sketch in the link below should be able to reproduce the uA sleep current. Is your multimeter good enough to measure uA? Tell us about your experiment in detail. When did you say the current was 1.8mA, @PJ_Glasso’s sketch? Or @msfujino’s sketch?
Hi there,
and welcome here.
Pay attention to the BSP (board support package) and weather your using the non-mbed or mbed versions on the BSP’s. We use the power profiler to collect the power Info you see.
The Power Ninja @msfujino is the most experienced with this topic hands down.
So I can only add ," what he said"
take your time and read EVERYTHING you will get up to speed no problem. come here and post any questions,and code using the code tags above(</>) paste it in there, pictures hepl to, lots of very helpful smart people are present most days & nights
I have used coin cells on Xiao no problem. I like these cr-2450’s
they are a little fatter…(thicker).
HTH
GL PJ
FYI, there are things like shutting down or sleeping the external Flash also will lower the sleep number. It’s great hardware and sometimes the software dev lags but the user base holds it down and parallel devs like adafruit and nordic add to the knowledge base.
What is your end vision with this?
here is the latest from me…
Getting lower power consumption on Seeed XIAO nRF52840 - #59 by PJ_Glasso
Thank you both for getting involved! I get the same result from both @msfujino deep sleep and @PJ_Glasso post #59 sketches.
Here is my current setup. The board with the red LED that connects to the USB Li ion battery is a boost converter where I removed to outgoing USB port and put pins in its place. Sorry if this butchering of the board hurts your eyes, I suppose it does. I know I could directly go from the USB port of the battery, but due to the pins the boost converter was the easiest way for me to enable the current measurement without cutting up another USB cable*. To measure the current, for lack of better equipment, I used those two clips to connect the multimeter on the high side. I have to push buttons connecting to ground on D2 and D3 and ground and 5V on the respective pins, nothing else
…oh no, it says I can’t embed media!.. let me try dropbox links to the pictures… you’ll have to click them because it only shows those broken image icons, sorry about that!
Board support package, BSP, thanks for spelling it out for me! This is what I got. I hadn’t noticed that it picks the “Sense” by default, but I just repeated the measurement after selecting non-sense and it did not make a difference.
Daniel
*in case you are wondering what is going on there: I am using two of the XIAOs that communicate using BLE. After developing both sides of the code I used this boost converter with a CR2032 to test things. I made a rookie mistake in the BLE code and I think that drained the coin cell quickly. To prevent that for further testing, I put the USB C cable in place so that I can use that Li battery and keep using the pin strips. If you are thinking why on earth did he keep the boost converter, it’s because I also wanted to measure how much current it can provide because the data sheet said “500 to 600 mA” and I wanted to know.
Hi there,
Nah’ Looks like a WIP to me
You do what you can do, with what you got, No Shame in that game! (post limit will lift and you can post pics after a few posts, btw) I see the Dropbox files.
SO what I see is your NOT using the battery connections on the bottom of the Xiao? Why NOT?
All bets are off if you choose to not power it that way, the other methods require a diode and
other considerations and will NOT get the LOW numbers NO-WAY!
Yada, yada , Boooster , Buck converter it’s all been done before not a big deal.
(honestly I LOL because all the first attempts are like yours , me included and look this way…WRONG…LOL!)
the smaller CR2032 coin cells will get you 350-450 ma. run time current total then it’s down hill and done from there. I like the 2450 has more juice longer and supports more total power draw.
During the advertising phase of the BLE the Xiao uses the most current. so the Idea is do the (setup) heavy lifting for the connection right away and then go Sleep. “rinse and repeat”
mind you many optimisations can be made to the BLE connection parameters and settings to squeeze the max out of battery life.
In your code if you are using the Serial port or “while Serial” the port will wait until a USB cable is connected and the rs232 driver/rec 1488/89 are in MARK state and using 1.x ma. of current.
Have a look at the schematic for the Xiao and READ the Links to @msfujino
research on “System on SLeep”
BSP… Board Support Package there are two Mbed versions (2.9.1) & NON-mbed versions(1.1.1) to start with.
have you gone over this: ?
Are you SURE you read the Wiki?
Two Arduino Libraries
Seeed Studio XIAO nRF52840 assembles many functions in one tiny board and sometimes may not perform the best of them. Hence, Seeed has published two Arduino libraries to let it maximum the power of each function. Therefore:
- It is recommanded to use the
Seeed nRF52 Boards
library if you want to apply Bluetooth function and “Low Energy Cost Function”. - It is recommanded to use the
Seeed nRF52 mbed-enabled Boards
library if you want to use it in embedded Machine Learning Applications or apply “IMU & PDM advanced function”. - Both libraries support very well when it comes to the basic usage, such as LED, Digital, Analog, Serial, I2C, SPI.
The Pin definition supported by these two libraries might be a little different and Seeed will keep update the wiki until it is clear.
Stop and take the time to RTFM is the best advice your close but your missing the basic understandings it will clear it up or generate the right questions to help you.
then you can get these:
LINK
HTH
GL PJ
Hi PJ!
Yes, of course I read the getting started, down to the battery charging which is not something I plan to do. I would not have known how to get it running in the first place without it.
Why not the battery pins? I, as I now know mistakenly, thought I can just as well use the pins for that purpose and since I already did the pin strips I went with that. I just soldered wires to the battery pins and now it’s working. When it wakes up I briefly see 100-something µA on the multimeter before it settles to 18 µA. In sleep mode I get 3.5 µA, so both readings agree well with your detailed measurements. Thanks PJ!
I am looking forward to merging this with the BLE code and the ADXL345 (to wake up the device due to being used) and see how low I can go. I am sure there will be some more surprises along the way but the individual parts are working. If I had realized there’s a version with motion sensors I would have bought that one. My ADXL345 board requires about 60µA, which isn’t great but if I manage the interrupt wake up working with the 1Hz or 8Hz sleep mode I hope this will go down. The BLE part is only notifying values at the push of buttons. Measurements will tell, but I think I did a reasonable job there.
Thanks again!
Daniel
Thinking about it, maybe I won’t even need the motion wake-up on this side of the BLE communication. If I can make it wake up on pushing the button and then notify it would be sufficient. I already see myself programming half the weekend
Ok, now that wasn’t the most productive weekend, or Monday. I still tried the motion sensors to determine when it is time to go to sleep and when to wake up together with BLE communication because I have other uses for it. It took some time, but it worked nicely. Nevertheless, for such a coin cell powered application where all I want to do is (briefly) send which button has been pushed when one is pushed and then go back to sleep, I wanted to do wake up → advertise (specifically a beacon where I placed the button number) → return to sleep after a prescribed time has passed. But I had not considered an important aspect of deep sleep, which is that on waking up it starts all over. It’s probably plain that I am relatively new to all this, but what I learned about using interrupts was that they are supposed to communicate to the main code using volatile variables. That doesn’t work in the waking up scenario when it starts from a reset. So my question is, is there a way to determine that the device woke up due to an external interrupt and where it came from? I searched but I didn’t find an answer (or did but failed to realize it). Because if there isn’t, I will have to try my luck with system ON sleep. I already read the thread today and found that my battery pins mistake was actually discussed there.
Regards,
Daniel
Hi there,
So i think take a look at the Technical reference guide for the Nrf52 part. I’m sure it is addressed in there, the other is using the Flash memory to tell the boot count and if it is awake, Also there is a wakeup Stub that runs a certain setup stub when waking up, AFAIR
also, You wouldn’t know if the advertisement is seen or not too that way I would look for another method with a Notify or some feedback, that way you can maximize your sleep counter and not wake premature to being required to (sensor update or x?). if that makes sense
HTH
GL PJ
All of it is GOOD stuff
I read a couple of things at Nordic but I concluded that this is too advanced for me right now. I only started with an Arduino starter kit a bit more than a month ago and still lack the level of knowledge about what is going on “behind the scenes” to make sense of what I read there. Until I feel confident that there is a good chance of success making this work, I will use the system ON sleep! This gives me 22 µA while waiting and about 130µA for a second when advertising at the push of a button. That gives me about a year from a CR2032. Crazy! I may even add deep sleep after an inactivity period and use an initial button press as an on-switch and it will last years.
On the scanning end, I have deep sleep with ADXL345 wakeup (and a 18650 battery so power is not really a huge concern). This has become obselete because my ADXL345 board needs 60µA, so I would be better off with system ON sleep. At least I learned something while developing it!
About the BLE, the beacon worked in testing. I can revisit more elaborate communication if I turns out to be unreliable in practice. I already have done it before using notify in code that I derived from the custom_hrm example. I will revisit that if I am not satisfied with the performance regarding a quick succession of button events. But first, onto the next problem. I have two buttons working, but I might like to have three and there’s only two straightforward interrupt pins. After this I draw a line!