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

    Syncing the clocks of Lora/Pymeshed Devices

    Scheduled Pinned Locked Moved Discussion
    3 Posts 2 Posters 300 Views 3 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.
    • B Offline
      boda
      last edited by

      I am building a testing series of meshed devices that are listening for Bluetooth Beacon advertisements. But I need to sync the clock of the nodes to get accurate measurements. Is there any way I can do something like this using PyCom's libraries? Thanks!

      For reference, "PainlessMesh" is a wifi-meshing library that syncs the node(s) clocks: https://gitlab.com/painlessMesh/painlessMesh/blob/master/examples/startHere/startHere.ino

      O 1 Reply Last reply Reply Quote 0
      • O Offline
        oligauc @boda
        last edited by

        @boda Please find example code below on how the sync clock.

        from machine import RTC
        from network import WLAN
        import machine
        
        wlan = WLAN(mode=WLAN.STA)
        wlan.connect('your ssid', auth=(None, 'your pass'))
        while not wlan.isconnected():
            machine.idle()
        print('WiFi connected')
        
        rtc = machine.RTC()
        rtc.ntp_sync('pool.ntp.org', update_period=3600)
        
        while not rtc.synced():
            machine.idle()
        
        print("RTC NTP sync complete")
        print(rtc.now())
        
        B 1 Reply Last reply Reply Quote 0
        • B Offline
          boda @oligauc
          last edited by

          @oligauc Thank you!

          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