I know the Xenon is defunct, but I had a couple already running and I’ve been adding to the code.
I’ve been struggling with making a Xenon sleep for x minutes an stay awake for y minutes.
It seems that it doesn’t take the config parameters of System.sleep(config).
Reading other posts, I am able to make it sleep by adding System.sleep({},{},100) after the line System.sleep(config).
However, I can’t make it stay up a specified time.
I used the example in the docs: Wake publish sleep example
I made a test program here: test code
Were there bugs not fixed on the Xenon? Any workarounds?
Running the last OS for Xenon 1.5.2
@Pescatore, the line System.sleep({},{},100)
effectively replaces the (non-functioning) System.sleep(config);
call with the “classic” sleep call API format of this type:
System.sleep(std::initializer_list<pin_t> wakeUpPins, InterruptMode edgeTriggerMode, long seconds);
where wakeUpPins
and edgeTriggerrMode
are NULL and seconds
= 100.
Based on the documentation, this call should put the Xenon in STOP mode for 100 seconds. I am not sure why the original call (using config
) is not sleeping though you could try STOP mode instead of ULTRA_LOW_POWER to see if that works.
Thanks, @peekay123 . I will give that a try.
I should have added that what happens with just the the System.sleep(config) statement, the code flows right through, not sleeping and then resets. This the code in the example I am referring to:
#if HAL_PLATFORM_NRF52840
// Gen 3 (nRF52840) does not suppport HIBERNATE with a time duration
// to wake up. This code uses ULP sleep instead.
config.mode(SystemSleepMode::ULTRA_LOW_POWER)
.duration(sleepTime);
System.sleep(config);
// One difference is that ULP continues execution. For simplicity,
// we just match the HIBERNATE behavior by resetting here.
System.reset();
#else
I was hoping that adding the System.sleep({},{},100)
it would take the rest of the parameters initialized at the beginning of the code, like how long to wait before sleeping again.
If I were to stick with the System.sleep({},{},100)
as a solution, how do I make it stay awake using this API?
Do I just resort to a millis() based wait loop? I am trying to keep it alive to detect OTA updates.
@Pescatore, I’m not sure what you mean by “stay awake”? There is no configuration of sleep keeps the MCU “awake”. But yes, the most likely mechanisms include using a millis()
counter or reading time
(depending on how long the delay is) or using a SoftwareTimer that sets a flag when the set period expires.
As for OTA updates, I believe there are several topics on how to handle sleep and OTA so you may want to do a forum search.
Thanks, I will dig.
You mentioned the (non-functioning) System.sleep(config);
Is this broken in 1.5.2? The docs say to use this new sleep API starting with 1.5.0.
Maybe it’s no longer supported for the Xenon?