-->
Page 1 of 2

How to get time without RTC and NTP client in ESP8266/NOdMCU

PostPosted: Thu Aug 09, 2018 9:11 pm
by mboy03241990
I have a simple IoT project that I can control(on/off) via LAN in my farm or remotely(If internet is present) if needed.. I want to add basic load scheduling in this project to turn on/off my load let say any day of the week at a certain time. I could use NTP client for this to turn on/off let say every Tuesday/Friday at 4pm but the problem is NTP library is dependent to the NTP server which will need me to put internet on the device. I do not want to install internet on this device 24/7 just for the scheduler..

I plan only to use the NTP library for setting the device time initially then device is offline most of the time..

to make things short i want my scheduler work offline without using RTC.. Is there any chance I could do that without to connect RTC module?

What is the correct approach of this problem? I can remember the time from the NTP server initially but Im sure the time would be inaccurate or off after few days without syncing it to the NTP server..

Your ideas and advice would be greatly appreciated.

Re: How to get time without RTC and NTP client in ESP8266/NO

PostPosted: Thu Oct 25, 2018 2:58 pm
by ros
Use NTP library and call in on boot to set time on chip. I've done something similar with my light control on schedule, check this out - https://github.com/palivoda/esp8266-lig ... c/main.cpp

https://github.com/stelgenhof/NTPClient

#include NtpClient.h
...
NTP.init((char *)DEFAULT_NTP_SERVER, UTC0200);
NTP.setPollingInterval(120*60); // Poll every 120 minutes, if you really need it. Or just once on boot is enough

Re: How to get time without RTC and NTP client in ESP8266/NO

PostPosted: Sun Oct 28, 2018 4:28 pm
by schufti
It is as easy as the A B C
without "R"eal "T"ime "C"lock there won't be any "real" time.

If you don't have WiFi around and are allergic to RTC modules you could go with a GPS module and get your time from the satellites ...

Re: How to get time without RTC and NTP client in ESP8266/NO

PostPosted: Mon Oct 29, 2018 4:57 am
by ros
Nice option. Can you share a link to GPS module and code sample you've used for for this trick? ;)