Page 1 of 1

ntptime.py howto change host

Posted: Sun Jan 06, 2019 2:57 pm
by spaceagejohnny
is the line:
host = "pool.ntp.org"
in ntptime.py changeable?
I copied this from https://github.com/micropython/micropyt ... ntptime.py.
is this even the file used by 'import ntptime' ?
I would like to run several esp8266 boards on an internal net or sub net that is not connected to the internet. ntp server would be a raspberry pi (I have that serving other computers - works well).
how can I change the host, and where.
hope I don't have to go messing around with the esp8266.---.bin file as I'm not sure I would be capable of doing that.
Thanks,
John

Re: ntptime.py howto change host

Posted: Mon Jan 21, 2019 4:32 pm
by tylersuard
Ok yes, you can change the host. In the code you mentioned, the url is just set to the variable name "host". So you can change that. Also, for the number next to it in socket.getaddrinfo(host, 123), the "123" is just a random number, using but the program will use that as the port number for connection. You can use whatever port you want for that. BUT, if you are using your own server to provide the time, you need to be sure that when you send information to that server using s.sendto(NTP_QUERY, addr), you will get back the time using s.recv(48).

* as a side note, if you know the IP address of your own server, you don't need to even use the url getaddrinfo thing. You can just do s.sendto(NTY_QUERY, 1.23.45.67.8 90) (where 1.23.45.67.8 is the IP address of your server, and 90 is the port to which you want to connect).

Re: ntptime.py howto change host

Posted: Mon Jan 28, 2019 6:03 pm
by spaceagejohnny
* as a side note, if you know the IP address of your own server, you don't need to even use the url getaddrinfo thing. You can just do s.sendto(NTY_QUERY, 1.23.45.67.8 90) (where 1.23.45.67.8 is the IP address of your server, and 90 is the port to which you want to connect).
[/quote]

I changed it .. works great
thanks
John