ESP32 Automatic Reset after one cycle

OP #7445254
Lesenswert?
• ▲
▼

Hello, I have a issue, I ran a code, it ran perfectly, then I made changes in the loop. Before making the changes, I wrote a separate code according to the changes I made, and ran it, It worked perfectly as well. When I combined the original code, and the code separately. Changed the variables, removed a small "; " missing type errors. Ran the code. It connected to wifi, then when I pressed button on IR , it showed 2, and after sending the data to firebase. It started to print connecting to wifi and connected to wifi. There was no internet connectivity issues, because the previous code did the same thing and it ran smoothly. while This after I press a key on IR remote says Connected to wifi. I want to know if this issue is code based which I highly doubt because I have debugged it multiple times or if It is caused by program storage space because it is 86% where as global variables use 14%.So, my program resets After I press a button on the remote and it shows the digit. https://hastebin.com/share/wahubaguca.cpp Please help me solve this problem, I have been at it for days.

Angehängte Dateien:
OP #7445324
Lesenswert?
• ▲
▼

Screenshot contains the image of the error. I used hastebin because the code was pretty long and I don't think you are allowed to post huge wall of code. Read it somewhere on this forum. I can post it in the original post, if its allowed. Apologies, I didn't know it could not be edited. But kindly, can you help me out here, if its the code that buggy, can you help me find where I should make changes. I am honestly lost, and already on my way to write new code for the program.

Gast #7445334
Lesenswert?
• ▲
▼

If you can post 84 kB images, you can also attach source code files. Your file is much smaller, but also larger files even several megabytes work fine.

Reduce your code step by step to see when it start working again. Then you know which part causes the problem. E.g. you could start with the block that produces the JSON output.

OP #7445358
Lesenswert?
• ▲
▼

That's what I did, I first remove IR related code then test the rest, It worked fine, Then I removed the JSON and rest, to check the IR related code, and it worked fine as well. but when I test both together, it works but whenever I pressed button to see IR code, it resets the whole program.

Gast #7445373
Lesenswert?
• ▲
▼

Then remove smaller blocks.

Or replace

if (irrecv.decode(&results)) {

by

if (irrecv.decode(&results) && false) {

to ensure that the block below exists but is never executed. Does that make a difference? If not, try:

if (false && irrecv.decode(&results)) {

To ensure that the decode() function is never called. Does that make a difference?

By the way: I see that you can reduce RAM usage a lot, although this is possibly not the problem cause. See https://arduinojson.org/v6/how-to/reduce-memory-usage/

Gast #7446245
Lesenswert?
• ▲
▼
1
const int numChannels = 12;
2
const unsigned long channelHex[numChannels] = {...}
3

4
for (int i = 0; i <= 99; i++)
5
   if (results.value == channelHex[i]) ...

You read much more array elements, than exist. Maybe that triggers the restart.

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.