Hi everyone. I am new in this forum and hope anybody to help.
I would like to have one PC time synchronized by time of another PC via ESP8266.
No internet can be used but there is a local wifi. No GPS, RTC etc.
I am thinking the first PC via ESP8266 can sent its time to the second PC.
If the ESP8266 can run an "private" NTP server so the second PC can be set to time synchronize to the time of the first PC...?
Please, if anybody have an idea how this can be achieved
One possibility is to have the 2 PCs and the esp8266 in the same wlan. An esp8266 could even create the wlan by running in AP (access point) mode. The esp8266 would also run a web server. PC1 would occasionally send a time stamp to the esp8266 using a script which would issue an appropriately formed URL. The esp8266 would use this timestamp to update its internal clock. PC2 would regularly run a script to issue a (different) URL to the esp8266 and fetch the current time which it would then use to update its own clock. You could add more complexity by attempting to make the esp8266 emulate an NTP server.
why do you need an ESP8266 for that?
Set up a NTP Server on PC A,
define on PC B the PC A as NTP Server.
a quick google research for "ESP8266 as NTP server" brings several proposals, a library, ...
The constraints are indeed rather odd which is one of the hallmarks of a school type project.
The scripting (or configuration of the time service) will depend on what is running on the PCs (Windows, Linux etc.)
My PC ( PC 1) is part of an administrative management network. I cannot do much with it. Even i am not sure if they will allow me to instal the ESP driver…The other PC (PC 2) is my working PC where I want to be the same time as PC 1. This one is free of restrictions.
You won't have to install any ESP8266 drivers etc. if you are simply communicating with the ESP8266 using HTTP. However, to develop the application and load it to an ESP8266, you'll need to install the Arduino IDE but this can be done on the unrestricted PC. However, to schedule scripts and maybe configure a time server you may find you need management access to the restricted PC. It just depends how tightly it is locked down. If it is joined to a Windows Domain it likely has a correct network time.
I'm having a rough time not taking you very literally and your proposal seems confusing.
If you want PC2 to take time from PC1, why do you think you need the ESP?
It's easy to find NTP software that can be installed as a service on Windows and Linux. No need for additional gadgets.
If not having the privileges to change PC1's software is an issue, well, NTP doesn't "take" time from other machines unless they too are already running some form of NTP/SNTP server service and can offer up the data to an NTP -capable client.
If you're looking to set up an authoritative time server with no dependence on the PCs on that network, that's a horse of a different color. And I'd be curious what the time reference is planned to be. Cellular maybe?
And do bear in mind that if you screw this up, it can affect SSL, etc.
Hi @plagedi ,
Welcome to the forum..
With PC1 locked down, hard to tell what you could do.
If windows and PC1 is on same net as PC2, then maybe command prompt on PC2 and issue..
NET TIME \\PC1 /SET /YES
good luck.. ~q
Thanks everyone for replaying to this.
PC1 is hard wired to a corporate network and a corporate wifi network. The PC2 cannot be connected to these networks, but it can be connected to another wifi for general use. Of course the corporate networks have a time server but on my question "Can the time server be linked/allowed to the general network/domain?" i have received an answer that company policy does not allow this. That is why i decided to look for an allowed alternative and come up with an ESP idea. If there is a way for the ESP to take the time from the PC1 where is connected and create a "virtual"...local NTP then i can direct the PC2 to synchronize its time to it.
The company wants the corporate network(s) protected.
Sticking the ESP between the two networks could conceivably present a security risk.
If PC2 can access general-use WiFi, there are plenty of reliable sources it can sync its time to. Assuming the NTP mechanisms are working correctly, the two PCs should be within microseconds of each other.
Is that not good enough? Why?
General WiFi is not connected to the internet. It is just internal...Otherwise it is easy to call NTP.
Can you suggest Arduino sketch for ESP8266 that can create time server based on the time of the PC where is connected? Then i can set the PC2 to synchronize its time. I have google this but all i find is GPS, RTC, NTP and so on suggestions. Or i am missing something.
OK, I made an assumption about the "general WiFi", lol, thanks.
It's not like there's a shortage of working examples of NTP code floating around for Arduinos (including one active thread in the ESP32 subforum) but I have zero experience with NTP on Arduinos beyond to mention that if you try something and it's not working, it's time to go back to network basics and make sure the ports are not blocked and the services are running.
The most basic problem for you is that the ESP will still wind up "crossing the streams" and the corporate network admins will frown upon that. Sooo.... hard stop.
To get anyone to sign off on this idea you're going to have to figure out some way of isolating the two networks from each other. Having one device whether it winds up being an ESP or PC1 that can communicate on both just ain't gonna fly.
You can test the limits of what they'll let you conceive by proposing two ESPs (one on each network) with a serial or RF link between them to transmit time information somehow.
Or just build your own time server using an old phone or radio receiver.
Maybe this can spark some ideas..?
Can the esp8266 join the same wlan as the locked down PC?
What are you able to do on the locked down PC which you want to use as the time source?
Can you run powershell scripts and specifically the command Invoke-WebRequest
on it?
Can you also set up scheduled tasks?
With those , you should be able to keep the esp8266 running with a reasonably current time which can be collected by the other PC.
If you cannot talk between the locked down PC and the esp8266 over the wlan and you've ruled out other time sources such a gps, radio time server (dcf77 etc.) and others then you could consider a technique similar to the one mentioned here for getting (time) information from the locked down PC. Using A Flashing LCD Monitor To Transfer Data | Hackaday . Basically writing something on the screen in a way which can be interpreted by a microcontroller.
What incidentally is the time drift on the isolated PC? Seconds per day or what?
Just how closely do you need to synchronize two computers that are not allowed onto the same network?
Does PC1 (on the corporate network) sync its clock with an outside NTP server, or an internal time server that is itself synced to an NTP server? If so, then syncing PC2 to any NTP server should keep the two computers fairly synchronized.
when PC1 is in an closed network
and PC2 is not part of that closed network
there are "no" legal ways to connect these two PCs.
If you can't connect PC2 to the closed network, you should not be able to connect any third party device like an ESP neither.
You can explain to your your network admin why it is necessary to sync the time of PC2 with PC1 and they will come up with a solution.
Or you just have to rely on the fact, that both PCs are very accurate.
Don't fight your security policies - you will loose.
This seems to be another college project where artificial hurdles are set to try to steer the students to a pre-conceived solution.
If PC2 needs to have an accurate time, just connect it to an accurate time source. I can't think of any reason why it needs to get it's time source from PC1 in the closed network. If they both have access to some external accurate time source, they will both be synchronized to the same time, at least as well as if PC2 gets it's time from PC1.
Another alternative, although ridiculously impractical for anything other than an academic exercise, and assuming that the OP can write and run scripts on the locked down PC, is to run a script which issues an audio signal (say AFSK or even morse code), through the speaker, onto which a Time Stamp is encoded. The ESP is fitted with a microphone and appropriate software to demodulate or otherwise interpret the time stamp and make it available somehow to the other PC.
And the real fun part is that if there are any SSL resources on the general WiFi network, every device on that network needs to have their time match up, even if that means being identically wrong. Brewing your own could muck things up nicely.
Ok, is the WiFi for general use under control of the IT department that controls the corporate network? If so, would the IT department be willing to set up an NTP server on that router that is synced to the same time source as the corporate network?
I see my question has already been answered.
If the company is that strict about not having anything outside synchronized to their internal time, then any attempt to circumvent that restriction is likely to get you fired.
Is the corporate network offset from actual UTC by some fixed amount, or are they varying that for some purpose?
A simple solution would involve a script on PC1 writing the current time to a serial port, ESP running NTP server. Even if someone hacks the ESP, all the info they could get is the time.
Some security policies disallow USB, for obvious reasons, so even that might be an issue.
However, there are some key requirements missing, e.g. whether a script can be run on PC1, what connections are allowed on PC1, what resolution of time synch is required.