So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Bonzo
#76591 I am going around in circles at the moment trying to get the time onto a Nodemcu using the Arduino IDE and keep hitting a brick wall. Everything was working with a Nodemcu > Raspberry pi > PC apart from the pi was sleeping/locking up.

I read the Nodemcu clock was not that accurate so decided to get the time from a NPT server. Now I have just read that if I poll the NPT servers to often I could get my IP banned; which may already have happend on one of them!

I have also read about the rtc.deepsleep modul but it looks like it is only for the Lau language. I do not want to try and learn another language as I am currently trying to learn the Arduino one and Python!

Basically I need to timestamp my sensor readings and save the timestamp with the readings into SPIFFS.

Can somebody please help me to get a timestamp into my arduino code. I have read an article about somehow getting the time from my network hub? Polling the NPT server less and using that to correct the Nodemcu time; but the time will be lost when it goes into deep sleep that is why rtc sleep looks better.
User avatar
By rudy
#76592 Why not use a DS3231 real time clock chip for the time. They are cheap and they are accurate.

I have some projects that need to know the time and can not rely on the internet being available. In my case the ESP8266 comes out of reset and then gets the time from the DS3231. It then tries to get the time from the internet. If it can't then it runs with the time that was set from the DS3231. If the ESP8266 gets the time from the Internet then the DS3231 is synced with the network time. (once per hour) Obviously your case is a bit different but not a lot.
User avatar
By Bonzo
#76598 Thank you for the reply rudy.

I have an old Sparkfun RTC module DS1307 and will give that a go. It is a shame I did not think about it before I laid out my strip board as there is no room for it. I will have to leave it laying in the box and connect with wires or bend the legs and mount it vertically as I like things to be neat.
I have read the DS1307 loses between 1 sec and 2min a day and is temperature dependent. It looks like the DS3231 is more accurate but if I sync it as you say it should be better than I need.

EDIT: Looking around most of the DS3231 boards I have found will not fit in my box.
User avatar
By rudy
#76601 The DS1307 is a 5 volt part and not shown to work at 3 volts like the DS3231. Most often the modules with the DS3231 have an eeprom on the board, and yes that module is big. But I found a smaller module that might work for you.

https://www.aliexpress.com/item/Free-sh ... 23866.html

https://www.robotshop.com/en/ds3231-hig ... ry-pi.html

Image

Image