I confirmed with a test that NRF_POWER_MODE_LOWPWR is the default once in the setup loop, so no need to explicitly enabled this. When I turned on constant latency mode the idle loop power increased to 377uA.
I also found that the DC/DC converter is NOT enabled by default. This does not impact the idle mode power, however, this does impact the advertising and connection power. I didn’t test this directly, but the online power profiler linked above shows significant savings with the DC/DC converter enabled.
Looks like the proper call to enable the DC/DC converter with the soft device is: sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
I picked up a sense and played around with the accelerometer. If you’re still looking for accelerometer info I posted some info here: Xiao Sense Accelerometer Examples and Low Power. Seemed complicated enough to be its own topic.
I’m trying to make a datalogger for a bucket rain gauge.The rain is filling the bucket. When the bucket is full, it is turning and triggering a contact with a magnet. One have to record the contact with timestamp. I’m using BLE for initial configuration (including time) and to retrieve data. So, most of the time, BLE is off and I will start it by pushing a button.
Now, I’m trying to use the XIAO nRF52840 without Sense. Non-mbed version 1.1.1. Current is measured on a 18650 LiPo connected to Bat’s pins.
Blink using delay in the main loop (when LED off): 21 µA
Blink with timer/callback and suspendLoop() : 21 µA
same as previous + attachInterrupt(raingaugePin, raingauge_callback, ISR_DEFERRED | FALLING) : 38 µA
Why such an increase? Can I minimize it?
@daCoder , I have questions on what you proposed. In your code with semaphore, you are using System Off Sleep. I think I can’t use it because I need to preserve timing function. I’m using xTaskGetTickCount(). Is my high power consumption increase related to high accuracy gpio management? Should your low accuracy version of the interrupts library improve this?
This video has good background on different options for low power measurements. I bought a Nordic PPK II based on the info. I notice many on this site using the same.
I believe you are correct. My understanding is that timers are not active during system_off. You would want to spend most of the time in system_on sleep which would happen if you pend on a semaphore, use suspendLoop(), or spend most of the time in the delay() call.
I was seeing a 12uA increase in power usage when using attachInterrupt. That would explain at least some of the 17uA increase you are seeing. You could save this by using the custom interrupt code posted above. However, is it worth it for your use case? With a 18650 and 38 uA of current draw, I think you get many years of battery life. Extreme power savings makes more sense if you are using something like a coin battery.
If you are looking for extreme power savings, you might look at your circuit and sketch for your initial case. You should be able to get an initial baseline of < 5uA (I saw 3uA) with the LED off and in a delay() call. Maybe bluetooth isn’t fully disabled.
Concerning my project, I will also have a second button to trigger BLE and the corresponding attachInterrupt is adding 20 µA again (although I may not attach interrupt but rather check if button is pressed each 10 s while blinking my status LED). My target is a 3 years autonomous operation. I don’t want to use LiPo/18650 that is too big and has a self discharge of 70 µA at room temperature. Coin battery would be my ultimate goal. CR2032 capacity is 210 mA.h. Corresponding current target would be 8 µA. Not so far but still difficult to reach. (I didn’t switched the QSPI off up to now). I may end up with LiSOCl2 battery. Capacity is of 2400 mAh and 1200 mAh for AA and 1/2AA resp. Corresponding target currents are 90 µA and 45 µA resp.
I used your custom library but my bucket interrupt is no more triggered.
I still have questions!!! You are presenting 5 tests (or more if incl. default interrupt manager) but only one code. To which test is related the presented code? (that include both semaphore and system off sleep ). Can you show the code for Main loop with delay?
The sketch is showing the semaphore version and demonstrates both system_off sleep and system_on sleep. The measurements using the delay() call were made by replacing the semaphore call with delay. The system is in system_on sleep while blocking on the semaphore or in the delay call. You know it is in system_on sleep because the state of the blue LED is persisted over time and the LED toggles each time you press the appropriate button. Pressing the other button puts the system into system_off sleep. Subsequent button presses wake the system from system_off sleep with an almost fresh boot (the state of the blue LED is lost.)
With the sketch above and no custom interrupt code, there are two measurable states:
system_on: 15uA (loop is blocked on the semaphore)
system_off: 1uA
I think you just need to replace the xSemaphoreTake() with a delay() call to duplicated the other test cases. The sketch should function as before, however, there is potential latency in responding to the button press.
It is possible that the libraries have changed affecting the power usage or the functionality of the interrupt code. Over the next couple of days, I will bring up the above code again to see if any changes.
@daCoder Do you know how to adjust the low power in mbed os version. I try System on mode and only can get roughly 700uA, but on the nrf52840 datasheet, it says 3uA. Do you have any experience for that
@Hao_Liu I don’t have experience with the mbed version. I saw ~3uA on both Zephyr and non-mbed Arduino. I expect the process to get low power and the final result should be similar with the mbed version.
@daCoder Do you already achieve 3 uA in systemOn mode on a non-mbed Arduino? Right now, I can only achieve roughly 260 uA. I am wondering if this value is still too high or is caused by the Mbed library. Do you have any ideas?
@Hao_Liu I recently upgraded the board library to a more recent version, so I retested. Here is the code I ran: deep_Sleep3.zip (1.2 KB)
I started with my zephyr build which in non-Arduino. I know this hadn’t changed and I measured 2.9 uA during system_on as before.
I then tested the attached arduino code and measured 15.17uA during system_on. This is using the default Arduino interrupt code. Next I replaced WInterrupts.c as described earlier in the post. This time I measured 3.97uA in system_on and 2.1uA in system_off. Not sure were the extra 1uA came from in system_on, but 3.97uA is still good.
Have you tried running the non-embed code that is posted? If not, I suggest running the posted non-embed code and make sure you achieve the same results. This would help rule out measurement issues or HW issues.
I’m using 1.1.3 “Seeed nRF52 Boards”. (I remember having to manually install two missing libraries.)
Adafruit SPI Flash 4.1.3
I run with a PPK2 at 3.0 volts. Sometimes I run with a CR2032 and just use the PPK2 to measure.
I always remove the USB cable and do a complete power removal to make sure the board is truly reset.