Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By lmerega
#55944
mrburnette wrote:If you are receiving 'electrical shocks', you have a very serious health issue.

LOL, sorry, I am not english, so perhaps I used an expression too strong ;) .
Put a 9V battery on your tongue, you can feel an electrical shock.
The one I feel on my board is about 1/3 of power than a 9V battery on the tongue.
Could you point me to some examples using delay(0) or yeld?
I am resetting the board every 10 minutes in this moment... and it is working... but it is really bad.

Thx again

.luca
User avatar
By lmerega
#55951
Guillaume wrote:I'm beginner but, I see this in your code:
Code: Select allif (now() >= 180) {
ESP.restart(); //why don't you work?!?
}


Doesn't that reboot the ESP every 3 minutes ?

Yes, now I changed it to 600... it's working now, but I do not like this solution.
User avatar
By mrburnette
#56005
lmerega wrote:Could you point me to some examples using delay(0) or yeld?
I am resetting the board every 10 minutes in this moment... and it is working... but it is really bad.
.luca


Surely,
My basic non-RF sketch still must deal with the delay(0) issue to keep the WDT petted.

The solution often is a bit of play to find the right spot(s)... you must know your code and understand the length of time a function takes. In the worst conditions, you will just need to print millis() at various locations and determine the time delta... remember, you should allow the RF section to breath every 50mS (maximum.)

In the code below, yield() is placed in the loop() to "pet the watch dog" right before a rather lengthy function is execute and right after a Print. (I may have gotten away with just one, but the two together provides rock-solid stability.)

Code: Select allvoid loop() {
    static unsigned long l = 0;                     // only initialized once
    unsigned long t;                                // local var: type declaration at compile time
   
    t = millis();

    if((t - l) > 5000) {                            // update temp every 5 seconds
        analogSample(); yield();
        webSocket.sendTXT(socketNumber, "wpMeter,Arduino," + temp_str + ",1");
        l = t;                                      // typical runtime this IF{} == 300uS - 776uS measured
        Serial.print( ADCvalue);Serial.println(": " + temp_str + "F");
        yield();
    }

    server.handleClient();
    webSocket.loop();
}