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

    I swore I had RTC ntp_sync() working on my Lopy and now I can't get it working at all?

    Scheduled Pinned Locked Moved LoPy
    lopyntp sync rtc
    6 Posts 5 Posters 1.3k Views 5 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.
    • D Offline
      duhmojo
      last edited by

      Hi. I was writing a pair of Lora test apps to NTP sync the clock from one to the other, where ntp_sync() was used to setup the RTC. I swore I had this bit working yesterday and now I can't get anything working over

      import machine
      from machine import RTC
      from machine import UART
      from network import WLAN
      from network import LoRa
      
      import os
      import time
      import socket
      import pycom
      
      uart = UART(0, 115200)
      os.dupterm(uart)
      
      pycom.heartbeat(False)
      
      wlan = WLAN()
      if machine.reset_cause() != machine.SOFT_RESET:
          wlan.init(mode=WLAN.STA)
          wlan.ifconfig(config=('192.168.2.230', '255.255.255.0', '192.168.2.1', '192.168.2.3'))
      if not wlan.isconnected():
          wlan.connect(ssid='SSID', auth=(WLAN.WPA2, 'password'))
          while not wlan.isconnected():
              machine.idle() # save power while waiting
      print(wlan.ifconfig())
      
      print("Syncing RTC to NTP...")
      rtc = RTC()
      rtc.ntp_sync("pool.ntp.org", update_period=3600)
      while not rtc.synced():
          pass # save power while waiting
      print(rtc.now())
      

      Basically the ntp_sync() call and subsequent while loop just sits there while nothing syncs. I'm tempted to try and setup a wireshark sniffer on my router to watch what the Lopy is trying to do over the Wifi network.

      Any ideas? Thanks!

      1 Reply Last reply Reply Quote 0
      • D Offline
        duhmojo
        last edited by

        Ah... I think my machine.SOFT_RESET might have had something to do with it. When I hit the reset button on the unit it reloaded and reconnected to my wifi correctly I believe, because I started ntp_sync()ing correctly. Thanks.

        1 Reply Last reply Reply Quote 0
        • P Offline
          protean
          last edited by

          Did you ever solve this? I'm still having this issue, today, on a FiPy.

          T P 2 Replies Last reply Reply Quote 0
          • T Offline
            Thosch42 @protean
            last edited by

            @protean
            Have you tried to use a IP adress instead of the URL? Just for testing...

            1 Reply Last reply Reply Quote 0
            • P Offline
              Paul Thornton @protean
              last edited by

              @protean Can you confirm your on the latest firmware?

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                reidfo @Paul Thornton
                last edited by

                @paul-thornton I replied on another thread that I think you responded to that I have this issue with 1.20.0.rc0. I reverted back to my unmodified build of 1.19.0.b4 and the problem disappeared. I found that after machine.reset() the clock still would not sync reliably (or at all) and even sometimes after a hard reset by hitting the reset button.

                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