Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low power example #533

Open
jpmeijers opened this issue Feb 7, 2020 · 7 comments
Open

Low power example #533

jpmeijers opened this issue Feb 7, 2020 · 7 comments
Assignees
Labels

Comments

@jpmeijers
Copy link

In the past I have been struggling to make LMiC work together with my microcontroller going into deep sleep mode. Currently I do a call to os_queryTimeCriticalJobs(ms2osticks(5000)) after which I will go into sleep mode for 5 seconds.

One remaining issue is that the micros() timer does not increment in sleep mode, so LMiC will think no time has passed, and the duty cycle logic will prevent me from sending messages - something that I want to do every 10 minutes.

Would it be possible to provide a minimal example of how one can use sleep modes along with LMiC?

Depending on the platform I either use RTCZero and schedule alarms 5 seconds after going to sleep, or I use the WDT to wake up every 8 seconds.

@JackGruber
Copy link

JackGruber commented Feb 7, 2020

Hi,

a example from lowpower Arduino Pro Mini project. Sleeptime is 8 second.

Update timer

// LMIC uses micros() to keep track of the duty cycle, so
// hack timer0_overflow for a rude adjustment: 
cli();
timer0_overflow_count+= 8 * 64 * clockCyclesPerMicrosecond();
sei();

@terrillmoore
Copy link
Member

Yep, updating the clock after sleep is something MCCI does in our STM32 and SAMD sketches. This was the original reason we forked BSPs, as there was no good way to do this in the stock BSPs. (Then we realized it was easy to configure the LMIC, and all our projects are using the LMIC, so...)

@terrillmoore terrillmoore self-assigned this Feb 9, 2020
@mchacher
Copy link

mchacher commented Apr 6, 2020

Hi all,
I am very much interested in this thread having exactly the same question. I am not able to understand how to manage the deep sleep mode with an Arduino Pro mini based on your answers above. Could you please share a more detailed example?
thanks a lot.

@JackGruber
Copy link

Hi, you can take a look in my project.
https://github.com/JackGruber/Arduino-Pro-Mini-LoRa-Sensor-Node

@mchacher
Copy link

mchacher commented Apr 6, 2020

Thanks for sharing @JackGruber. I will look at your code.

@jaqPi
Copy link

jaqPi commented Aug 5, 2020

Hello everyone,

I run into the same problem. Thanks @JackGruber for sharing your project and your solution. Unfortunately, the code works only for AVR boards but not for my Feather M0. Do you know how do adjust the micros() timer of a Feather M0? I am about to read myself into that topic, but it still feels like black magic at the moment.

@etix
Copy link

etix commented Jun 1, 2021

Yep, updating the clock after sleep is something MCCI does in our STM32 and SAMD sketches. This was the original reason we forked BSPs, as there was no good way to do this in the stock BSPs. (Then we realized it was easy to configure the LMIC, and all our projects are using the LMIC, so...)

I've spent quite a few hours trying to make my SAMD board sleep while keeping track of the elapsed time waiting for the RX windows (especially now since TTN v3 requires 5 seconds), I tried to manually adjust os_gettime but it failed since the MCU can take an unpredictable number of ticks waking up and makes the LMIC unhappy. @terrillmoore would you mind sharing how you did it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants