kolban wrote:Do you have a link to the millis() function documentation for the function of the Arduino libraries implemented to top of the ESP8266? Here is what is going through my mind.
Your code seems to be writing out the millis() value divided by 1000 to turn it into seconds. Perfect ... get that ... however ... what are "expecting" the millis() output to be? My belief is that the value is a timer that keeps incrementing since boot time. Which means (to me) that it should always be increasing and if one wants to find delta times, one must record the initial value and then subtract that from the current value to find the difference.
Again, I might be totally off base on this having never tried to use (yet) the Arduino IDE/libraries (I code using the raw Espressif SDK and Eclipse).
Ok
I have changed code: placing StartTime=millis() in the Setup;
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
unsigned long StartTime=0;
unsigned long WorkTime=0;
const char* ssid = "@HomeCA72";
const char* password = "";
MDNSResponder mdns;
const int led = 0;
ESP8266WebServer server(80);
void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from esp8266!");
digitalWrite(led, 0);
}
void handleNotFound(){
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void setup(void){
//-----------------------
StartTime=millis(); //<---------------
//-----------------------
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
// Serial.setDebugOutput(true); //burkmurray
// WiFi.mode(WIFI_STA);//burkmurray
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/inline", [](){
server.send(200, "text/plain", "this works as well");
});
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
WorkTime=millis()-StartTime;
Serial.print("Start and Work Times[ms]= ");
Serial.print(StartTime);
Serial.print(" ");
Serial.println(WorkTime);
server.handleClient();
//---------------------
// digitalWrite(led, 1);
// delay(100);
// digitalWrite(led, 0);
delay(100);
}
Results:
Start and Work Times[ms]= 211 31146
Start and Work Times[ms]= 211 31246
Start and Work Times[ms]= 211 31346
Start and Work Times[ms]= 211 31446
Start and Work Times[ms]= 211 31546
Start and Work Times[ms]= 211 31646
Start and Work Times[ms]= 211 31747
Start and Work Times[ms]= 211 31847
Start and Work Times[ms]= 211 31947
Start and Work Times[ms]= 211 32047
Start and Work Times[ms]= 211 32147
ets Jan 8 2013,rst cause:4, boot mode:(3,7)
wdt reset
burkmurray wrote:Any changes to your circuit on your last flash? Pins that were floating and now aren't, or vice versa?
No changes to my circuit