• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

LoRa Module Sleeping

Q&A Forum › Category: ESP32 › LoRa Module Sleeping
0 Vote Up Vote Down
David Doidge asked 4 years ago

Hi,
I have 2 esp32 with lora modules sending sensor data every 10 minutes. The problem I have is that the receiver will work for hours but then fail.
I altered the code to incorporate an “ESP.restart()” if no data was received after 15 minutes which seemed to work ok, but I wanted to know why.
I then altered the code to incorporate another “LoRa.begin(866E6)” if no data was received after 15 minutes and this also worked, so the esp32 is not crashing but the LoRa module, i think, is going to sleep for some reason. I changed the LoRa module but the same thing happens.
Can you give me some advice on why you think the module is falling asleep ?

29 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hello David,

  • How are you powering your board?
  • Do you have any other Arduino IDE Serial debugging information of what happens when the board crashes?

Thanks for your patience!

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
The esp32 is powered via pc usb3, LoRa module is powered via esp32
The serial shows the packets being read (working) until there is no packets for 15 minutes and it then resets the LoRa module (no error messages)

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
I’m not sure why that happens.
The last time I experimented with my LoRa modules, the reception never failed.
However, it seems that’s not the case for your project.
 
What’s the LoRa module that you have? Is it the same as ours?
 
Additionally, you are powering the project using the computer. I’m wondering if the computer goes into sleep mode and doesn’t provide enough power when it fails??
Can you try to power the circuit with another power source? A power bank or a phone charger, for example?
 
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
RF96 at 868Mhz
I have tried powering the device a few different ways but with the same results.
I will try on the weekend with a different sketch and see if it needs resetting.
Thank you for the reply,
David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Ok,
Then, let me know the results.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
Just an update to say I am still having problems with the receiver “crashing” !
I have tried different frequencies/power supplies/etc
I do believe it is a programming/sketch problem but cannot understand how it runs for hours then “crash” ๐Ÿ™

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi David.
I’m not sure what might be causing the issue.
Can you share your receiver’s code with me?
To share a code, share a link to github, pastebin, google drive, or other.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
Thank you for trying to help.
https://drive.google.com/drive/folders/1LmPNQyoxYkmbDy5twJYI35w4dbninB_X?usp=sharing
David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi again.
I didn’t know you were also using MQTTT with your project.
Can you remove the MQTTT section of your code and test again? To be sure that it is related to LoRa and not with MQTTT interfering with something on the setup. Or have you tested that?
Regards,
Sara
 

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi again.
I didn’t know you were also using MQTTT with your project.
Can you remove the MQTTT section of your code and test again? To be sure that it is related to LoRa and not with MQTTT interfering with something on the setup. Or have you tested that?
Regards,
Sara
 

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
I am afraid I have removed all the wifi and mqtt with the same results.
It works for hours and then it just stops

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
I’m not sure why that happens. There are similar problems recorded on the library issues page with different solutions and suggestions, but I’m not sure what might be your case. You may want to take a look or post your own issue there:

  • https://github.com/sandeepmistry/arduino-LoRa/issues

 
Additionally, they recently added another way to receive packets using a callback function. You can check the example here:

  • https://github.com/sandeepmistry/arduino-LoRa/blob/master/examples/LoRaReceiverCallback/LoRaReceiverCallback.ino

You can modify your code with this different way of receiving packets and see if that solves the problem.
 
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Thank You.

This one seems to be exactly as mine: https://github.com/sandeepmistry/arduino-LoRa/issues/447

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
I have tried to incorporate the “LoRa.onReceive(onReceive)” and “”void onReceive(int packetSize)” parts of sandeep code into my sketch and yours but I am failing in my limited programming knowledge and am not getting any packets being received.
Please could you show me what code needs to be replaced as sandeeps example shows nothing inside the void loop ?

David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi David.
 
Can you show me how your code looks like now?
 
Basically, the onReceive() is a callback function that will run automatically when a new packet is received.
So, you don’t nee to check constantly for new messages in the loop() with if (packetSize == 0) {.
 
So, everything that you have after the following line:
while (LoRa.available()) { //if there is a packet, read its contents while available
should go inside the onReceive() function.
 
If you show me your current code, maybe I can point out what is wrong.
 
Regards,
Sara
 

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
You explain it so much easier for me to understand, thank you.
I have altered my code, again, and am now receiving packets.
I will see how long it runs without freezing.
David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

That’s great!
Then, tell me the results.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
No luck, I got this (amongst other stuff!!) after 5 hours

Guru Meditation Error: Core 1 panic’ed (Interrupt wdt timeout on CPU1)

edit:

I removed all my gunk code and so far it has lasted 12 hours, will see how long it lasts ๐Ÿ™‚

David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Ok.
If you want, send me the code so that I can take a look.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
https://drive.google.com/drive/folders/1cWbJrsFbxktkLAh-WSAqdBdlDPB5C40c?usp=sharing

I get the error: Guru Meditation Error: Core 1 panic’ed (Interrupt wdt timeout on CPU1)………….ย  when it tries to connect to the wifi.

David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
Try to call the setup_wifi() function in the setup(), instead of calling it inside the callback() function.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Hi,
Moved the setup_wifi() into the void setup() connects ok to the wifi.
It now shows the “Guru Mediation……….” when it runs the MQTT part.
David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Maybe you should move that part outside of the callback function.
Instead, add a flag variable that will run that part of the code in the loop() when the flag variable is true.
Do you know how to do that?

0 Vote Up Vote Down
David Doidge answered 4 years ago

I am sorry but no, can you link me to a guide please ?
David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
See the first example: https://www.baldengineer.com/flag-variables-are-not-evil-for-microcontrollers.html
But, in your case, instead of an ISR function, you have a callback function, and you don’t have interrupts.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

Thank you again,
Will have another try as soon as work allows !!

update: changed the code this evening and uploaded and am receiving packets ๐Ÿ™‚

Will see how long it works for ?

David

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Great!
Then, tell me the results.
Regards,
Sara

0 Vote Up Vote Down
David Doidge answered 4 years ago

So far it is still receiving packets with no restarts.
I think you have sussed it ๐Ÿ™‚
David

1 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

That’s great!
I’ll mark this issue as resolved for now.
If you happen to have issues later, you can still comment in this thread.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login ยป

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright ยฉ 2013-2025 ยท RandomNerdTutorials.com ยท All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.