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 ?
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!
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)
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
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
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” ๐
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
Hi,
Thank you for trying to help.
https://drive.google.com/drive/folders/1LmPNQyoxYkmbDy5twJYI35w4dbninB_X?usp=sharing
David
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
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
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
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:
Additionally, they recently added another way to receive packets using a callback function. You can check the example here:
You can modify your code with this different way of receiving packets and see if that solves the problem.
Regards,
Sara
Thank You.
This one seems to be exactly as mine: https://github.com/sandeepmistry/arduino-LoRa/issues/447
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
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
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
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
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
Hi.
Try to call the setup_wifi() function in the setup(), instead of calling it inside the callback() function.
Regards,
Sara
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
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?
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
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
So far it is still receiving packets with no restarts.
I think you have sussed it ๐
David