Build a Stratum 1 Time Server Using a Raspberry Pi Pico

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ธ.ค. 2022
  • Using a GPS module and a microcontroller board, like the Raspberry Pi Pico W, it is possible to make your own Stratum 1 time server. A Stratum 1 time server is directly linked to a reliable source of UTC time such as GPS. Sounds complex? Trust me it isn't. Let me explain!
    ---
    My videos about time, NTP, atomic clocks etc: • Time
    Let Me Explain T-shirt: teespring.com/gary-explains-l...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains

ความคิดเห็น • 75

  • @John.0z
    @John.0z ปีที่แล้ว +38

    As an older person, seeing this sort of solution being available, not just for home use, but at such a low cost, is beyond amazing.

    • @tonysheerness2427
      @tonysheerness2427 ปีที่แล้ว +1

      40 years ago time servers in computer rooms cost an absolute fortune,

    • @BrunoRegno
      @BrunoRegno ปีที่แล้ว +3

      I remember the first time I saw basically the same thing... It was made by NEC, it took a complete full rack, and it was nowhere near as accurate... And if the figure I was told was right, it costed $14 million... It served as the national timebase standard for the Republic of Panama and was part of a NEAX PBX. Surprising indeed.

    • @MikePreston-darkflib
      @MikePreston-darkflib ปีที่แล้ว +1

      @@BrunoRegno The problem with national telephone networks is that they are very reliant on accurate timebases. The old T1 standard for example pushed 1.5Mbits of data each second, if you are just a single bit out, you have unintelligible audio/data on the other end.
      Sure, you can try to recover the timing from the stream itself, but you should still have a single source of truth for the network where possible so you as a nation don't drift too much.

    • @mikapeltokorpi7671
      @mikapeltokorpi7671 ปีที่แล้ว

      This has been possible with serial interface and hand held GPS with serial bus (or by hacking to it with some wires as in this video) since late 90's. (I was working in Nokia with navigation based product back then). NMEA codes are in text format and in public domain. However GPS manufacturers tend to have proprietary non-text serial protocol, too. Both in the same serial interface and by default configured to work with NMEA protocol.

  • @alexlandherr
    @alexlandherr ปีที่แล้ว +5

    I’ve used a GitHub repo called “RPi-GPS-PPS-StratumOne”, a GNSS receiver and a Pi Zero 2 W as an NTP server.
    The repo has a bash script to do all the difficult setup for you and uses PPS for more precise disciplining of the Pi’s time.

  • @nico96gmail
    @nico96gmail ปีที่แล้ว +10

    I used a MikroTik router. It has NTP server and or client program already integrated in its OS. You plug a serial gps and you can synchronize it with gps. And there are really cheap MikroTik router and you get a good router with it.

    • @ErickBuildsStuff
      @ErickBuildsStuff 9 หลายเดือนก่อน +2

      Nico, please share the model number you have used. I would like to recreate your method.

  • @alanb76
    @alanb76 ปีที่แล้ว +13

    Nice to see this on a Pico, and using both cores. Please add PPS to make this accurate enough to be useful. A Stratum 1 Time Server needs to use the GPS PPS signal. The Serial data alone is not accurate enough for Stratum 1. Many low cost GPS boards have this signal in addition to the serial.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +5

      Glad you like it. The source code is in my GitHub repo, please feel free to extend it to include PPS.

    • @bruce348
      @bruce348 9 หลายเดือนก่อน

      Could you provide your github link please?@@GaryExplains

  • @calabrais
    @calabrais ปีที่แล้ว +1

    This is amazing, great work!

  • @wayne6220
    @wayne6220 ปีที่แล้ว +2

    Very impressive video. Thank you

  • @larry785
    @larry785 ปีที่แล้ว

    2:49 The free GPS antenna is the same as the better one, they are both patch type, however the one with the SMA connector has a built-in LNA.

  • @nils7c1
    @nils7c1 ปีที่แล้ว

    Thank you for the informative video! I wonder why you would need your own NTP time server, though? Do you see public NTP servers as a security risk, or consider them unreliable?

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +7

      There are lots of situations where running your own time server is beneficial, especially on any kind of private LAN with many machines. Imagine the amount of network traffic a data center creates just trying to sync the time. But the point of this project was more about the "fun" and hobbyist spirit than anything else.

  • @serotonin67
    @serotonin67 หลายเดือนก่อน

    Great video on how to. But I am a confusiast about your result at the end of this video. Why is your setup reporting it takes over 900ms ? That appears too slow. In comparison with connecting to network time from an internet NTP server. Why do this? What risk and reward is it to make a GPS NTP server to the SOHO network?

  • @cookinsteve9281
    @cookinsteve9281 ปีที่แล้ว +3

    Great timing!! Just picked up an ultimate GPS from Adafruit and have been wondering what to do with it. Surly something like this will justify the purchase

  • @timvw01
    @timvw01 ปีที่แล้ว

    Very cool

  • @DocNo27
    @DocNo27 ปีที่แล้ว +1

    I remember being impressed at GPS NTP sources that finally came down under $2500 in the 2000's. Ha!

  • @andreverville9492
    @andreverville9492 ปีที่แล้ว

    What about the NMEA message receiving time lag from the GPS receiver and further software delays? I thought you would be able to do your magic on the second, but refine the exact moment, af least to a few milliseconds, from the 1PPS (one pulse per second) signal directly from the GPS on one of the Pico's GPIO ports. The 1PPS IS the exact moment you can count on for time synchronization.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      That sounds like a good idea. The code is in my GitHub repo please feel free to extend it to monitor the pps on a gpio pin.

    • @Larry821
      @Larry821 8 หลายเดือนก่อน

      That's true you would absolutely need PPS to get desired accuracy from this kind of configuration. But the module used in the video does not even have PPS output so a different module would have to be used.

  • @scottdakers5957
    @scottdakers5957 ปีที่แล้ว

    Can you build the same using a WWVB radio?

  • @Ebu26
    @Ebu26 ปีที่แล้ว

    Gary will you start uploading speed tests again?

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      Sadly not at the moment. It wasn't popular.

  • @ericwelsh4853
    @ericwelsh4853 ปีที่แล้ว +1

    Wouldn't it have been a lot easier to just use the GPS data to set the hardware clock on a computer (any general purpose computer that can run Linux), then run the ntpd daemon as a stratum 1 time server on that computer?
    With this solution you would only need to write some code to extract the current time from the GPS data and use that to set the time.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      Of course there are other solutions, but that isn't the point is it.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      Also, did you see this video where I put an atomic clock in my PC? th-cam.com/video/YKApDtJjXU4/w-d-xo.html

  • @jayyoder667
    @jayyoder667 ปีที่แล้ว

    What is this Serial.printf() of which you speak? The compiler chokes with the message "Compilation error: 'class arduino::UART' has no member named 'printf'; did you mean 'print'?" Looking at the docs and google search seems to indicate the arduino ide can't do this. Am I missing something here?

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      The Raspberry Pi Pico implementation of Serial includes printf, for Arduino you will need to break it down into Print and Println.

    • @broadexuk
      @broadexuk หลายเดือนก่อน

      @@GaryExplains it fails on my PicoW at this point and when rem'ed out it then fails on setRX. Did something change and these are no longer in the language?

  • @hoekbrwr
    @hoekbrwr ปีที่แล้ว +1

    So luckily you could get your breath in order again after commenting the video, I HOPE!

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      Eh?

    • @hoekbrwr
      @hoekbrwr ปีที่แล้ว +1

      @@GaryExplains What I am trying to say it's about your speech at the end of the video which was very many words in a short time,😉

  • @allenlorenz
    @allenlorenz ปีที่แล้ว

    How accurate is your implementation ? how does it compare to using an an a normal ntp service on your machine ?

    • @MikePreston-darkflib
      @MikePreston-darkflib ปีที่แล้ว

      3 orders of magnitude worse - only gets the time to the nearest second and then has variable latency transmitting it to the network. Normal Stratum 1 NTP has sub-ms accuracy. This is produced by using an edge triggered pulse input (PPS) to lock in the exact point the time is correct.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      Many GPs modules offer a PPS pulse, it shouldn't be hard to incorporate that. As for the variable latency transmitting the time via NTP, of course that is true for all NTP implementations and NTP handles it.

    • @allenlorenz
      @allenlorenz ปีที่แล้ว

      @@GaryExplains Ok I am interested and curious, so your mission is accomplished in that. From reading the other comments, many question do come to mind. Given a normal computer ( window / linux ) how accurate is it with normal ntp server. How accurate is can it be using this gps time with and without pps. what if I wanted to go crazy have two dedicated raspberry pi core to measure a sensor, but they are two far away from each other for wifi signal, how good could I get them in making the measurement ?

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      I suggest you watch my other videos on time, I think you will find answers to many of your questions. Here is the playlist: th-cam.com/play/PLxLxbi4e2mYFmsJADZJSM7-wjbUF7udsC.html

  • @patdbean
    @patdbean ปีที่แล้ว

    Is GPS time more or less accurate than the land based atomic time like the clock at the national phisical laboratory in the UK .

    • @catchnkill
      @catchnkill ปีที่แล้ว

      @@guusossevoort6855 How is GPS compared with the clock in mobile network's basestations deployed?

    • @catchnkill
      @catchnkill ปีที่แล้ว

      @@guusossevoort6855 Nice to know. I asked because I read that basestations usually employ a very accurate clock. Now I know that it is the same as the GPS clock.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      You may find this video of mine interesting. I put an atomic clock in my PC! th-cam.com/video/YKApDtJjXU4/w-d-xo.html

    • @patdbean
      @patdbean ปีที่แล้ว

      @@GaryExplains interesting , but still gps based and a bit costly. See th-cam.com/video/S7JmCmbBKfA/w-d-xo.html

    • @DEtchells
      @DEtchells ปีที่แล้ว +4

      @@catchnkill Actually, I think most cellular base stations use GPSDOs (GPS Disciplined Oscillators), they’re much cheaper and more robust than rubidium oscillators and actually have better long-term stability. GPSDOs typically have a very stable ovenized crystal oscillator at their core, with a voltage input that can slightly shift the oscillator frequency. The oscillator output is divided down to a 1 pps signal, which is compared with the 1 pps output from the GPS module. If the oscillator’s output is leading the GPS signal, the oscillator’s control voltage is adjusted to slow it down, if it’s lagging, it’s sped up.
      The control loop has to be carefully designed and tuned to avoid any “jiggling” of the output frequency (called phase noise), but frequency deviations of less than 1 part in 10^10 are easily achievable. (That is, an error or less than 0.01 Hz in a 10 MHz clock signal.)

  • @blindeye-lw6ev
    @blindeye-lw6ev 10 หลายเดือนก่อน

    hey guys just trying to get this script to run in arduino IDE but my serial1 isnt a variable its a macro and i am always getting the error code Compilation error: 'class arduino::UART' has no member named 'setRX'

    • @GaryExplains
      @GaryExplains  10 หลายเดือนก่อน

      What board are you using?

    • @blindeye-lw6ev
      @blindeye-lw6ev 10 หลายเดือนก่อน

      @@GaryExplainsPi Pico W like you

    • @GaryExplains
      @GaryExplains  10 หลายเดือนก่อน

      Oh. I have a vague memory of something similar but I can't remember right now what it was. I am away from my desk for a few days so I don't think I can help much.

    • @blindeye-lw6ev
      @blindeye-lw6ev 10 หลายเดือนก่อน

      @@GaryExplainsI have time

  • @tubeDude48
    @tubeDude48 ปีที่แล้ว +1

    Gary, how about a link to all the devices you purchased!

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +2

      To be honest I can't even remember where I got the GPS module, they are ubiquitous. Any place that can sell you a Pico can normally sell you a GPS module.

    • @tubeDude48
      @tubeDude48 ปีที่แล้ว

      @@GaryExplains - I wrote down all the info. I'll check that way. YES, I don't like the other-one either!

  • @pleappleappleap
    @pleappleappleap ปีที่แล้ว

    There are a bunch of Stratum-1 sources on the internet that don't rely on GPS, but instead sync directly to UTC, which is what GPS is synced to.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      And?

    • @pleappleappleap
      @pleappleappleap ปีที่แล้ว

      @@GaryExplains "In fact, the whole Internet is probably synchronized, time is synchronized using the signal that comes from the GPS satellites."

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      Could you give me a list of NTP servers that use an atomic clock rather than GPS? I couldn't find such a list.

    • @pleappleappleap
      @pleappleappleap ปีที่แล้ว

      @@GaryExplains I'll see what I can dig up. There are also ones that use cellular signals, like CDMA.

    • @Joeyhelmond0492
      @Joeyhelmond0492 11 หลายเดือนก่อน

      @@pleappleappleap it's been a month, where's the list?

  • @vanhetgoor
    @vanhetgoor ปีที่แล้ว

    Most the time I am inside the house, the GPS reception is miserable there. I have to walk outside the house to know where I am. Only then a GPS receiver can tell me that I am at the back of my house and not in it. On the other hand, in the telephone signal is also the time transmitted. Maybe UMTS / GPRS can be used better instead of the GPS signal. The receiver is just as cheap as the GPS receiver. Often it can be harvested from an old phone, the Chinese even sell these receivers, desoldered from telephones whos only fault is being from last years. And maybe using an old mobile telephone receiver could also give extra information, like name of the telephone company and the exact GPS location of their mast. Recording this information could give you an alibi if you are at the same time somewhere else doing things you shouldn't. (Omnipresence is not rare or so, many have this!)

  • @rayclutts3107
    @rayclutts3107 ปีที่แล้ว

    Please add the source code to this project.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      It is in my GitHub repo, a quick Google search normally gives my repo as the first result.

  • @tubeDude48
    @tubeDude48 ปีที่แล้ว

    Where's a link to the code!?

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      The code is in my GitHub repo, just Google for "Gary Explains GitHub".

    • @tubeDude48
      @tubeDude48 ปีที่แล้ว

      @@GaryExplains - Didn't work! At on time you put it in one of your comments and it took m their immediately. Nuts!

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว +1

      Try here: github.com/garyexplains/examples/tree/master/ublox_tinygps_ntp_server_pico

    • @tubeDude48
      @tubeDude48 ปีที่แล้ว

      @@GaryExplains -Thank You! Yes, this is it! 👍👍👍 This is what I was after!

  • @jxtq27
    @jxtq27 ปีที่แล้ว +1

    On the one hand this project is kinda cool, but on the other it's not done and especially not explained in a way to provide any benefit compared to using an ntp server on the Internet. Just because you're stratum 1 doesn't mean that you're accurate.

    • @GaryExplains
      @GaryExplains  ปีที่แล้ว

      I was aiming more for the "cool" aspect.

    • @brendancooney9401
      @brendancooney9401 6 หลายเดือนก่อน

      Please explain!!