Home       Guestbook

Section   Top      Arduino IDE     Electronic Parts     Case Assembly       Schematic        Vero Board Layouts      3D Printed Parts    Operation    Downloads

 

 

 

 

Stratum 1 GPS ESP8266 NTP WIFI Time Server v2

 I wanted a reliable time server for some of my NTP clocks as pool.ntp.org would sometimes fail for a day or so and I could never find out why.

I decided to build a my own GPS NTP Time server and found Mitch Markin's design which I could easily modify to suite my requirements.

The 3D files to build this project can also be found on Thingiverse.

 

THE GPS SATELLITE SYSTEM


The 31 satellites that currently make up the GPS space segment are orbiting the Earth about 12,000 miles above us.

These satellites are constantly moving, making two complete orbits in less than 24 hours. They travel at speeds of roughly 7,000 miles per hour.

Small rocket boosters keep each satellite flying on the correct path.


GPS satellites circle the Earth twice a day in a precise orbit.

Each satellite transmits a unique signal and orbital parameters that allow GPS devices to decode and compute the precise location of the satellite.

GPS receivers use this information and trilateration to calculate a user's exact location.

Essentially, the GPS receiver measures the distance to each satellite by the amount of time it takes to receive a transmitted signal.

With distance measurements from a few more satellites, the receiver can determine a user's position and display it electronically.


 

The time server is used to drive my collection of NTP clocks.

 

 

This design replaces v1 and uses Mitch Markin's latest design with 2 OLED displays.

The board layout and controls of my original design remain the same but the front panel has been re-designed to accommodate the extra OLED display.

I have changed Mitch Markin's v2 design slightly by omitting the 3 way switch and instead the 2nd OLED display alternates between server info and location info.

A PIR also turns the displays off when no one is in the vicinity..

I have also fitted larger 1.3" OLED displays as my NTP server is fitted high up on a wall so the displays are easier to read.

 

 

Clock Strata
NTP uses a hierarchical, semi-layered system of time sources. Each level of this hierarchy is termed a stratum and is assigned a number starting with zero for the reference clock at the top.

A server synchronized to a stratum n server runs at stratum n + 1.

The number represents the distance from the reference clock and is used to prevent cyclical dependencies in the hierarchy.

Stratum is not always an indication of quality or reliability; it is common to find stratum 3 time sources that are higher quality than other stratum 2 time sources.[a] A brief description of strata 0, 1, 2 and 3 is provided below.



Stratum 0
These are high-precision timekeeping devices such as atomic clocks, GNSS (including GPS) or other radio clocks.

They generate a very accurate pulse per second signal that triggers an interrupt and timestamp on a connected computer.

Stratum 0 devices are also known as reference clocks.

NTP servers cannot advertise themselves as stratum 0.

A stratum field set to 0 in NTP packet indicates an unspecified stratum.


Stratum 1
These are computers whose system time is synchronized to within a few microseconds of their attached stratum 0 devices.

Attachments can be direct, GPS or DCF77 etc.

Stratum 1 servers may peer with other stratum 1 servers for sanity check and backup. They are also referred to as primary time servers.


Stratum 2
These are computers that are synchronized over a network to stratum 1 servers.

Often a stratum 2 computer queries several stratum 1 servers.

Stratum 2 computers may also peer with other stratum 2 computers to provide more stable and robust time for all devices in the peer group.

Stratum 3
These are computers that are synchronized to stratum 2 servers.

They employ the same algorithms for peering and data sampling as stratum 2, and can themselves act as servers for stratum 4 computers, and so on.
The upper limit for stratum is 15; stratum 16 is used to indicate that a device is unsynchronized.

The NTP algorithms on each computer interact to construct a Bellman-Ford shortest-path spanning tree, to minimize the accumulated round-trip delay to the stratum 1 servers for all the clients

 

 

Credits

This project uses an ESP8266 NodeMCU module and GPS receiver to produce a local Stratum 1 WIFI time signal and  is housed in a wall mounted 3D printed enclosure.

This circuit is based on a Stratum 1 Time Server designed by Cristiano Monteiro and re-designed by Mitch Markin.

Cristiano Monteiro based his code on the work of http://w8bh.net/  look under Arduino Projects/Clocks.

 

 

 

 

 

Arduino/Visual Studio Code

In order to program the ESP8266 in version 1 I used Visual Studio Code.

I was unable to get Visual Studio Code working on v2 so I used the Arduino IDE 2.3.0 instead following Mitch Markin's instructions.

Make sure you have the ESP8266 extensions installed in the IDE and they are up to date.
Create a directory on your computer called GPSTimeServer    
Copy the main.cpp file from the src directory in this repository to your GPSTimeServer directory  
Rename the file GPSTimeServer.ino    
Also copy the definitions.h file from the includes directory in this repository to your GPSTimeServer directory  
Don't change the name    
Use the library manager to search for and add the following libraries:
Time     Michael Margolis  v1.6.1
RTC      Makuna   v2.3.5  (must be this version)
TinyGPS  Mikal Hart  v13.0.0
U8g2     Oliver  v2.33.15
Set the board to NodeMCU 1.0 (ESP-12E Module)  
Set the COM port  
Compile and upload     

 

 

 

 

 

 

 

Parts Required

ESP8266 NodeMCU

 

PIR HC-SR501 Module

I have used a PIR module to turn off the OLED display when no one is in the room this ensures the long life of this OLED display.

The PIR has 2 trimmer resistors for adjusting sensitivity and also length of time the PIR & display stay activated.

 I had tried the simple version of the PIR see image below, but had false triggers/noise from the ESP8266.

 

 

I kept the small diffuser from the simple PIR and replace the larger diffuser with it.

 

 

 

 

 

GPS Module

GY-NEO6MV2 NEO-6M GPS Module with PPS

In order to capture the GPS signals, a GPS chip is needed in the form of a module. Make sure your GPS module has PPS “Pulse Per Second” output.

PPS is a squared wave electrical signal with a less than one-second width but with a precise 1 Hz frequency. 1.000 pulses per second.

This signal is of vital importance to keep a time server synchronized with the atomic source, by synchronizing top of the second shift with PPS input.

GPS Antenna

Waterproof Active GPS Navigation Antenna with 28dB gain.

This antenna allows me to fix it externally to get a good reception.

Make sure you antenna comes with a SMA to IPEX converter cable.

 

 

 

 

RTC

The RTC stores the time and date in battery backed memory when power is removed.

 

   

 

Modification of DS3231 AT24C32 I2C Precision Real Time Clock Module

There has been a possible fire risk associated with the circuit design of these modules when used with rechargeable bateries.

I use a non rechargeable battery and remove charge resistor R5 see details below.

 

My clock uses a DS3231 AT24C32 I2C Precision Real Time Clock Module instead of a DS1307.

The module comes supplied with a Lithium-Ion rechargeable battery see diagram above. I use a non rechargeable battery so have removed resistor R5

from the module as below.

 

Location of R5 on the DS3231 module.

 

Charging Resistor R5 removed.

 

 

 

 

 

1.3" OLED Display

This clock uses 2 off 1.3" inch 128x64 I2C SH1106 OLED display.

The display uses the same 2 wire bus as the RTC.

0.9" OLED displays can  be used instead just change the code to suit the OLED type and I2C address.

The front case will need the display cutouts reduced accordingly.

 

 

Rear of the OLED

Make sure the address is selectable on the rear of the OLED as both addresses will be required.

Move the resistor to change the address on one of the boards from 0X78 to 0X7A and make sure this is set in the code.

 

 

 

 

 

The Case

The case is made up from 3 separate 3D printed parts.

Below back box and plate for the rear of the front box.

The front case is fixed to the rear box with 4 off 3mm Allen bolts into M3 brass inserts.

 

The case is labeled using inkjet transfer paper.

See details on my DCF77 Analyzer clock page.

 

Case Assembly

 

Starting from the rear box.

 

Before assembling the Server mark fixing screw positions on the wall and temporarily fix in place. The screws should be tight enough to allow the box to be slid in place once the server has been assembled.

Mark  the position of the cable hole on the wall (if hidden wiring is used).

 

Slid the rear box off the mounting screws.

Glue (hot melt glue works well) the top Vero Board clip in place in the bottom of the box against the top side with rebate facing down.

 

Slide in the assembled Vero Board including the Vero Board Spacer into the rebate of the glued in strip.

The Vero Board Spacer is screwed to the rear of the Vero Board with M2 self tappers.

This allows space for the solder joints and screw heads holding the case to the wall.

I wire short 5v power and GPS coax tails at this stage and feed then through the cable hole.

 

Insert the 3 Vero Board Clips onto the Vero Board ensuring the rebates face down & in towards the Vero Board.

 

Lay the rear front panel over the rear box lining up the 4 inner corner holes and fix the 3 Vero Board clips to the rear front panel using 3 off M3 self tappers.

I have made the Veroboard clips narrower than on the previous version.

 

 

If disassembling in the future these 3 screws holding the Vero Board mounting clips to the rear front panel can be left in place.

 

 

This is a view from below with the rear box removed showing how the the 4 Vero Board clips hold the board in place.

Note the black Vero Board spacer in place. this holds the Vero board off the wall fixing screws.

 

 Using 4 off M3 self tappers fix the rear front panel to the rear box.

Note the M3 brass inserts fitted to the corners of the rear front panel.

The front panel M3 bolts are screwed into these inserts.

 

This picture shows where the switch panel, OLEDs, indicator LEDs and the PIR are located over the Vero Board below.

These items are of course fixed to the front panel.

 

This picture shows the switch panel, OLED, indicator LEDs and the PIR are located on the rear of the front cover.

They are all held in place with hot melt glue.

 

Plug in all wires from the Vero Board to the front panel components.

The front cover in place with all components fitted is then placed over the rear box locating over the rear front cover plate.

 

 

Using 4 off M3 bolts fix the front cover in place through the four brass inserts in the corner holes in the rear front cover plate.

 

 

Connect the 5v and GPS tail connectors to the wiring coming out of the hole in the wall and then slide the server in place over the fixing screws.

I have used an external GPS aerial fitted on the roof above my office with the time server located high up near the ceiling.

 

Case Rear View Sections

Rear view of completed case

 

With the rear box removed the 4 rebated clips that hold the Vero Board to the base of the rear box can be seen.

Note the black Vero Board spacer fixed to the rear of the Vero Board. 

 

 

 

Vero Board & clips removed to show the rear front cover plate fixed to the front cover.

 

Rear front cover plate removed showing locations of the GPS, OLED, Swich board and LEDs on the rear of the front panel.

 

Front panel rear showing holes for he GPS, OLED, Swich board and LEDs.

 

 

 

 

 

 

Schematic

Click to view full size version

ESP8266NODEMCU Pin Outs

 

 

 

 

 

Vero board Layouts

Click to enlarge

 

 

 

 

Completed Vero Board with spacer below

 

 

Vero Board Layout Control Switches

 

 

 

Vero Board mounted inside the rear box.

The screws hold the Vero Board to the Vero spacer not the case.

The Vero Board is held in place by 3D printed clips.

The first seen in the pic below is hot melt glued to the rear case and has a rebate to hold the Vero Board.

 

3D printed Vero Board clip showing rebate that holds one side of the Ver0 Board in place.

 

 

 

There are 3 other Vero Board clips also so with rebates that fix to the rear front panel cover with M3 self tappers.

Vero Board clips showing Vero Board rebate.

 

 

 

 

 

 

 

 

3D Printed Parts

Front case with cutouts.

 

Rear view showing rebate for the OLED screens.

 

The rear front plate fixes first to the rear box with M3 self tapers using the inner four corners holes then to the front box recess with M3 bolts using the four outer corner holes fitted with brass inserts.

The other 3 holes fix 3 of the Vero Board clips to this panel.

 

Rear Case

 

GPS Spacer

This simply fits under the end of the GPS Board to support if off the Vero board.

Fixed to the Vero Board with hot melt glue.

The GPS module can be fixed to the spacer with self tappers if required.

RTC Spacer

Due to the way I have spaced the RTC Module on the Vero Board there is a slight overlap of the RTC and the GPS module.

This spacer keeps the RTC Module off the GPS module.

Fixed to the Vero Board with hot melt glue.

Vero Board Support/Spacer

This part is fixed to the bottom of the Vero Board with M2 self tappers through the top of the Vero Board.

It keeps the soldered joints of the bottom of the box. allows space for the fixing screw heads and supports the Vero Board.

Vero Board Clip

This part has a rebate in the bottom to fit over the Vero Board with spacer fitted. It is hot melt glued in place.

The Vero Board with spacer slides under the rebate ready to be locked in place with the other 3 spacers.

Vero Board Clip

These are slimmer, take a lot less time to print and take up less space in the case than the clips used in version 1.

This part has a rebate in the bottom to fit over the Vero Board with spacer fitted.

Once 3 of these are fixed to the rear front plate with M3 self tappers along with the rear vero Board clip they will lock the Vero Board in place.

3 off required.

 

 

Below bottom view showing the Vero Board held in the 3 clips plus the rear clip

 

Cable Tie Fixing

Hot melt glued to the back of the front case provides support to tie the wires from the modules.

This helps keep strain off the connections.

Vero Switch Spacer

Fits over the switches on the switch panel to space the switches off the front panel to ensure correct protrusion of the switch covers through the front case.

 

 

 

 

Operation

 

PIR

The PIR can be adjusted for sensitivity and time on after trigger.

 

Controls

Pressing the Red Reset button momentarily resets the ESP8266 and reloads the code.

 

Pressing the Yellow WIFI Button momentarily turns the WIFI sever off.

Pressing again turns it on.

 

Indicators

Yellow LED illuminated indicates that the WIFI server is On.

Red LED shows the PPS pulse and once synchronized to satellites it will flash once per second.

Green LED illuminates when the signal is locked.

 

OLED Displays

 

There are two OLED displays.

 The left display shows the number of satellites connected -line 1 left, resolution line 1 right,  date line 2 and UTC time line 3.

The right hand display alternates between Server and location info.

Server displays number off connection on row 1.

Row 2 the last connected IP address with the time of connection on row 3.

Location displays the precise location of the server.

 

 

Setting up the Time Server

 The server will require a name and a password if you do not want the server open.

This is done in line 15 and 16 of the definitions.h  in the code.

#define APSSID "TimeServer" // Default AP SSID
#define APPSK "password" // Default password

The current sever name is TimeServer with a Password of password.

 

Power up the server and you should get a the WIFI LED illuminating after a few seconds.

After a short time the Green lock LED should light followed by the Red PPS LED flashing every second.

If you open your phone WIFI connection you should be able to see the server listed by the name you set above.

.

 

Connect to the server by logging in with your phone using your password set in code

Once connected enter the IP address in your phone browser 192.168.4.1

You should get the message "You are connected"

You should now be able to test the server by connecting your NTP clocks using the  ssid & password set above.

 

 

 

 

 

 

 

 

 

 

 

 

 

Front Panel Text Layout

I have included a front panel layout so it can be modified to suit.

Zip includes TurboCAD, and PNG files.

Note print without the boxes and circles but leave the cross hairs in place for positioning the inkjet transfer.

I leave the outside box as well as a trimming guide i.e. I cut the transfer inside this line.

In the previous version the transfer was fixed to the front panel as one transfer.

In version 2 the transfers are printed in one then cut out and fixed to the front panel individually.

 

 

Download Label for TurboCad and also in png format.

 

 

 

 

Arduino IDE Code Download

 

 

 

 

3D Parts Download

Includes stl and FreeCAD files