jomjol / AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world
https://jomjol.github.io/AI-on-the-edge-device-docs/
5.95k stars 648 forks source link

Wrong date & time #586

Closed slangpetter closed 2 years ago

slangpetter commented 2 years ago

Hi!

I have problems with date & time. Everything works as it should except that it thinks it is 1970-01-01. Whether I have Timeserver on or off. How can i fix this?

Best regards Petter

Bild2 Bild3 Bild4 Bild1
zuzu59 commented 2 years ago

Hello, I have exactly the same problem ! At each reboot the date is found in 1970, as if the time server was not taken into account. With version 10.0.1 I did not have this problem! Thank you @+

stonemaan commented 2 years ago

same here

RoberWi commented 2 years ago

Same here. Went back to version 9.2 and the problems are gone.

stonemaan commented 2 years ago

Same here. Went back to version 9.2 and the problems are gone.

unfortunately not for me. I tried all versions since 9.2 - none of them worked. Flashing and OTA did not help. set another time server did not work as well. MQTT does not work anymore...

Kalli01 commented 2 years ago

Maybe the entry in the config.ini has changed by mistake due to an update. For me, the following is entered directly in config.ini for Germany.

[System] TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 ;TimeServer = undefined ;AutoAdjustSummertime = false Hostname = wasser_stadt ;SetupMode = false

stonemaan commented 2 years ago

Maybe the entry in the config.ini has changed by mistake due to an update. For me, the following is entered directly in config.ini for Germany.

[System] TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 ;TimeServer = undefined ;AutoAdjustSummertime = false Hostname = wasser_stadt ;SetupMode = false

Did not help :/

friedpa commented 2 years ago

I am using 9.2.0 with:

[System] TimeZone = CEST,M3.5.0,M10.5.0/3 TimeServer = fritz.box Hostname = Gaszähler-ESP32CAM ;SetupMode = false

works fine.

stonemaan commented 2 years ago

After erasing flash and re flashing again using FAT32 instead of FAT (do not know if this had any effect) and removing the standardgateway - both of my ESP32 are back and works perfectly.

jomjol commented 2 years ago

@slangpetter @Kalli01 : can you test the solution of @stonemaan ?

Otherwise I have no idea!?!

Kalli01 commented 2 years ago

That was perhaps not clearly written by me. With me there were no problems with the time.

Feinfinger380 commented 2 years ago

Same Problem, tried out with some ESP.

Remove the fix IP from the Config solved the Problem.

barthm1 commented 2 years ago

I have the same problem and I'm not able to correct it - no reaction on cold boot, using a ntp server

screengas The wrong time belongs to the next day screengas2 screengas3

Feinfinger380 commented 2 years ago

I have the same problem and I'm not able to correct it - no reaction on cold boot, using a ntp server

screengas The wrong time belongs to the next day screengas2 screengas3

Please show the serial Log at startup.

jomjol commented 2 years ago

@barthm1 : sorry I don't get the problem. Can you explain it a bit more in detail?

barthm1 commented 2 years ago

Datum liegt 2 Tage in der Zukunft Uhrzeit ist auch irgendwo - Durch Kaltstart, eintragen eines NTP Servers kann das nicht korrigiert werden. Löschen der Log-Dateien habe ich auch probiert - Datum Uhrzeit bleibt falsch. Timezone ist korrekt

friedpa commented 2 years ago

@barthm1 Bitte einmal den Config.ini Eintrag hier posten.

Feinfinger380 commented 2 years ago

@barthm1

Hast du ne feste IP vergeben?

barthm1 commented 2 years ago

@friedpa warum der hostname "nicht" übertragen wird weiß ich auch nicht Die IP Adressen sind nicht fest vergeben - aber über den Router fest zugewiesen

[System]

TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 TimeServer = pool.ntp.org ;AutoAdjustSummertime = Hostname = gasmeter ;SetupMode = false

anderer Zähler der funktioniert

[System] TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 ;TimeServer = undefined ;AutoAdjustSummertime = false ;Hostname = undefined SetupMode = false

barthm1 commented 2 years ago

In dem MQTT Eintrag fehlt auch das "main" Last restart steht auch falsch

screengas4

michaeljoos72 commented 2 years ago

An alle mit Zeitproblemen: Versucht einfach mal per OTA eine ältere FW zu flashen --> z.B auf 10.1.0, dann Zeit kontrollieren und falls OK wieder die aktuellste FW flashen. Hat bei mir jetzt schon 2x geholfen.

jomjol commented 2 years ago

Zuerstmal zum Ablauf: 1) nach dem Booten wird erstmal sehr früh versucht, die Zeit zu bekommen, damit die Logeinträge stimmen. Da zu dem Zeitpunkt die config.ini nicht gelesen wurde, wird ein Standart-Zeitserver verwendet: pool.ntp.org 2) Falls der nicht nach 10 Versuchen erreicht wird, bleibt die Zeit bei 01.01.1970... 3) Wenn in der config.ini ein aktiver Timeserver-Eintrag gefunden wird, wird dieser gesetzt und die Zeit dann nochmals dort mit max. 10 Versuchen abgefragt und gesetzt. 4) Die Zeitzone wird über TimeZone = CET-1CEST,M3.5.0,M10.5.0/3 gesetzt (auch erstmal vorläufig, bis er in der Config.ini ggf. aktualisiert wird.

Ich habe gerade bei mir nochmal verschiedene Konfigurationen mit eigenem und externem Zeitserver getestet. Läuft eigentlich wie erwartet. Mit einer Auffälligkeit: meinen lokalen Timerserver (FritzBox) wird nur erkannt, wenn ich die IP direkt eingebe - mit fritz.box geht es nicht.

Wenn die Uhr um 2 Tage falsch geht, kann es nur am Timeserver oder einem Fehler im Format TimeZone liegen.

barthm1 commented 2 years ago

Sobald ich die IP-Aadresse der Fritzbox eIntrage, wird nach einem Neustart die Zeit korrekt gesetzt - Problem scheint also nur die Namensauflösung zu sein

Mad-007 commented 2 years ago

Danke für den Tipp - nach direkter Eingabe der IP Adresse der FritzBox wird auch bei mir die Zeit wieder richtig gesetzt.

Gunter1710 commented 2 years ago

Also die Fritzbox IP-Adresse hat bei mir auch geholfen. Verstehen muss man das nicht aber es geht :-)

jomjol commented 2 years ago

Dann schließe ich das jetzt mal.

zumheulen commented 1 year ago

@jomjol You "closed" here but didn't generally fix the problem ;-) I too went almost insane all morning today, although I had set it up perfectly with V12.01 (SD card was defective). Was timestamp 1970! I tried all possible time servers listed on the net, and rebooted. Some, but not all, I was able to ping successfully beforehand. Since I don't own a "Fritzbox" but a UniFi Dreammachine and everything is a little more complicated, I can't rule out that this is also partially responsible for "problems". At least it was unsuccessful to give the UniFi its IP because, according to internet research, it probably does not provide a timestamp... (no guarantee) WHAT, however, brought immediate success (a tip on the Internet), my Synology NAS provides the time within the network and boom, everything worked! :-)

jomjol commented 1 year ago

Good to hear!

caco3 commented 1 year ago

If it does not work with a domain name but with the IP, it most likely is a DNS issue.

If you have a fritzbox, the easiest is to enter the IP of it. Since it works for most users i don't think it is an issue of the firmware. But like reported in https://github.com/jomjol/AI-on-the-edge-device/issues/1292 I also saw it a few times that it failed after 10 retries. The time then was on 1970.

As an improvement, we could retry to set the time before every round if it did not get set before

caco3 commented 1 year ago

Hopefully fixed with https://github.com/jomjol/AI-on-the-edge-device/pull/1364