Closed sabas1080 closed 1 year ago
Thank you! This would be amazing!
Hey there, just checking to see if any progress has been made on this? I can't seem to figure it out.
I'm looking for the same. I found some Arduino sleep code for the SAM R34, but it's for a different board than the Bast-WAN/RAK, so won't work as-is, but might be a good starting point.
Hi @glenmurphy thanks!
@Jordandarabos SAMR34 and RAK4260 now support sleep modes please use our fork of the libraries RTCZero https://github.com/ElectronicCats/RTCZero ArduinoLowPower https://github.com/ElectronicCats/ArduinoLowPower
:D
So-far I haven't been able to get this to fully work on a raw RAK4260, including the new RTCZero code plus the PR on the boards:
Given the higher current draw (3mA is high) and lack of wakeup, my suspicion is that it's halting partway through the sleep() code - will comment out / bisect when I get a chance.
@glenmurphy yesterday I fix a error with RTCZero https://github.com/ElectronicCats/RTCZero/commit/57dc030044838243d3c5a399154eb71b93d9813a
you have the latest changes?
Just an update on this.. We're working through some things with the RTCZero Library. For the record this is what we've found:
sleep() is getting stuck during the while loop at line 122(while ((OSC32KCTRL->STATUS.reg & OSC32KCTRL_STATUS_XOSC32KRDY) == 0);). It seems to be an clock issue so that got us looking at the RTCZero Library.
We found the the none of the RTCZero examples work, which we're investigating now. Will update with anything that we find but was wondering if you were able to get the RTCZero examples to work @sabas1080 ?
Hi @Jordandarabos
I have not been able to find the error, the library works with me for times, welcome your help
Hey @sabas1080
Thanks for the quick response! That's odd because when we upload the example sketch SimpleRTC it just prints "00/00/00 00:00:00" Over and over. We're going to do some testing today to see what might be causing the issue.
Hey @sabas1080
So very strange results so far... We can get the RTCZero examples to work by adding a whole bunch of serial prints in random spots in RTCZero.cpp, which is bizarre. This also caused the low power mode sketch to follow through (still only getting down to about 3-4ma) but at least the sketch doesn't freeze. The interrupt seems to wake up the device and work properly. Any ideas on why affect the RTCZero examples? Also, I noticed there are different sleep modes for the RAK4260. Is it possible we're going into the wrong mode which is why the consumption is so high? Just thinking out loud. Will update when we if we stumble upon anything else. Thank you.
@Jordandarabos that may be the reason it works for me sometimes, what are the different sleep modes for the RAK4260?
@sabas1080 @plachta-zabatt
So regarding the prints in RTCZero.cpp, seems like if we put a 10ms delay on line 135 it works. Which makes me wonder if the function RTCisSyncing() is actually doing its job? I'm not familiar enough with it to know but we'll keep digging.
The different modes are located here >https://github.com/RAKWireless/RAK4260_Low_Power_demo/blob/master/APPS_LOW_POWER3_debug/APPS_LOW_POWER3/src/low_power_demo.c
starting on line 671. I've listed them below for convenience:
-ACTIVE mode: Performance Level 0 at 12MHz -ACTIVE mode: Performance Level 2 at 48MHz -IDLE mode: Performance Level 0 at 12MHz -STANDBY mode:PD0,PD1 and PD2 in retention state -BACKUP mode -OFF mode
Is correct, I have added the delay and it works, could be a temporary patch
we tried to acces by RTC->MODE2.SYNCBUSY.bit.CLOCKSYNC bit only and nothing changed so the behaviour is kinda weird maybe is it bad defined on the CMSIS? i dont know
Any update on this implementation? Currently the lowest I can get is 2mA in sleep mode
@blackrosezy 2mA is the lowest you currently get
I was trying to setup sleep on the SAM R34 as well but with little luck.
- idle() returns to execution immediately
- sleep() freezes execution and drops the current draw from ~10mA to ~3mA (measured using a µCurrent Gold)
- sleep(time) does not return/wake-up after time
- attachInterruptWakeup doesn't appear to work - the interrupts fire the callback correctly before sleep() is called, but do not wake the device from sleep. I tried Bast WAN pins A2 (PA07), D10 (PA14), and D13 (PA22)
I got these exact results. The code just stops executions and never wakes no matter what I do.
I'm looking for the same. I found some Arduino sleep code for the SAM R34, but it's for a different board than the Bast-WAN/RAK, so won't work as-is, but might be a good starting point.
So I tried burning the bootloader for this core and I tried out their low power examples. The advantage is that there the processor actually wakes from it's sleep. But I measured around 3.7mA in IDLE mode, which was the same as with the ArduinoLowPower library. When I let it sleep in the BACKUP mode, I got down to 790uA, which is still much higher than the 790nA specified by the datasheet.
The breakout board shouldn't take much current by itself. Maybe the cheapo multimeters have problems at these low values. I'll probably create an issue at the RIOT R34 Stamp repo to find out what's the issue.
@Jakub-Nagy
the changes I made in the libraries are based on the work of RIOTNetwork, It should work the same, if you find any difference let me know and we will comment, welcome your suggestions
To achieve this current you must have the minimum number of elements working, the 790nA is only the chip, a good average should be about 500uA
the changes I made in the libraries are based on the work of RIOTNetwork, It should work the same, if you find any difference let me know and we will comment, welcome your suggestions
Well, as I said with RIOT the waking up from sleep is possible, in the libraries linked here it is not. The only way I can wake up the processor is by reseting it altogether.
good average should be about 500uA
I mean that's probably okay, but it's kinda sad knowing that it should be able to get much lower.
790nA is only the chip
So do you know what's the rest? Is it components on the breakout board?
@Jakub-Nagy
Well, as I said with RIOT the waking up from sleep is possible, in the libraries linked here it is not. The only way I can wake up the processor is by reseting it altogether.
maybe some changes are necessary in our core for it to work correctly https://github.com/riotnetwork/samr/commit/959d6563cbfb3bb70506627a99acd5f1e2f6a80d https://github.com/riotnetwork/samr/commit/dc40495a447d154cc347ec6fb0c16c0308e24658 https://github.com/riotnetwork/samr/commit/26d41461ab7a236ea1c679e5a56de1a4458ae020 https://github.com/riotnetwork/samr/commit/d4a60a6aa903b5fe6ecce7d1605359dd33ef54cc https://github.com/riotnetwork/samr/commit/d47a467a1728bf744bd06a20385252d7a0903705
I mean that's probably okay, but it's kinda sad knowing that it should be able to get much lower.
790nA is only the chip
So do you know what's the rest? Is it components on the breakout board?
to improve the current level you will have to use Microchip / Atmel tools and optimize your hardware to the maximum, you must consider consumption of the regulator, LEDs, resistors and sensors that must also enter low consumption mode or not place them, example https://diyi0t.com/reduce-the-esp32-power-consumption/
to improve the current level you will have to use Microchip / Atmel tools and optimize your hardware to the maximum
Maybe that's currently the only way.
consider consumption of the regulator, LEDs, resistors and sensors that must also enter low consumption mode or not place them
Yes I'll definitely do that on my own hardware. But even on this breakout board, the maker from Tindie states that the consumption of the board itself (without the chip) is only 9ua, plus the 890nA of the chip that should total at 10uA, not at nearly 800uA. I will try to find out more.
Yes I'll definitely do that on my own hardware. But even on this breakout board, the maker from Tindie states that the consumption of the board itself (without the chip) is only 9ua, plus the 890nA of the chip that should total at 10uA, not at nearly 800uA. I will try to find out more. the maker of this board recommend Atmel Studio 7 or Mbed
the maker of this board recommend Atmel Studio 7 or Mbed
Atmel Studio works but it lacks documentation and Mbed works but with much much larger hoops than with Arduino.
I just want to share my setup to test the sleep current (I'm using Joulescope from JetPerch) for the RAK4260 (https://store.rakwireless.com/products/rak4260-breakout-board).
First I'm using firmware from https://github.com/RAKWireless/RAK4260_Low_Power_demo. The lowest current that I can get is ~700nA in Standby mode.
Using the same hardware setup, I'm using the library from https://github.com/ElectronicCats/ArduinoLowPower, the lowest current in sleep mode that I can get is around ~2mA.
Currently I'm comparing the code from https://github.com/RAKWireless/RAK4260_Low_Power_demo and https://github.com/ElectronicCats/ArduinoLowPower to see which area that can be improved.
Here are my hardware setup:
I got the BastWan power consumption down to 120uA with RIOT OS in STANDBY Mode and down to 80uA in BACKUP mode. From my view the LDO takes roughly 50uA AP2112K-3.3TRG1 Dtasheet plus 5uA for the LiPo Charger MCP73831 negleting power demand of the ATECC608A and coarse measured the 1uA for the Battery voltage divider (r3/r4). To verify it would be very supporting if we would know about the power consumption in STANDBY mode of the MCU itself e.g. using the breakout board. @blackrosezy Did you measure also the STANDBY mode power consumption and like to share your results? This might give me a hint to further investigate power leaks or to judge if we are fine with it for now. For anyone to x-check measurements see bastwan branch for RIOT OS and example project including LoraWan https://github.com/h-filzer/samr34-lorawan-smt50
This is a message to remind you that your request has been pending for 5 days and awaits your comments. Our agent would like to hear from you about your previous request to see if the difficulty you were facing has been resolved or if we can provide further assistance. Otherwise, if we do not hear back from you within the next three days, the issue will be closed. Kind regards, Electronic Cats Support Team
Sleep modes with the Arduino IDE
Examples https://github.com/RAKWireless/RAK4260_Low_Power_demo