pls help: code which runs on Arduino uno, does not on ESP-01
Posted: Tue Feb 23, 2016 4:23 am
Hi;
I got my new ESP-01's up and running - so, the modules are fine and programming (w/ IDE 165) works.
However, the following code (which runs flawless on the uno), compliles fine for the ESP, but throws an error and crashes when running on the ESP:
This is the error popping up on the serial monitor:
However, when I eliminate the else part from aboves code:
the code runs!
Pls note: I am not a programmer, so the code is probably not elegant, but I do not see how to do it different.... (*)
Any help would be greatly appreciated!
Heiner
(*) Basically, what I want to achieve is:
I am monitoring a switch on gpio02; whenever that switch is closed, I want to store the timestamp of that event into an array timestamp[x], where xmax is 10. I do this in a for x= 0 to 10 loop, but whenever there is no switch event detected, I decrease the loop variable by one. So the loop hits only the max count of 10, when there where 10 events detected. After that, other code is run (-> transmitting the 10 timestamps via wifi to a server)
I got my new ESP-01's up and running - so, the modules are fine and programming (w/ IDE 165) works.
However, the following code (which runs flawless on the uno), compliles fine for the ESP, but throws an error and crashes when running on the ESP:
Code: Select all
void loop() {
for(x = 0;x < loopmaxcount; x++) { // accumulate batch of timestamps
// Update the Bounce instance :
debouncer.update();
// compare the reedState to its previous state
if (debouncer.fell()) {
++GasCounter;
Serial.println(GasCounter);
timestamp[x]=now();
}
else {
x--;
}
}
.........
This is the error popping up on the serial monitor:
Code: Select all
Soft WDT reset
ctx: cont
sp: 3ffef900 end: 3ffefb40 offset: 01b0
>>>stack>>>
3ffefab0: 3ffefb8c 0000000b 3ffe84b3 3ffeeb14
3ffefac0: 3ffe8494 0000000b 3ffee9ac 402022af
3ffefad0: 00000009 3ffee9ac 3ffee9b8 40202129
3ffefae0: 3ffe8494 3ffeea04 3ffefb8c 402039c8
3ffefaf0: 1f0110ac 00ffffff 3ffee9ac 40202258
3ffefb00: 3ffe8344 3ffeea04 3ffee9ac 4020209d
3ffefb10: 3ffe8720 1f0110ac 00000000 3ffeeb14
3ffefb20: 3fffdc20 00000000 3ffeeb0c 40202e55
3ffefb30: 00000000 00000000 3ffeeb20 40100114
<<<stack<<<
However, when I eliminate the else part from aboves code:
Code: Select all
else {
x--;
}
the code runs!
Pls note: I am not a programmer, so the code is probably not elegant, but I do not see how to do it different.... (*)
Any help would be greatly appreciated!
Heiner
(*) Basically, what I want to achieve is:
I am monitoring a switch on gpio02; whenever that switch is closed, I want to store the timestamp of that event into an array timestamp[x], where xmax is 10. I do this in a for x= 0 to 10 loop, but whenever there is no switch event detected, I decrease the loop variable by one. So the loop hits only the max count of 10, when there where 10 events detected. After that, other code is run (-> transmitting the 10 timestamps via wifi to a server)