Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    RTC ntp time server not working on static ip

    Scheduled Pinned Locked Moved Firmware
    lopy
    17 Posts 6 Posters 6.7k Views 7 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PiAirP Offline
      PiAir
      last edited by

      I can confirm this behavior.
      What 'fixed' it for me was to not use 'pool.ntp.org' but the/a actual IP address: 128.199.44.119.

      >>> import machine
      >>> rtc = machine.RTC()
      >>> rtc.ntp_sync('pool.ntp.org', 3600)
      >>> print(rtc.now())
      (1970, 1, 1, 0, 0, 39, 726100, None)
      >>> rtc.ntp_sync('128.199.44.119', 3600)
      >>> print(rtc.now())
      (2017, 5, 14, 16, 3, 6, 118200, None)
      

      Note: this is not a real fix, but it appears that, despite setting the DNS server, the LoPy can't always get the IP address
      For example, if I use socket.getaddrinfo() I often get an IP address, but not always:

      >>> wlan.ifconfig() ('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('0.0.0.0', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('122.175.14.128', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('16.88.252.63', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('0.0.0.0', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('0.0.0.0', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('0.0.0.0', 80))]
      >>> socket.getaddrinfo('pool.ntp.org', 80)
      [(2, 1, 0, '', ('80.87.252.63', 80))]
      
      

      The info of my LoPy:

      >>> import os
      >>> os.uname()
      (sysname='LoPy', nodename='LoPy', release='1.6.9.b1', version='v1.8.6-535-g84855b2b on 2017-03-24', machine='LoPy with ESP32', lorawan='1.0.0')
      
      

      I will upgrade to the latest firmware asap to check if it is fixed there, but have to document a project I have been working on this weekend first.

      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @PiAir
        last edited by livius

        @PiAir
        What if you do the same for "normal" address not ntp e.g www.pycom.io?
        Ntp pool count requests and if you ask too frequent then you can have problem.

        think about people first, then computers

        PiAirP 1 Reply Last reply Reply Quote 0
        • PiAirP Offline
          PiAir @livius
          last edited by

          @livius With other websites (my own) I have the same problem: sometimes it returns the IP-address, other times just zero's. Same as with the ntp.org site.

          L 1 Reply Last reply Reply Quote 0
          • L Offline
            livius @PiAir
            last edited by

            @PiAir
            Then it looks like some error. In firmware?

            think about people first, then computers

            PiAirP 1 Reply Last reply Reply Quote 0
            • PiAirP Offline
              PiAir @livius
              last edited by

              @livius Don't know yet, I wanted to finish my write-up of connecting a GPS receiver first before disconnecting stuff and upgrading the firmware. Could be something fixed in the latest version.

              1 Reply Last reply Reply Quote 0
              • PiAirP Offline
                PiAir
                last edited by

                Problem also in latest fimware

                >>> import os
                >>> os.uname()
                (sysname='LoPy', nodename='LoPy', release='1.6.13.b1', version='v1.8.6-607-g9c8a0e9e on 2017-05-01', machine='LoPy with ESP32', lorawan='1.0.0')
                >>> wlan.ifconfig()
                ('192.168.0.191', '255.255.255.0', '192.168.0.1', '213.46.228.196')
                >>> import machine
                >>> rtc = machine.RTC()
                >>> rtc.ntp_sync('pool.ntp.org', 3600)
                >>> rtc.now()
                (1970, 1, 1, 0, 2, 21, 96633, None)
                >>> rtc.ntp_sync('128.199.44.119', 3600)
                >>> rtc.now()
                (2017, 5, 16, 6, 3, 44, 126771, None)
                
                1 Reply Last reply Reply Quote 1
                • B Offline
                  bucknall
                  last edited by

                  Could you please create an issue outlining this on our GitHub repo? This is where Daniel and the team head first to tackle outstanding firmware issues/bugs :)

                  https://github.com/pycom/pycom-micropython-sigfox/issues

                  Developer Evangelist - Pycom

                  PiAirP 1 Reply Last reply Reply Quote 1
                  • PiAirP Offline
                    PiAir @bucknall
                    last edited by

                    @bucknall Done.

                    1 Reply Last reply Reply Quote 1
                    • PiAirP Offline
                      PiAir
                      last edited by

                      @Rorence said in RTC ntp time server not working on static ip:

                      I have no idea about how to fix this error. I just want to search answers on here.

                      For now, there are two options:

                      1. use dhcp instead of a fixed IP:
                      wlan.ifconfig(0,config='dhcp')
                      
                      1. if you really have/want to use a fixed IP, use an IP-nummer for the ntp server instead of a FQDN. For example
                      rtc.ntp_sync('128.199.44.119', 3600)
                      

                      instead of

                      rtc.ntp_sync('pool.ntp.org', 3600)
                      

                      An issue has been posted with regards to this error, but no time line has been added for that. Once it has been fixed in the firmware, you shouldn't have to worry about it anymore. :)

                      1 Reply Last reply Reply Quote 0
                      • S Offline
                        shariq @livius
                        last edited by

                        @livius does ntp works with internet only? in case I want to connect my pycom to update time for rtc.

                        robert-hhR 1 Reply Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @shariq
                          last edited by

                          @shariq Obviously you can set up your own ntp server, if you like, which is called instead of the ntp server pool on the internet. if you get the date & time from a different source, like an external rtc, you can use rtc.init() to set the local date & time.

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom