This is only a preview of the April 2018 issue of Silicon Chip. You can view 47 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "230VAC Thermopile-based Heater Controller":
Items relevant to "Low cost, Arduino-based 3-Axis Seismograph":
Articles in this series:
Items relevant to "The Clayton’s “GPS” time signal generator":
Items relevant to "El Cheapo Modules 15: ESP8266-based WiFi module":
Purchase a printed copy of this issue for $10.00. |
How to use Internet Time with GPS clocks
The “Clayton’s”
GPS Time Source*
We’ve produced a number of GPS-based clocks over the last few years
but they can be problematic if you can’t get a GPS signal – deep inside
a building, for example. But how about this for a clever alternative:
program a cheap WiFi Module to act as a time reference, kept accuracy
via the internet! It pretends to be a GPS unit, so any GPS clock can use it!
By Tim Blythman
C
The beauty of this system is that it presents this time
lock projects that depend on a GPS source as the
reading as if it’s coming from a GPS module, so you don’t
time reference can be relied on as being highly achave to make any changes to the clock hardware or softcurate – after all, the time code in the GPS signal is
ware. You could build any of our GPS clocks and with just
derived from an atomic clock.
a small amount of extra effort, get them to run off Network
The most recent GPS-synchronised clocks we’ve pubTime Protocol (NTP) time via your existing WiFi network.
lished are the Analog Clock Driver (February 2017;
It should even work with commercial, pre-built GPS clocks.
siliconchip.com.au/Article/10527 and the High Visibility
In fact, this concept can be used with any device that
6-Digit LED GPS Clock (December 2015 & January 2016;
uses a GPS module to get a time signal.
siliconchip.com.au/Series/294).
It doesn’t need to be a clock. But keep in
And in the case of the High Visibility
mind that it may not be accurate enough
6-Digit LED GPS Clock, it requires no
to use as part of a time reference system.
manual adjustments for daylight saving
or time zones as it can determine these
How it works
adjustments based on location data from
As already noted, we’re using an
that same GPS module.
ESP8266 module which is available preUnfortunately, all GPS-based clocks
assembled, already having an onboard
are subject to one caveat: they won’t
WiFi transceiver. We program it using the
work well without having a clear
Arduino IDE. IDE stands for Integrated
“view” of the sky, so that they can pick
Development Environment, which means
up the signals from multiple GPS satthat it lets you write code for an Arduino,
ellites. While GPS signals can usually
then compile it and upload it to the board.
be picked up indoors, whether you will
And note this point; while we are usget them at a given location depends on
ing the Arduino IDE, we are not using an
the construction of the building – and
Arduino Uno or related Arduino board!
even the weather.
The software we have developed
But many readers will already have
fetches the current time and date from
a WiFi network at home and that gives The NTP WiFi
module we chose, the
an NTP server via the internet, then it
an alternative source of time that’s al- ESP8266 WeMos D1 Mini Module
uses this timestamp in combination with
most as accurate (far more accurate than (available from Jaycar, Cat XC-3802).
its internal clock to generate a stream of
you’re ever likely to need!). So why not
GPS-compatible (NMEA encoded) data,
take advantage of it?
including time signals.
This project takes a cheap and readily available ESP8266
It is possible to estimate your location based on your
WiFi/ARM processor module and uses it to fetch accuinternet IP address, so our software does just that, transrate time readings from the internet and pass it through
lating the IP into a latitude/longitude pair using an online
to the clock.
*The time source you have when you don’t have a GPS time source!
58
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
service. So if you are using this module with the High
Visibility 6-Digit LED GPS Clock, it can use these coordinates to calculate the correct time zone and daylight saving
rules, and it will display the correct local time.
While we’ve found that the estimated position can sometimes be a few dozen kilometres out, in 99.99% of cases,
this will still be in the same time zone, so the time displayed will still be correct.
But if you are using a proxy or VPN, this information
may be inaccurate, as the IP service may return coordinates
based on your proxy location. But for most home WiFi setups, this should not be a problem.
NMEA GPS data
NMEA stands for National Marine Electronics Association; NMEA 0183 is a specification for communication between marine electronics systems, including GPS receivers. Pretty much all GPS receivers produce serial data in
this format, which is why we’ve designed our unit to use
this same standard.
We’ve described the NMEA 0183 standard in detail in the
past and we will give some examples below. But for now,
you just need to understand that the data is sent over an
RS-232 (or similar) serial link, in ASCII text format, with
each distinct line being considered a “sentence”.
Each sentence is prefixed with a code which indicates
what data is contained within. So units receiving this data
can skip any sentences with codes that they don’t understand. Each sentence contains a series of values separated
by commas and terminated with a checksum, so that data
which is corrupted during transmission can be ignored.
Since the information from a GPS receiver is simply serial ASCII data, it’s easy for a microcontroller to mimic. A
GPS receiver will usually transmit around 3-10 sentences,
sent once per second. But for our clock projects, only two
are important.
These are the RMC (minimum recommended GPS) and
GSA (fix validity and active satellites) sentences. RMC contains the GMT/UTC time, date, latitude, longitude, speed,
course and magnetic variation data. GSA indicates whether
the unit has obtained a GPS fix and a partial list of the satellite Ids used to obtain that fix. See Fig.1 for an example.
This was taken from a real GPS receiver.
Without an actual GPS receiver, the latitude, longitude
and satellite status will have to be fabricated or estimated;
the only information which absolutely needs to be correct
is the time and date.
We’ve also written the software to produce a “dummy”
status sentence to show some information about the status of the WiFi connection. Since this is a sentence type
that the clocks are not programmed to interpret, they will
ignore it. But you could monitor the output of the serial
port using a PC as a debugging aid.
What is a Clayton’s GPS Time Source?
Some readers (particularly younger ones) may not understand
the reference to “Clayton’s” – arguably, one of the most famous
tag lines to come out of Australian advertising (OK, that and “NOT
HAPPY, JAN!”).
Back in the 1970s and 80s, there was a non-alcoholic drink
called “Clayton’s” which was advertised as “the drink you have
when you’re not having a drink”. They, of course, meant alcohol.
Very quickly, the phrase entered the Aussie vernacular; it meant
the (fill in blank) you had when you’re not having (or possessing,
or owning, or using etc etc etc!) a (fill in blank).
Our “Clayton’s” GPS time source is therefore the time source
you have when you don’t have access to GPS – whether that’s
because you don’t have one (!) or because it doesn’t have the
clear view of the (northern in Australia) sky and so cannot receive
the valid GPS signal.
Network Time Protocol
NTP is one of the oldest internet protocols still in use.
It’s used by pretty much every computer and smartphone,
to keep their clocks accurate.
NTP, designed to be simple and fast so that the overhead of checking and adjusting the time is minimised, is
well suited to implementation on a small device like an
ESP8266 module. It’s also designed to compensate for networks delays.
Ultimately, NTP time comes from a source which typically has a caesium atomic clock. From there, the time is
distributed to other nearby servers. Our unit will most likely be getting its data via a path that is three or more levels
(or “strata”) removed from the atomic clock.
In other words, we’re synchronising our time to servers which synchronise their time to other servers which
synchronise their time to other servers which have atomic
clocks attached. Whew!
But you can still expect the resulting time to be accurate
within about 10ms. Given that we are transmitting this data
$GPRMC,013115.000,A,3345.6276,S,15116.8171,E,0.00,157.
35,140218,,,A*76
$GPGSA,A,3,05,31,25,29,02,,,,,,,,2.22,2.02,0.92*02
Fig.1: an example of typical RMC and GSA sentences from
a real GPS receiver. The RMC sentence provides basic fix
data such as latitude, longitude, speed, heading, and most
importantly, date and time. In this case, the UTC time is
1:31:15am and the date is 14/02/2018.
siliconchip.com.au
Celebrating 30 Years
Here’s an
alternative
ESP8266 module,
the ESP-01
(available from
the Silicon Chip
Online Store,
Cat SC3982). It’s
smaller but it’s
not quite as easy
to program in
situ. We have an
article describing
this module in
detail on page 76
of this issue.
April 2018 59
Fe at ur es & sp ec ifi ca tio ns :
to a clock which will be only
results and use that as the corbe displaying to the nearest
rect time.
second, that should be accu- * Uses low-cost ESP8266 WiFi module
Keeping track of time
rate enough.
Comparable in size to a GPS module
To determine the time us- *
The NTP-based GPS Time
ly required
ing NTP, the unit sends out * Little or no assemb
Source uses its internal oscilincluding
a number of packets over * Generates standard GPS NMEA data
lator and timer to keep track
dity
vali
al
sign
the internet to NTP servers
of time in the short-term, so
time, date, position and
and uses its internal clock * Also produces 1PPS pulses (D1 version only)
it does not need to constantly
to keep track of when each
re-query the servers to detert
rne
inte
from
e
tim
NTP
tically fetches
packet is sent and when a re- * Automa
mine the time.
servers
ply is received. The response
This oscillator’s frequency
tion, for clocks with
also includes the time (ac- * Provides approximate loca
may not be exactly right and
location-based time zone support
cording to the server) when
it could vary with temperaour query was received and * Adjustable baud rate
ture and other factors but
when the response was sent.
since we synchronise it fret
* Configured via serial por
The packets are sent using the
quently using NTP, it should
ing
ugg
deb
for
my status sentences,
low-overhead User Datagram * Produces dum
never drift very far.
Protocol (UDP).
In fact, by looking at how
* Power supply: ~70mA at 3.0-5.5V
Using this information, we
it’s drifting each time we get
can determine the round-trip
a time update via NTP, we
time, ie, the time it takes for our query to get to the server
can account for and cancel out some of this drift.
plus the time it takes to get the response. Normally, the
That’s important since we use this oscillator to deterroute taken by both packets will be similar and so the demine the one-second intervals on which to send the NMEA
lay will be similar.
data and this gives the clock its seconds “tick”. If that was
By subtracting the time that the server spent processing
inconsistent or worse, glitched (eg, giving two pulses in
our request from the round trip time and dividing by two,
short order), you would probably notice.
we can get a pretty good idea of how long the response
By default, we perform an NTP update at hourly intertook to get to us. We can then add that delay time to the
vals. The oscillator in the ESP8266 micro is typically acaccurate time we receive from the server and that should
curate to within about ±0.001%. That means that, uncorbe close to the exact time when the response was received.
rected, it will drift by up to 42ms each hour. That’s hardly
Since we query a number of servers, if a majority of the
noticeable and the corrected drift is likely to be well within
times determined from the responses are within a few mil10ms. You aren’t going to notice a 10ms “jump” when the
liseconds of each other, we can be fairly sure that we have
time is updated from NTP.
a good determination of the time and we can average those
One thing we haven’t mentioned yet is that there are ac-
Fig.2: circuit diagram of the original WeMos D1 mini, which has now been cloned and is widely available. It’s based on
an ESP8266 WiFi module with onboard processor but contains extra circuitry to make it easier to program and use.
60
Silicon Chip
Celebrating 30 Years
siliconchip.com.au
Fig.3: there are several different versions of the D1 Mini
board but they are all suitable for this project and have the
same pin-out, as shown here. The one we used (a common
clone) looks like this but there may be slight variation in
the components on the board.
Fig.4: the only part mounted on the the top side of the D1
Mini module is the ESP8266 sub-module, which contains
the IC itself plus a few passive components inside a metal
shield can. This is the side normally visible when the
module is plugged into another board.
tually two different hardware units which you can use for
this project. One is smaller and cheaper (ESP-01) but only
has eight pins. The slightly larger module (D1 Mini) has
more pins and this allows us to also provide a 1PPS (one
pulse per second) output, for clocks which require it. See
Figs.2, 3 & 4 for details of the D1 Mini.
If available, the 1PPS output is generated from the same
oscillator and is driven high briefly at the same time that
we start to transmit the NMEA data. We’ll get back to discussing the two different hardware modules later.
NTP always gives UTC or Universal Coordinated Time.
This is the modern, more accurate version of Greenwich
Mean Time, which differs from GPS time by (currently) 18
seconds due to the fact that the GPS satellites are not adjusted for leap seconds when they occur.
However, the GPS data stream does include information
about how many leap seconds have occurred, so this can
be corrected for.
Most GPS receivers are able to use this information and
so give the correct UTC time, but some receivers don’t apply the leap second change at the right time. This means
that using NTP may actually be more accurate than some
GPS receivers.
some status information. While the small PCB antenna on
this module doesn’t have a long range, it’s expected that it
will be used indoors (where GPS isn’t available) and probably not too far from a router.
ESP8266 module
The small size of the ESP8266 module means that it can
function as a direct drop-in replacement for many GPS
modules.
There are quite a few different ESP8266-based modules
available. Our preference is for the WeMos D1 Mini, which
includes an onboard USB/serial converter to simplify programming, as well as a 5V regulator, allowing it to be used
with both 5V and 3.3V power supplies.
Other modules like the slightly smaller ESP-01 can also
be used, but you will need a USB-serial converter to program it and pull-up resistors are also required to get it to
operate in the correct mode. We’ll show you how to use
either module for this project.
The features of the module that we are using are the WiFi
connectivity, serial port and also the onboard LED to report
siliconchip.com.au
Circuit diagram
The circuit diagram for the ESP8266 WeMos D1 Mini
module (available from Jaycar, Cat XC-3802) is shown in
Fig.2 and its pinout is shown in Figs.3 & 4. Since this is a
pre-built module which does pretty much everything we
need it to do, there’s no additional circuitry required. We
simply feed power into the GND and 3V3 pins and the emulated GPS serial data appears at the TX pin.
If your clock supplies 5V to the GPS module then you
can feed this into the 5V pin instead. The onboard regulator then derives the 3.3V supply which powers the module.
Regardless, the serial data output will have a 3.3V swing
but this is true of most GPS modules (even if they run off
5V) so the clock should not have any problem with this
(5V micros can normally accept 3.3V logic levels at their
digital inputs).
You can also use the smaller ESP-01 Module (available
from Altronics, Cat Z6360) but it cannot easily be programmed as-is. You will need a breadboard, some jumper
wires and a few resistors so that you can program it. You
will also need to add some components to the board before
mounting it in the clock, so that it will operate normally.
The ESP-01 also does not include a 3.3V regulator, so
the host circuit will have to supply it with 3.3V or thereabouts (3.0-3.6V is acceptable).
Programming it
Regardless of which module you’re using, you need to
install the Arduino IDE and the ESP8266 processor addon so that you can upload the code to it. If you haven’t already done this for a previous project, use the following
steps – and if you do already have this software installed,
check to make sure you have the latest version.
First, install the most recent version of the Arduino IDE
onto your PC, if you don’t already have it. This can be
Celebrating 30 Years
April 2018 61
Fig.5: this is how the ESP-01 module is connected for programming. Note the two loose wire “ends”, which
are used to put the module into programming mode.
downloaded for free from www.arduino.cc/en/Main/Software
Next, install the ESP8266 board files. This is also a free
download but it’s quite large and will take a while. To do
this, open up preferences in the Arduino IDE and under
“Arduino Board Manager URLs”, enter: http://arduino.
esp8266.com/stable/package esp8266com index.json (as
shown in Fig.6).
Hit OK, then go to Tools Boards Board Manager,
type in “esp8266” in the search box, click on the entry
which appears below and then click on the “Install” button (see Fig.7). This will result in around 160MB of compilers and associated files being downloaded and installed
on your computer.
There are two main build options, so we’ll run through
the easier option first. This is using the D1 Mini module.
Go to Tools Board menu and select the “WeMos D1 R2
& mini” entry. There are no additional libraries to install,
as the basic WiFi feature libraries are installed with the
ESP8266 processor add-on.
Using a micro-USB cable, plug the D1 Mini module into
your PC. Check the ports under Tools Ports to see that
the driver is installed and select the port. If it is not installed, the driver can be downloaded from https://wiki.
wemos.cc/downloads
Open the .ino sketch file (downloaded in a ZIP from the
SILICON CHIP website) and select Sketch Upload. If everything completes successfully, you can jump ahead to the
Setup section.
Using the ESP-01 module
The ESP-01 module is less than half the size of the D1
Mini, which means it can’t fit a lot of the nice features of
the larger board (such as the onboard USB/serial converter).
Still, it isn’t too difficult to build a rig for programming this
tiny module. You will need a separate USB/serial converter with a 3.3V supply output, as the ESP-01 will not like
5V! We have a suitable device in our SILICON CHIP Online
Shop (Cat SC3437). See Fig.5 for the connection diagram.
Connect one male/female jumper lead to each of the ESP01’s pins except for GPIO2 and run the other end to one edge
of the breadboard. We used red for VCC, black for GND, orange for TX, yellow for RX, green for RST, blue for GPIO0
and mauve for CH_PD (“Power down”). The mauve lead
for CH_PD can connect to the same row as VCC, as CH_PD
needs to be pulled up to Vxx for the module to do anything.
Connect another four male/female jumper leads to the
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Fig.6: before you can install the ESP8266 Board file, you
need to tell the Arduino IDE where to find it. You do that in
the Preferences dialog, as shown here.
62
Silicon Chip
Fig.7: this shows how you install the ESP8266 “core” files
in the Arduino Board Manager. That lets you compile and
upload code to ESP8266-based boards, including the ESP-01
and WeMos D1 Mini.
Celebrating 30 Years
siliconchip.com.au
USB-serial converter and then connect these to
Our ESP-01
the ESP-01 via the breadboard as follows: red
programming rig,
lead to 3.3V, black to GND, orange (from TX
corresponding to
on the ESP-01) to RXD on the USB/serial conFig.5. It looks a bit
verter, and similarly, yellow (from RX on the
complicated but
ESP-01) to TXD on the USB/serial converter.
really there isn’t
much to it apart
The ESP-01 module needs some pull-up refrom a number of
sistors for correct operation, so connect a 10kΩ
jumper leads.
resistor from the VCC row to the RST row (between the green and red jumper leads), and
another 10kΩ resistor from the VCC row to
the GPIO0 row (between red and blue jumper
leads). See Fig.5 for details.
Finally, using male-to-male jumpers, add
flying leads to the RST and GPIO0 rows (green
and blue). These are now our reset and programming jumpers and we plug them into the
GND row to activate them. If you prefer, you
could even fit some tactile pushbuttons to the
breadboard if you are going to be using this
setup more than once.
To reset the ESP-01, touch the green lead to
GND. To enter UART upload (programming)
mode, hold the blue wire against GND, then
briefly touch the green wire to GND, then release the blue again. Usually, the blue LED on the module will blink on
wire. You can even touch the green wire to the blue wire and off in “run” mode, but will only briefly flicker once
(while it is against GND) to ensure everything happens in in programming mode, so if the LED is blinking, you may
not be in programming mode.
the right sequence.
We’ve found that uploading to the ESP8266-based deAnother trick you could use if you want to make the setup more permanent is to (carefully!) glue the sockets that vices is sometimes less reliable than other devices, so it
are plugged into the ESP-01 together to form a single large may simply be a case of trying a few times.
socket which can be removed as one piece from the ESP01. If you are using a cyanoacrylate type adhesive (Super Set-up
With the sketch completely uploaded to the device,
Glue), gently separate the sockets to allow the glue to penetrate, apply a small amount away from the ESP-01, then open the Serial Monitor at 9600 baud (you can do this
via the Tools menu or, in Windows, the key combination
firmly squeeze them together until the glue takes.
Now, having built our programming rig, we can upload CTRL+SHIFT+M). The program will transmit its current
baud rate at 9600 baud before running, so if you see a differthe code to the ESP-01.
Click Sketch Upload in the IDE and while the sketch is ent number or garbage output in the Serial Monitor, check
the displayed baud rate and use that instead.
compiling, touch GND to the blue wire, then green and then
Within a few seconds, there should be a stream of data
release green and release blue. The ESP-01 will stay in programming mode until it is reset or a sketch is successfully on the screen, similar to Fig.8. The lines beginning with
“$GPRMC” and “$GPGSA” are our emulated GPS (NMEA)
uploaded, in which case it will run the uploaded sketch.
Any errors will appear in the bottom pane of the Ardui- data, while the “$ESP82” lines are debugging informano IDE window. If you get errors like “error: espcomm_up- tion so that we can follow what our NTP-based GPS Time
load_mem failed”, this is because the computer cannot send Source is doing.
These two groups of three lines show the data from a
data to the ESP-01. In this case, try the blue/green sequence
Fig.8: sample output from the completed NTP/GPS Adaptor
unit. The GPRMC, GPGGA and GPGSA sentences mimic
those produced by a GPS receiver (hence the GP prefixes)
while the ESP82 sentence contains our debugging data.
You can see that the unit acquired a WiFI IP address
(192.168.43.252) between the first and second instances.
siliconchip.com.au
Fig.9: the NTP GPS Source set-up menu.
Celebrating 30 Years
April 2018 63
Parts list – NTP Time Source
1 D1 Mini ESP8266 module [eg, Jaycar XC3802] or
1 ESP-01 module [eg, Cat SC3982 & Altronics Z6360]
To program the ESP-01, add:
1 USB/serial converter
[eg, SILICON CHIP Online Shop Cat SC3543]
1 small breadboard
2 10kΩ 0.25W resistors (1% or 5%)
2 male-to-male jumper wires (to suit breadboard)
11 male-to-female jumper wires (to suit breadboard)
configured module that has already connected to a WiFi
network. You can see that it updates its time, latitude and
longitude between the first and second group of sentences
(it really is that quick!).
You will probably see something that looks like the first
group repeated, as your unit will not be connecting to a
WiFi network just yet.
To enter the configuration menu, type “~” and press
enter on the Serial Monitor. You will need to have the
serial monitor set up to produce carriage return (CR) or
carriage return/line feed (CR/LF) at the end of each line,
as the menu looks for CR on some commands; this happens by default.
The menu will appear, as shown in Fig.9. You will need
to configure options three and four to suit your local WiFi network by pressing “3” and Enter, followed by your
WiFi network’s SSID name and then press Enter. Then
type “4” and Enter, followed by the password and Enter.
As you might imagine, the password is saved in a nonsecure fashion and can easily be viewed by anyone who
has access to the module, so be careful who you give it to.
The NTP server and dummy coordinates should not
need to be changed but this can be done in a similar fashion if necessary.
The dummy coordinates correspond to Sydney, so
should be a good default if you are using the High Visibility 6-Digit LED GPS Clock in Victoria, NSW or ACT. If
you are using the GPS-synchronised Analog Clock Driver, these don’t matter, as the time zone is set in the PIC
on the driver PCB.
In any case, the unit should get a reasonably accurate
latitude and longitude from the IP web service. It’s only
in the case that this fails that the defaults are used.
Finally, press “9” and then Enter to save, then press the
reset button on the side of the D1 Mini to load the new
defaults. You should see a valid IP address appear after
the second comma of the “$ESP82” sentence if the WiFi
connects successfully. See Fig.8 for more detail on this.
Checking the “$GPRMC”, “$GPGGA” and “$GPGSA”
sentences should reveal valid data, including the current
(UTC) time and date after “$GPRMC”. If everything seems
to be working here, we can connect it up to our clock.
The D1 Mini also has an onboard LED to help set-up and
troubleshooting. While it is looking for a WiFi network
at start-up, the LED is on solidly – so if the LED lights
up and never goes out, the unit is not connecting to your
WiFi network. After this, the LED will blink every time
data is transmitted, which should be once per second.
64
Silicon Chip
Configuring the ESP-01
As well as needing the right combination of pull-ups
and pull-downs to be programmed, the ESP-01 will also
need to be configured to run correctly before connecting it
to a clock. Fortunately, this is easily done by adding solder
bridges to some of the pins to connect them to the correct
voltage levels.
Soldering the pins simply prevents the ESP-01 from entering programming mode, so it can still be configured via
the setup menu on the serial port if necessary.
Carefully run a bridge of solder between the 3.3V pin
(the top left pin when looking at the top of the board, pins
at the top), CH_PD, RST, GPIO2 and GPIO0 (the four centre pins). This effectively forces the ESP-01 into run mode
every time it is powered up. We found it easiest to bridge
out the four centre pins, then tilt the module to allow the
bead of solder to reach the 3.3V pin.
See the photo below for how the ESP-01 should look
after it has been bridged. Alternatively, you could solder
a couple of short lengths of hookup wire to join the pins.
To connect it to the clock, plug jumper leads into 3.3V
(top left), GND (bottom right) and TX (above GND). From
now on, the ESP-01 can be treated like the D1 Mini and
these are the only three connections you need. Note that
with the ESP-01 module, the blue LED is connected to the
TX pin, so it will flicker to indicate data is being transmitted
but will not solidly stay on while the module is attempting
to connect to WiFi as with the WeMos board.
Connecting to the GPS-synchronised
Analog Clock Driver
There are only three connections needed to work with
the GPS-synchronised Analog Clock Driver from February
2017: power (3.3V), ground and the serial data. Remove
the battery from the Clock Driver, ensure that JP1 is set to
the 3V position, then wire the unit up to the GPS module
header. See the top photo opposite for details.
This means connecting the 3.3V pin on the D1 Mini to
the VCC pin on the clock, Ground (“G”) to GND and TX to
TX. We used jumper socket lead off-cuts to wire up our D1
Celebrating 30 Years
Bridging the pins of the
ESP-01 with solder forces
it into “run” mode and
prevents it stalling in
UART upload mode. With
a bit of care and a solder
sucker, the solder can be
removed and the ESP-01
can be reprogrammed
if necessary. The pins
that are bridged are
VCC, CH_PD, GPIO0,
GPIO2 and RESET.
The copper tracks
at the bottom of the
PCB are the onboard antenna.
siliconchip.com.au
Mini, so it’s easier to remove in future if necessary (for example, if we need to configure it to a different WiFi network).
You’ll see in the photo that we’ve actually connected
3.3V to the “EN” pad on the PCB, because it’s directly connected to VCC on the reverse of the clock PCB and it means
that the wires don’t need to cross.
Set the hands of the clock to 12, and re-insert the cells.
You should see the STARTUP LED on the Clock Driver
flash once, then twice as it powers up the D1 Mini. If the
D1 Mini’s LED does not light, check the wiring connections.
The LED should go out again in a few seconds as it connects to WiFi, and provided the Internet connection is good
and the NTP servers are online, the STARTUP LED on the
Clock Driver will flash four times and it will start doublestepping towards the correct time.
Connecting to the
High Visibility 6-Digit LED GPS Clock
The set-up for the High Visibility 6-Digit LED GPS Clock,
from the December 2015 and January 2016 issues, is similar to that for the GPS-synchronised Analog Clock Driver.
Because our prototype unit did not have a 1PPS output
(and it is not required by the clock), we did not connect
it. If you need it, it’s on pin D2 of the Mini.
Ensure that LK1 is set to the 3.3V position and connect
+V to 3.3V on the D1 Mini, GND to G and TX to TX, as
shown in the photo below.
Power on the clock, and after a few seconds, you should
see the GPS display indicating that the clock is awaiting
a valid GPS signal. Once valid data has been received by
the clock, it will go to the normal clock display. Since
this clock uses latitude and longitude to set the time
zone, incorrect data here may lead to an incorrect time
being displayed.
If you find the time is incorrect (especially if it is out
by a whole number of hours), the NTP-based GPS Time
Source may not be providing correct latitude and longitude data, in which case the dummy values may need to
be changed.
The NTP-based GPS Time Source updates its time from
the NTP servers every hour. We’ve tried to program it so
that it won’t “jump” when that happens; in fact, you probably won’t notice it. But for the first few
hours, as the drift compensation will
not be operational yet, you may notice
an occasional slight glitch in the time.
Only three wires are needed to connect the D1 Mini to
the GPS-synchronised Analog Clock Driver (Feb 17) and
although slightly larger than the GPS Module, the D1 Mini
is a great fit for the PCB.
the US government, and it was a server we tried while testing the NTP-based GPS Time Source. In practice, because
the servers are so far away, the round-trip time for our data
was too long to maintain accuracy, so a closer server was
chosen at pool.ntp.org
This server is actually a large number of servers around
the world and the internet’s DNS system tries to point you
to a nearby server.
The server can be changed via the configuration menu
by pressing “5” and enter, then entering the URL or IP
address of the new server.
SC
Using it with other clocks and
NTP servers
Any device that uses GPS data as its
clock source should be able to use this
project. With NTP being used so widely,
the time provided is quite accurate and
the three connections for power, ground
and data are usually easy to find.
The default NTP server used in our
sketch is actually provided by volunteers
who donate their server time to make
NTP widely available. See http://www.
pool.ntp.org/en/ for more information.
As always, servers on the internet may
come and go, and there are alternatives.
For example, nist.time.gov is provided by
siliconchip.com.au
Using a row of header pins makes it much easier to connect our completed
unit to the clock. In this case, we only need three pins.
Celebrating 30 Years
April 2018 65
|