Forum: Mikrocontroller und Digitale Elektronik ESP32 Automatic Reset after one cycle


von Humza U. (humza_u)


Angehängte Dateien:

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.

von Harald K. (kirnbichler)


Lesenswert?

Instead of a useless screenshot showing mostly blank screen area, you 
should have uploaded your sourcecode here, instead of using "pastebin".

von Humza U. (humza_u)


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.

: Bearbeitet durch User
von Monk (roehrmond)


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.

: Bearbeitet durch User
von Humza U. (humza_u)


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.

von Humza U. (humza_u)


Angehängte Dateien:

Lesenswert?

here isthe file as well

von Monk (roehrmond)


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/

von Humza U. (humza_u)


Lesenswert?

Now, when the button on the remote is pressed the program doesn't 
respond to it.

von Stefan F. (Gast)


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.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.