Seeed XIAO BLE Sense nRF52840 deep-sleep mode

Hi Vint1k,
Please read the link below.

1 Like

@msfujino, thank you for help.
I copied your code and attempted to activate deep sleep mode, and it worked!
However, I may have made a mistake because when I took measurements, the current was around 700 μA.
Based on your comparison, the current should be around 5-25 μA, which is ten times lower.

I have one more question for you.
If I enable deep sleep mode, how can I wake up the device? I’ve read something about GPIO, but as a beginner, I don’t really understand how to implement it.
I have a button. Is it possible to wake up my device by pressing this button?

Hi there,
So which BSP files did you use? that makes it better on order of magnitude. Embed andNON-mbed
the first line of the compiler output will tell you if you’re not sure which board you picked, there’s two choices same MCU (currently non-mbed is Ver. 1.1.8 the embed one is 2.9.2.) the most power saving was with the first one NON-embed.
HTH
GL :slight_smile: PJ

1 Like

Hi again.
Here is the output when compiled:


As far as I understand, I currently have non-mbed. And you say that this BSP is the most efficient in terms of energy saving mode. It seems like there’s something wrong with my board…

Hi there,
Yes I believe, all the Power is saved mostly in BSP 1.1.1 Try roll back and measure again.
HTH
GL :slight_smile: PJ

I tried to roll back to version 1.1.1.
At first I encountered an error saying that the file “Adafruit_SPIFlash.h” was not found.
Next, I installed the “Adafruit SPIFlash” library and encountered the following error:


I suspect that I also need to install not the latest version of Adafruit SPIFlash. Which one then?

upd. I rolled back this library to version 4.0.0 - the current consumption became 80 MILLIamperes. So many. I never had this before, even without a sleep schedule…

Hi there,
If you look at the demo I posted for the Grove Expansion Board on here, there is the Compiler output that shows which version, Pretty sure it’s the latest , but check it out for the correct implementation of it.
I put the flash params in the code as opposed to having the .h flash conf_file.
HTH
GL :slight_smile: PJ

1 Like

I re-measured it under the following conditions and it sleeps without problems.

//----------------------------------------------------------------------------------------------
// BSP : Seeed nRF52 Borads 1.1.8
// Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense 
//----------------------------------------------------------------------------------------------
// 2024/02/14

#include <bluefruit.h>          // 1.10.0  /Arduino15/packages/Seeeduino/hardware/nrf52/1.1.8/libraries/Bluefruit52Lib/src
#include <Adafruit_SPIFlash.h>  // 4.3.1 or earlier   Need to be deleted /Documents/Arduino/libraries/SdFat

When connected to USB, charging current is observed, but 80mA is not charging current?

2 Likes

Hi there,
That’s GREAT! thanks msfujino… Progress :+1:
GL :slight_smile: PJ
I had initially between 60ma and 80ma with BLE & Flash and external darlington mosfet driver for a solenoid on my rev 1 pc board. that’s high(80ma) on any planet…

Hi there.

Firstly, thank you so much for your assistance.
How do I measure current? I upload the sketch to the Arduino board via USB cable in ArduinoIDE, then disconnect the board from the computer and connect it to a power source (approximately 6V DC). Here is the electrical circuit:
Без имени
Next, I simply measure the current with a regular multimeter (I sent a photo of how I measure the current just above).
But now it seems that I’ve burnt out the multimeter, as it no longer measures milli- and microamps.

Therefore, I am unable to check the current now (using the versions of the libraries that msfujino provided).
msfujino, how do you measure the current?

I truly aim to achieve a current around tens of microamps!

I use pppk2.
Power Profiler Kit II - nordicsemi.com

1 Like

Hi there,
Best money ever spent, Does so much more than just measure and log power, sources it , sinks it, and has built in mini logic probes…Allows you to visualize Signals and Power consumption as it relates to Code development. :wink: :ok_hand:


one of theses…

HTH
GL :slight_smile: PJ

also while we are here, The $10 nordic Dongle is the best BLE test tool available. (and it’s programable)


all of it works from the Nrf_Desktop app… download it Awesome

1 Like

Thank you.
Already ordered Nordic Dongle, and ppk2.
I’ll test it. As far as I understand, the Nordic Dongle will need to be programmed using the nRF Connect SDK?
There will also be questions regarding deep sleep…)

Hi there,
The Nrf_desktop app , will recognize the device and drop code on it for the tool needed.
You don’t do anything but confirm… :+1: Works really Great!
HTH
GL :slight_smile: PJ

1 Like

Thank you, you help me a lot!
If you allow me, I’ll ask one more question.
According to my plan, the device should connect via Bluetooth (probably BLE) to a mobile phone. And I want to be able to upload a new sketch (in fact, a firmware update) to the board from my mobile phone. Is this possible?
(I’m talking about the Seeed XIAO BLE Sense nRF52840 device now)

Hi there,
Yes Under certain Circumstances.
You need to put it into Bootloader Mode (usb-C) or Use a form of BLE OTA (Over the Air Update)
The later is somewhat restrictive, over the air.
The sketch would be in the form of a u2f file or Hex
Check the Over the Air updates threads for Nordic also, You set aside an area in Flash to drop the bin onto then it reboots to that, not sure if it’s permanent (lost at next power cycle?) update unless you do something b4 hand.
HTH
GL :slight_smile: PJ

AFAIK, there is a working example in the Nrf_SDK , but I may be wrong.

1 Like

First of all, I am very grateful to you for trying to help me.
I explain the situation I am in. I’m now trying, firstly, to understand what to use: it’s either Arduino or nRF SDK / nRF Connect.
I need to find a suitable option, taking into account my wishes:

  • Possibility of realizing deep sleep with a consumption of less than 100 microamps.
  • Ability to update firmware via Bluetooth Low Energy from a mobile phone.
  • Ability to connect and work using the Ant+ protocol.
  • Ability to work with third-party devices (in my case, with the AS5600 magnetometer).

I’m new to this topic. As far as I thought to myself before, there will be fairly simple examples for each point that will help me decide, and so on.
But even with the first point (deep sleep), I already had problems. No matter how hard I try, repeating all your actions, I cannot achieve a consumption of 100 μA or less.
I asked a question regarding Ant+ in a separate topic, to which you answered that I needed to use OTA downloading, but I didn’t get any really working measurements.
There are no problems with AS5600 on Arduino, but when it comes to nRF connect / nRF SDK, I’m sure I’ll have to “reinvent the wheel.”

Now let me get to the heart of the matter.
Is this really such an unexplored topic that there are no ready-made solutions, examples, or tips?
As an example, uploading the S340 to Seeed Sense - I’m sure I’m far from the first to do this. Is there really no step-by-step instructions on how to download? (this is for Ant+)
Or, for example, an OTA update - I started reading, but there is not a single ready-made example.

Don’t get me wrong, I really appreciate the time allocated for me, but, unfortunately, I haven’t found any specific solutions for myself. I will be EXTREMELY GRATEFUL if you find a solution for me on Arduino for at least one of the above points. And yes, I’m currently considering Arduino as my main option, so please don’t suggest nRF connect to me. If I understand that it is difficult to implement this on Arduino, but easier on nRF connect, then, of course, I will switch. But you understand me, I cannot implement some of them this way and some of them differently. I need to implement everything on one framework.

I’m even willing to pay if people help me with ready-made codes and IDE settings that solve at least one of the listed problems.
Because at the moment there are only more questions, but, unfortunately, I have not yet been able to close a single question, I have not found a single final solution.

Thank you very much!

Hi there
Sure, We are all here to help. What you endeavor to do , is NEW and therefore no ready made examples are in existence. Does not mean you can’t be the First :wink: :v:
Start with the first this , the SLeep and get that handled, It is very possible.
ton’s of code on here for that.
Do you have a sketch that works with the AS5600?
Post it and let’s start there. Your not the first to face this effort. Takes some patience and work but in the end it’s totally possible.

To your points,
Deep Sleep , Light Sleep (Done, level of power savings depends on BSP file used)
UPdate firmware over BLE. (I have only seen this on the Nordic SDK, but it is possible)
Ant+ protocol (work in process, needs first two)
AS5600 absolutely. doable and probably done already.

I would work it in reverse maybe, get the comms working, then do the rest.
you using this hardware?

HTH
GL :slight_smile: PJ

1 Like

Hello.
I bought myself a Dongle nRF52840, but I had problems with it from the very beginning. How to program it?
For example, the simplest code “Blinky”. I watched several videos, but all of them are incomprehensible to me. Directly through VSCode nRF Connect does not see it (the screenshot below shows that Programmer detected it, but nRF Connect did not).


Next, I read that you need to drag and drop the HEX file of the project using the programmer. But where can I get this HEX file and in what environment should I write the code for the Dongle?

I am sure that my questions seem stupid to you, but still, please help me figure this out. Maybe it’s easy to solve the issue with Ant, which I still have active, because I don’t want to buy an expensive JLink+

Hi there,
WOW, So NO SUCH thing as a Stupid question :wink: :v:I think you are conflating the two things.
One the Dongle can be programmed and will be reprogrammed when ever you load a particular sketch or function from Nrf connect for Desktop.
Starting with Nrf Connect for Desktop (ver 4.40)…
Open the BLE for example and select the dongle from the pull down.
it will be recognized and programmed to be a BLE dongle. Hit scan and see if it see’s any BLE devices? If it does or you don’t have any try turning on BLE on your phone. Does it show up or any devices? If so then go to the next app,
The Programmer app, Again select the dongle from the pull down and it should push it to DFU Bootloader mode and display the contents of the memory in the dongle. pictured here,


You’ll notice the DRAG& DROP area to reprogram the dongle with your code or “Blinky” Just be sure to select the Correct board type (ie dongle) PCA10059.
The same thing works with the XIAO Nrf52840 based MCU’s
This will get you on the way to your ANT project.
HTH
GL :slight_smile: PJ

BTW, you’ll notice if you switch back to the BLE tester, it will ask to reprogram dongle(yes) and you will see how it reprograms the dongle back from programmer mode. :+1:

1 Like