Post topics, source code that relate to the Arduino Platform

User avatar
By dynek
#26124 Hello All,

I'm still completely amazed by the power of this little device and being able to program it using the Arduino IDE just makes it even cooler :-)
Thanks to those making this possible!

Now I have a question. I am building a small project that POST data to a web server every hour.
What I have done so far is working as expected except sometimes.

First the problem: in my SQL DB I should see an entry every hour and that works for quite some time but all of a sudden it starts sending data much faster and goes back to normal. See timestamps:
2015-08-15 21:32:33
2015-08-15 22:32:33
2015-08-15 23:32:33
2015-08-16 00:32:34
2015-08-16 01:32:34
2015-08-16 02:32:34
2015-08-16 03:32:34
2015-08-16 04:32:35
2015-08-16 05:32:35
2015-08-16 06:31:39 <-- going little bit backwards already strange as it worked rock solid for the last 9h but anyways I don't need to be that precise
2015-08-16 07:31:39
2015-08-16 07:37:01 <-- this is where it starts to act weird. why does it send data that quickly after last one?
2015-08-16 08:37:00

Basically the code looks like this:
Code: Select all//include libraries
#include <ESP8266WiFi.h>

// clock watcher
unsigned long interval = 3600000;
boolean probe_sent = false;

[..]

void loop() {
  // if millis() reached interval (1h) restart ESP
  if(millis() >= interval) {
    ESP.restart();
  }

  if(!probe_sent) {
    // initiate wifi link
    // connect to web server
    // post information
    // set probe_sent to true
    // disconnect from AP
    // set WIFI_OFF
  }
}


So what this does is post data right when started and then sleeps for 1h.

I'll keep investigating on my side but I'm kind of stuck and was wondering if someone would have a clue.

Any help will be, of course, much appreciated :-) Thank you!
User avatar
By Barnabybear
#26135 Hi, could have been a reset? That would explain both unexpected times (the first the looks as if it reporeted to soon could have reset just before the timer). You could set up a counter that is not reset by sleep and reports with the data to check. The counter should increment unless the ESP resets in which case it should return to 0. The ESP8266-01 can reset through noise on the reset pin if not held high correctly & on voltage fluctuations.
User avatar
By dynek
#26287 Hello and thank you for your answer,
Barnabybear wrote:could have been a reset?

I highly suspect it indeed was a reset but not done manually / on purpose.
As WiFi is configured and data post only when the device is powered-on it has to be a reset. I don't get why.
Barnabybear wrote:The ESP8266-01 can reset through noise on the reset pin if not held high correctly & on voltage fluctuations.

Voltage fluctuation may happen, wondering if a 1uf capacitor on the line would help digest those?
The reset pin is already held high permanently when running.

Thank you!