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

Question: How to properly include deepsleep functionality instead of timed rescheduling? #28

Closed
drfritz142 opened this issue Jan 31, 2022 · 4 comments
Labels
question Further information is requested

Comments

@drfritz142
Copy link

Dear Leonel,

thanks first and foremost for this very comprehensive software. I could get it running on a bluepill/rfm95 within a few minutes. Just wonderful.

Now I would like to include a deepsleep function. Most of the time my sensor will be in deepsleep to save battery. Previously, I have just "hacked" that deepsleep call into the code right at the end of the EV_TXCOMPLETE event. But this seems nothing but brutal in your code. I bet there could be a place where it would be properly called within a wrapper function perhaps which every board then could specify out by itself. But where would that call be and how would one properly stop the timed rescheduling? Essentially, this should be replaced: instead of rescheduling after x seconds, the MC should sleep and when waking up, start the next roundtrip.

Could you be so kind as to let me know where I can implement this properly?
Thanks,
Andreas

@drfritz142
Copy link
Author

Of course, this is not an issue but a question. But somehow I didn't find a way to select this ...

@lnlp
Copy link
Owner

lnlp commented Feb 14, 2022

Hi,

Thanks for your feedback.

Deep sleep support is a much wanted feature and very relevant for battery powered LoRaWAN devices.

Unfortunately LMIC-node currently does not include any deep sleep support.

The first (and main) reason is that the (MCCI) LMIC library still does not provide any support / hooks for deep sleep.
Support for functions like e.g. saveLmicState() and restoreLmicState() have yet to be added to the LMIC library (user will need to provide the actual implementation).
Another issue is that the timers that LMIC depends on, need to updated after deep sleep. This is essential because LMIC needs to manage radio time i.e. it keeps track/manages which channels it is allowed to transmit on when. The LMIC library currently does not provide support for this. A 'redo from start' approach would bypass proper radio time management and will very probably conflict with LoRaWAN and/or regional radio frequency regulations.

A second reason why LMIC-node currently does not support deep sleep is that deep sleep behaves differently on different MCU platforms (e.g. ESP32 actually resets when waking up from deep sleep while other platform preserve all state). Without any generic support from the LMIC library this would be quite complex (and much work) to implement for all MCU platforms that LMIC-node currently supports.

For you, how to implement this properly depends on your MCU platform and you will need to solve the issues described above for your platform and hardware.

@lnlp lnlp added the question Further information is requested label Feb 14, 2022
@drfritz142
Copy link
Author

drfritz142 commented Feb 14, 2022 via email

@lnlp
Copy link
Owner

lnlp commented Feb 15, 2022

I think it's an understatement, that deepsleep is very relevant - I believe it's essential!

It definitely is. Therefore it's sad that the LMIC library still doesn't provide any type of support for it.

I found a solution which was realized for an ESP32

Be aware that the dutycycle correction which that solution implements works for EU band plans (eu868) only.

which ... forgets EVERYTHING during deepsleep

Well, almost everything: contents of RTC memory is preserved during deep sleep (see ESP32 memory types).

BR

@lnlp lnlp closed this as completed Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants