Silicon ChipWi-Fi Time Source for GPS Clocks - June 2024 SILICON CHIP
  1. Contents
  2. Subscriptions
  3. Back Issues
  4. Publisher's Letter: Test your speakers!
  5. Feature: Techno Talk - Program that! by Max the Magnificent
  6. Feature: Net Work by Alan Winstanley
  7. Project: Wi-Fi Time Source for GPS Clocks by Tim Blythman
  8. Feature: Heart Rate Sensor Module by Jim Rowe
  9. Project: Loudspeaker Test Jig by Phil Prosser
  10. Feature: Setting up and using Room EQ Wizard by Phil Prosser
  11. Feature: Teach-In 2024 – Learn electronics with the ESP32 by Mike Tooley
  12. Feature: Max’s Cool Beans by Max the Magnificent
  13. Feature: Audio Out by Jake Rothman
  14. Feature: Circuit Surgery by Ian Bell
  15. PartShop
  16. Market Centre
  17. Contents
  18. Back Issues: Peak Test Instruments

This is only a preview of the June 2024 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Articles in this series:
  • Win a Microchip Explorer 8 Development Kit (April 2024)
  • Net Work (May 2024)
  • Net Work (June 2024)
  • Net Work (July 2024)
  • Net Work (August 2024)
  • Net Work (September 2024)
  • Net Work (October 2024)
  • Net Work (November 2024)
  • Net Work (December 2024)
  • Net Work (January 2025)
  • Net Work (February 2025)
  • Net Work (March 2025)
  • Net Work (April 2025)
Articles in this series:
  • Teach-In 2024 (April 2024)
  • Teach-In 2024 (May 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (June 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (July 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (August 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (September 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (October 2024)
  • Teach-In 2024 – Learn electronics with the ESP32 (November 2024)
Articles in this series:
  • Max’s Cool Beans (April 2024)
  • Max’s Cool Beans (May 2024)
  • Max’s Cool Beans (June 2024)
  • Max’s Cool Beans (July 2024)
  • Max’s Cool Beans (August 2024)
  • Max’s Cool Beans (September 2024)
  • Max’s Cool Beans (October 2024)
  • Max’s Cool Beans (November 2024)
  • Max’s Cool Beans (December 2024)
Articles in this series:
  • Audio Out (January 2024)
  • Audio Out (February 2024)
  • AUDIO OUT (April 2024)
  • Audio Out (May 2024)
  • Audio Out (June 2024)
  • Audio Out (July 2024)
  • Audio Out (August 2024)
  • Audio Out (September 2024)
  • Audio Out (October 2024)
  • Audio Out (March 2025)
  • Audio Out (April 2025)
  • Audio Out (May 2025)
  • Audio Out (June 2025)
Articles in this series:
  • Circuit Surgery (April 2024)
  • STEWART OF READING (April 2024)
  • Circuit Surgery (May 2024)
  • Circuit Surgery (June 2024)
  • Circuit Surgery (July 2024)
  • Circuit Surgery (August 2024)
  • Circuit Surgery (September 2024)
  • Circuit Surgery (October 2024)
  • Circuit Surgery (November 2024)
  • Circuit Surgery (December 2024)
  • Circuit Surgery (January 2025)
  • Circuit Surgery (February 2025)
  • Circuit Surgery (March 2025)
  • Circuit Surgery (April 2025)
  • Circuit Surgery (May 2025)
  • Circuit Surgery (June 2025)
Wi-Fi Time Source for GPS Clocks The Raspberry Pi Pico W can be used as a substitute for GPS modules in existing time keeping designs, for when you can’t get a reliable GPS signal. It gets the time from an internet NTP server via Wi-Fi and is accurate to a fraction of a second. Project by Tim Blythman E ver since GPS modules have been affordable for the hobbyist, we have used them as accurate time sources. While GPS (and other similar satellite systems) has revolutionised navigation and mapping, it also provides easy global access to highly accurate time sources. Each GPS satellite is equipped with two atomic clocks, and they transmit a very accurate time signal every second. We have used that signal for many projects to date, including the recent, very popular GPS Analogue Clock Driver from September 2023. While GPS was the first GNSS (global navigation satellite system), there are now several more, including the Russian GLONASS, European Galileo and Chinese Beidou systems. The Indian Regional Navigation Satellite System (IRNSS) and Japanese Quasi-Zenith Satellite System (QZSS) are designed to improve positioning on a national scale, with the QZSS also benefiting Australia as the satellites’ orbits bring them over us. While they use subtly differing technologies (even GPS has evolved over its 50-year existence), a common external interface has been established. In fact, the VK2828U7G5LF GPS module that we use for many projects can receive signals from GPS, GLONASS and Galileo satellites. For the purposes of this article, we’ll use GPS as an encompassing term for all the different navigation satellite systems. However, note that some of these systems are not truly global, as the satellites do not usually provide coverage at high latitudes (close to the poles). hand, Wi-Fi signals are usually available indoors. The actual hardware of the 2019 unit is simply a D1 Mini Wi-Fi ESP8266 microcontroller module. The module is programmed with firmware to connect to a Wi-Fi network and update an internal clock from the internet using NTP (network time protocol). This time is then used to generate ‘sentences’ to communicate that time. A 1PPS signal is also generated, although this signal will not have the precision of an actual GPS module. Previous GPS Time Source In the April 2019 issue of PE, we published the Clayton’s GPS Time Source. As the name hints, it doesn’t actually use any GPS technology, but rather it can be used as a source of GPS-like time signals when an actual GPS signal is unavailable. It’s often recommended as a replacement for a GPS module in clock projects. The motivation for this concept was driven by many clocks being used indoors, where very weak GPS signals are hard to receive. On the other Pico W update This project is an update of the original Clayton’s GPS but using a Raspberry Pi Pico W instead of a D1 Mini. While we could have refactored the same code for the Pico W GPS, there are several reasons why we did not. We have had many suggestions for improvements over the last five years, so it made sense to incorporate them where possible. We’ve chosen to use the C SDK as we found that it gave us better access to low-level functions and programs run more quickly. Some of the new features were possible (and much easier to implement) due to aspects of the C SDK and its software libraries. There is no doubt that the Pico W is very well priced, making it an attractive option when the module is all or most of the hardware required. What projects does it work with? New GPS-Synchronised Analogue Clock Practical Electronics, September 2023 GPS-Synchronised Analogue Clock Practical Electronics, February 2018 High-Visibility 6-Digit LED GPS Clock Practical Electronics, January 2017 – February 2017 6-Digit GPS-Locked Clock Practical Electronics, May – June 2011 Practical Electronics | June | 2024 15 Wi-Fi Time Source Features n Delivers NMEA 0183 data simulating a GPS time source n Adjustable baud rate n 3.3V logic levels work with 3.3V and 5V systems n Synthesised 1PPS signal n Gets the time from NTP servers via Wi-Fi n Generates estimated latitude and longitude based on IP address n Can also output fixed dummy coordinates n Can scan for up to eight Wi-Fi networks (SSIDs) n Configurable via virtual USB serial port, independent of data stream n Uses a compact and low-cost Raspberry Pi Pico W module n Integrated buck/boost converter runs efficiently from 1.8-5.5V n Crystal oscillator offers better than 30ppm accuracy between updates n Draws 50mA, or up to 100mA during Wi-Fi transmissions (3.0V supply) Indeed, it is cheaper than the GPS module it can replace. But particular features of its RP2040 microcontroller helped us to create the Wi-Fi Time Source. For example, it can implement a virtual USB serial port, meaning that the configuration menu is separate from the NMEA data stream (National Marine Electronics Association). Due to the nature of the serial port on the D1 Mini, these were shared on the Clayton’s GPS, so using the configuration menu interrupted the data stream. The Pico W also implements a virtual USB drive for flash memory programming. Some people had difficulty uploading to the flash memory to the D1 Mini for various reasons. For example, it requires either a dedicated programming application or the Arduino IDE for programming. On the other hand, the Pico W can be flashed by just about any computer with a USB port. The process is as simple as copying the file to the virtual USB drive. The RP2040 processor on the Pico W has two cores, so one can be dedicated to sending out the NMEA data and not be blocked by activity on the other core, which handles the configuration and Wi-Fi connections. The Pico W also has an onboard switchmode regulator that’s more efficient than the linear regulator found on the D1 Mini. Some readers reported problems powering the D1 Mini, so it is a welcome upgrade. It not only reduces the current requirement at higher supply voltages but also enables operation from supplies as low as 1.8V. Just like the earlier time source, the Wi-Fi Time Source emits three NMEA sentences: ‘RMC’ (recommended minimum data for GPS), ‘GGA’ (Fix information) and ‘GSA’ (satellite data). Most of our GPS clock designs only use the RMC sentence, with some also 16 using GGA. So this data is entirely adequate for driving those clocks. NMEA sentences Practically all GPS modules deliver data generally in accordance with the NMEA 0183 standard. The standard actually specifies 4800 baud serial data using a balanced signal complying with the RS-422 electrical standard. The newer NMEA 2000 standard uses a CAN bus network at 250kiB per second. The full contents of this standard are not publicly available, so the simpler NMEA 0183 is still widely used, since it is well known and understood. Most receivers nowadays use single-­ended logic-level signals (typically 3.3V) with baud rates of 9600 or even higher. Many modules also offer a 1PPS (pulse per second) signal that is synchronised to the satellite atomic clocks. The serial data consists of lines of ASCII characters called sentences. For our purposes, each sentence is marked at the start by a ‘$’ character, followed by two characters that identify the ‘talker’. This is typically ‘GP’ for GPS systems, although we have seen some modules that use ‘GN’ where data from multiple satellite systems are combined. The next three characters identify the type of message, followed by sentence-­specific data and a checksum code to provide a degree of protection against corrupted data. The most common sentences that encode the time also contain location data, so the Wi-Fi Time Source can produce dummy location data or even use an IP address geolocation data service to generate an approximate location. In any case, it’s a good idea to generate such data in case the receiving device expects there to be valid data in this location, even if it is not used. This approximation will never be good enough for navigation purposes. Still, it is usually sufficient to determine a timezone, which is ideal for those clocks that use GPS location data for this purpose. For example, the High Visibility 6-Digit LED GPS Clock from January and February 2017 uses location data to set the time zone and daylight savings rules automatically. With most of our GPS projects using the GPS signal for clock timekeeping, the Wi-Fi Time Source is well-suited for use with indoor clocks, where they may not have a view of the sky and thus to a GPS signal, but can easily be connected to a Wi-Fi network. Hardware The Wi-Fi Time Source hardware is minimal. The dashed box in Fig.1 shows the pinout of the Pico W after it has been programmed. The remainder of Fig.1 shows the full map of all the pins with their features. As you can see, we’ve kept all the useful pins at one end. It would have been nice to be able to shorten the board by cutting off unnecessary section. Unfortunately, the entire board is needed and it can’t be made much smaller, especially as the Wi-Fi antenna is at the end opposite the USB connector. The power pins are fixed on the right-hand side, near the USB connector. These are pin 40 (VBUS), pin 39 (VSYS) and pin 38 (GND). There are actually several GND pins (see Fig.1), but pins 3 and 38 are closest to the other important pins. Pin 37 (3V3_EN) is an input to the regulator on the Pico W; this is kept high by a 100kW resistor but can be pulled low to shut down the regulator and thus power off the Pico W. Pin 1 (GP0) is the source of the generated NMEA serial data, which idles at a 3.3V logic high level. The Pico W’s hardware UART (universal asynchronous receiver/transmitter) peripherals are only available on specific pins. This pin was chosen as it is the UART TX pin closest to the USB connector and the power pins. We selected the adjacent pin 2 (GP1) for the 1PPS output; it could have been any of the remaining GPIO pins. We’ve shown the 3.3V output only because it might be handy if you need a regulated 3.3V supply for your project. The regulator on the Pico W can deliver up to 2A, although some of that is used by the Pico W. Fig.2 shows the power circuitry of the Pico W and will help you decide how to connect the Wi-Fi Time Source in your circuit. Practical Electronics | June | 2024 Pins used for the Wi-Fi Time Source Fig.1: the pins on the Pico W that can be used for the Wi-Fi Time Source are shown in the dashed red box. Pin 1 (GP0) is the closest UART TX pin to the USB end of its PCB and is also near the relevant power pins. You probably won’t need all the connections shown here for most clock projects (see Figs.3-6); three or four connections are often sufficient. Pin 1: serial NMEA data; pin 2: 1PPS signal; pin 3: ground; pin 36: 3.3V; pin 37: 3.3V enable (active high); pin 38: ground; pin 39: 1.8V to 5.5V in; pin 40: USB supply. Most people will simply need to connect a supply between the VSYS and GND pins. But note that there is a diode between VUSB and VSYS, so if a USB cable is connected, it might feed into VSYS, particularly if VSYS is less than the 5V from USB. Unless you can be sure that you won’t connect anything to VSYS while power is applied to VUSB (for example, via the USB socket), the safest option will be to connect the incoming supply to VSYS via a schottky diode, which will prevent current from passing from VBUS into your supply. Given that most people will use the USB port to program, configure and test the Pico W, the easiest solution is to disconnect the USB cable before connecting to the target circuit. In that case, direct connections to the Pico W pins will be fine. Later on, we’ll also show you how to connect the Wi-Fi Time Source to some of our recent clocks. Software development The Raspberry Pi C SDK is still evolving, especially the parts of it that deal with the Wi-Fi features of the Pico W. But it is well documented, and interest is sufficient that the online community is also very helpful. So, we ran into some minor difficulties during development, but we managed to work around them. We used version 1.5.0 of the SDK; Practical Electronics | June | 2024 versions before 1.4.0 did not support the Pico W and later versions might differ. As we noted, the Pico W has two processor cores. One of these (the second core) is programmed to do nothing more than generate the NMEA data and 1PPS pulses. This is crucial as we found that the D1 Mini (as used in the 2019 Time Source) would occasionally block (be busy and not be able to run other parts of its program) during Wi-Fi operations. By setting up one core to do the critical activity, the Wi-Fi Time Source can continue to operate, even in the extreme event that one of its processor core crashes entirely. This core can even reset the Time Source under some conditions. When a reset happens, some data is stored in RAM to preserve the current time across the reset. This is possible as RAM remains powered during the soft reset process. We saw very occasional crashes (and reset recovery) when the Time Source had been active for long periods, but this should not be an issue for operation with the recent GPS clocks, as the Time Source should only be powered long enough to set the time, after which it is powered off. This second processor core looks at the current time and calculates what the time will be when the next second rolls over. It then prepares all its data to suit this next second. As soon as the second rolls over, the data is sent, and the 1PPS signal is pulsed. This means that the NMEA data and 1PPS pulses are delivered with minimal jitter. Providing the output as the second rolls over means that the fractional data can be ignored, simplifying the code slightly, both for us and potentially for any device receiving that data. The other core has the vital role of periodically getting an accurate value for the time and collecting the other data that is needed. One of these is a ‘validity’ flag, equivalent to the GPS ‘satellite lock’ that should always be checked to ensure that valid data is being received. The Pico W implements an internal 64-bit counter with microsecond resolution. This counts up from zero when the processor starts or is reset. The documentation jokes that (in the vein of the Y2K or Millennium Bug) this will eventually cause a year 5851444 bug. Such bugs typically occur when a counter rolls over beyond its maximum value. While we are not too concerned about this particular counter, it always pays to to be aware of these potential ‘gotchas’. The main role of the software running on the first core is to fetch an accurate timestamp from the NTP servers. This timestamp is compared with the current value of the 64-bit counter, and an offset is used 17 Fig.2: the power supply circuit of the Pico W, shown here in case you wish to adapt the Wi-Fi Time Source to a different application. For example, consider adding a diode feeding into VSYS to prevent VBUS power from feeding into your power supply if a USB cable is connected. to calculate the actual time (at any time) by simply adding the current value of the 64-bit counter. The RP2040 processor in the Pico W has an internal real-time clock peripheral, but this only has a resolution of one second, so we can’t really use this to keep time accurately. However, we set it and use it in places where it is accurate enough, such as reporting time in human-readable form on the configuration interface. The first core also provides a virtual USB serial port that is used to print an interactive menu with the help of a serial terminal program. This can be seen in Screen 1; we’ll look more closely at the options later. The menu allows up to eight SSIDs (Wi-Fi networks) to be set. The software will automatically cycle through these networks until it successfully connects to one. It will attempt to reconnect if the connection is lost. Since many applications of the Time Source depend on it only being turned on briefly (to save draining battery power), the initial behaviour is to perform a network scan to ensure that the first attempted connection is to an available network. The virtual serial port also produces status information, mainly concerning the Wi-Fi status and time since the last NTP update. One of the menu options allows the NMEA data to be dumped to the virtual serial port for easy debugging. The first core is also responsible for controlling the Pico W’s inbuilt LED, which is set up to flash useful status indications. The LED is switched on solid when power is applied, indicating that 18 the Time Source is powering up correctly. It can also flash once, twice or three times per second. One flash means it is connected to a Wi-Fi network, while two flashes indicate that the time is considered to be correct. Three flashes occur when both those conditions are true. In general, the time is correct if an NTP update has been received in the last few hours, although this limit can be adjusted. The crystal oscillator which is used on the Pico W has a 30ppm (parts per million) tolerance, meaning it could drift by up to one second every eight hours. However, in practice, we saw NTP adjustments up to 200ms, so we’re confident that the time will be accurate within half a second with the default settings. Programming the Pico W It makes sense first to program the Pico W and check that it is working as expected. Hold the BOOTSEL button on the Pico W and plug it into your computer. A USB drive named ‘RPI-RP2’ should appear. Copy the NEW_CLAYTONS_1.UF2 file to it; after a second or so, the LED should come on. You can then use a serial monitor program to access the menu. We use TeraTerm on Windows, while minicom can be used on Linux systems. Open the Pico W’s virtual serial port to access the interactive menu. Ensure that your terminal program uses CR or CR+LF as its line ending. Since it is a virtual serial port, the baud rate is unimportant, and any baud rate setting should work. Time is 22:43:01 on 14/02/2023. NTP OK. Last updated 0 minutes ago. WiFi Status: Connected with IP: 192.168.130.140 Menu: 1 : Scan networks 2 : Show saved 3n : Delete SSID (n from saved list) 4n : Set SSID (n from scan list) 5 : Manual SSID 6n : Set Password (n from saved list) 7 : Test saved 8 : Save to flash 9 : Set Country Code (currently XX) A : Set IPAPI URL (ip-api.com/line?fields=lat,lon) B : Set Latitude (−27.467899 = 27°28’4”S) C : Set Longitude (153.032501 = 153°1’57”E) D : Set baudrate (9600 baud) E : Set Talker (currently GP) F : Set NTP validity timeout (200 min) G : Set NTP server (pool.ntp.org [139.99.222.72]) H : Set default year (2022) I : Turn debug on (currently off) J : Reboot Clayton’s Pico W GPS Time Source Screen 1: many options are available to configure the Wi-Fi Time Source. At a minimum, you will probably need to use commands 1, 4, 7, 8 and 9 to set the country code and connect to your Wi-Fi networks to operate it with our GPS clocks. Other commands could come in handy depending on your application. Practical Electronics | June | 2024 Table 1 – Wi-Fi Time Source configuration commands Comm. Function Notes 1 Scan networks and display a list in order of decreasing RSSI Channel and authentication are also listed. The number shown in column n is used for Command 4. 2 Show the current network list The list is active but may not reflect the contents in flash memory unless a save has been completed. 3n Delete item n from the list shown by Command 2 4n Add network n from Command 1 Also prompts for a password. If all slots are full, an error is printed and you will need to use Command 3 to free a slot. 5 Enter a network name manually Shouldn’t need to be used unless you need to 6n Enter the password for a network, using change a password. n from the list shown by Command 2 7 Test networks in the list Scans through the list and attempts to connect to each network in turn. This can take a while and success is only reported if an IP address is obtained. 8 Save all settings to flash memory It’s a good idea to reboot after this to ensure that all settings are reloaded correctly. 9 Set two-letter country code Only loaded on boot, so reboot after setting this and using Command 8 to save. A Set IP to lat/lon API URL This should return two lines of text with decimal latitude on one line and longitude on the next. Set URL to blank to disable. B Set default latitude Enter in the decimal format. C Set default longitude Enter in the decimal format. D Set NMEA baud rate The default is 9600, but any rate between 300 and 921600 can be used. E Set Talker code The default is ‘GP’, but it can be any two characters. ‘GP’ works for all our clocks. F Set NTP validity timeout in minutes The longest period for which the time can be considered valid without a (typically hourly) NTP update, from 60min to 50000min (about a month). G Set NTP server URL The default is ‘pool.ntp.org’, which automatically redirects to a geographically nearby server. Others can be used, such as ‘time.nist.gov’. The IP address may not be correct until a network is connected. H Set default year The year used at boot when no other time data is available, from 1970 to 4095.. Can be used to check and debug the NMEA I Toggle debugging NMEA data output to data. This setting is saved in case you need this data to always be available on the USB USB serial port serial port. J Reboot Pico W It’s recommended to reboot after saving settings to ensure that all settings are reloaded at boot time. If you hold the BOOTSEL button while rebooting, you can use this method to enter bootloader mode. Practical Electronics | June | 2024 Basic setup All commands should be followed by Enter. The Pico W implements country codes to ensure that the correct (legal) Wi-Fi channels are used for communication. The default ‘XX’ setting is a subset that is safe worldwide but does not allow the use of some Wi-Fi channels. So it should work but might not be optimal. It’s a good idea to set this to your country. Use command 9 (followed by Enter) and enter a two-letter country code (AU, NZ, US, UK... and so on), then save the settings with command 8 and reboot the Pico W with the J command. Editor’s note: the codes should be in the alpha-2 format, see: https://w.wiki/4kP Reconnect to the Pico W if necessary; TeraTerm will usually perform this automatically. Now use menu option 1 to run a Wi-Fi scan; this should complete within a second or so. The networks are listed in order of RSSI (signal strength), so you should find your SSID near the top. Note that commands listed with an n suffix take a second numeric argument. For example, if your network appears first (next to number 0), enter command 40. You will then be prompted for the password for this network; type it in and press Enter. You can enter multiple networks without rescanning. If your network doesn’t appear, use command 5 to enter the name manually, and you will then be prompted for the password too. Command 6 on its own is used to change or set a password if, for example, you have entered it incorrectly. Then try command 7 to test the saved networks. You should see a message saying ‘Connected with IP’, followed by an IP address for each SSID. If not, try again. If you get an ‘Auth failed (password?)’ message, the password entered may not be correct; you can use command 6 to re-enter it. The serial port will print updates around every 15 seconds if nothing has been entered on the serial port – this is done to prevent any updates from interfering with your configuration process. If all is well, use command 8 to save the settings to flash and reboot again to ensure that the settings are loaded. This is necessary as some parameters can only be set once, and the easiest way around this is to reboot the device. This should be the minimal amount needed to set up the Wi-Fi 19 ----------------------------------Command 1 ----------------------------------1 Scanning Scan complete Scanned network list: n SSID RSSI Chan Auth 0 AndroidAP4AA0 −44 1 PASS 1 APV Admin Only −65 3 PASS 2 APHV Conference −66 3 PASS 3 TPW4G_ZeB426 −82 11 PASS 4 WiFi-5E5EE1 −84 8 PASS 5 NTGR_4E0C −93 11 PASS ----------------------------------Command 43 ----------------------------------43 2 TPW4G_ZeB426 Added OK Enter password. PASSWORD password saved. ----------------------------------Command 2 ----------------------------------2 Saved network list: 0 AndroidAP4AA0 1 Tim 2 TPW4G_ZeB426 ----------------------------------Command 32 ----------------------------------32 SSID deleted. Saved network list: 0 AndroidAP44A0 1 Tim ----------------------------------Command 7 ----------------------------------7 Testing networks. 0 AndroidAP4AA0 >connected with IP:192.168.208.140 1 Tim >SSID not found 2 Networks tested, 1 OK Screen 2 (right): this edited screen dump shows the output of some of the more complex commands. Note that these commands have been issued in the order shown, to add and then remove an SSID. Commands 3 and 4 require a second parameter which is a number printed by commands 2 and 1 (respectively) issued prior. Time Source to work with most of our clocks. A detailed list of commands, along with their use and purpose, is shown in Table 1. Screen 2 shows the typical responses to the more common and complex commands. Most other commands require a simple response and will report a message if there is a problem. Screen 3 shows the typical progression at startup, although events may not occur in this order. You might also see a much larger NTP adjustment; that is normal. You can toggle the printing of GPS sentences over the USB serial port by using the I command. Screen 4 shows this; naturally, your data might be 20 Time is 04:01:30 on 13/02/2023. NO NTP. Connect failed Connecting to 0 AndroidAP4AA0 Skip IPAPI fetch, no WiFi. **** NTP adjustment: 11953 **** Connected with IP: 192.168.130.138 Time is 04:01:45 on 13/02/2023. NTP OK. Last updated 0 minutes ago. IPAPI start. Headers of 170 bytes report 18 bytes of content. Received 18 bytes. HTTP finished:200 OK Lat/Lon=−27.467899,153.032501 Time is 04:02:00 on 13/02/2023. NTP OK. Last updated 0 minutes ago. Time is 04:02:15 on 13/02/2023. NTP OK. Last updated 0 minutes ago. Time is 04:02:30 on 13/02/2023. NTP OK. Last updated 0 minutes ago. Time is 04:02:45 on 13/02/2023. NTP OK. Last updated 1 minutes ago. Time is 04:03:00 on 13/02/2023. NTP OK. Last updated 1 minutes ago. Time is 04:03:15 on 13/02/2023. NTP OK. Last updated 1 minutes ago. Time is 04:03:30 on 13/02/2023. NTP OK. Last updated 1 minutes ago. Time is 04:03:45 on 13/02/2023. NTP OK. Last updated 2 minutes ago. Time is 04:04:01 on 13/02/2023. NTP OK. Last updated 2 minutes ago. Screen 3: the last few lines on this screen (using the TeraTerm serial terminal program) show that the Wi-Fi Time Source has connected to Wi-Fi and updated its time from NTP servers. The previous lines are typical of what might be seen on a normal startup. different. If you have a PC program that can process GPS data, you can use it to verify the data. Connecting it to a clock The Wi-Fi Time Source could feasibly connect to just about any system that expects logic level NMEA 0183 data; however, its lack of accurate speed and location data means it is not the best choice in some cases. We don’t recommend using it as the source for our GPS-based frequency references; the 1PPS signal provided by this time source is not intended to have the necessary precision. It’s not going to be much use as a navigational aid either, ruling out the Advanced GPS Computer from une/July 2022, so we’ll assume you are using the Wi-Fi Time Source with one of our GPS clocks. We have instructions below on using the Time Source with some GPS clock projects we have published over the last ten years. Table 2 also summarises how this Time Source can replace some common GPS modules. Note that these connections may not be optimal, especially for clocks that run on batteries. You might want to experiment with alternative configurations. The suggested wiring for the recent battery-powered clocks is different to Table 2 for that reason. $GPRMC,050215.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*3F $GPGGA,050215.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*78 $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050216.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*3C $GPGGA,050216.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*7B $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050217.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*3D $GPGGA,050217.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*7A $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050218.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*32 $GPGGA,050218.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*75 $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050219.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*33 $GPGGA,050219.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*74 $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050220.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*39 $GPGGA,050220.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*7E $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050221.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*38 $GPGGA,050221.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*7F $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F $GPRMC,050222.000,A,2728.0004,S,15301.0057,E,0.00,000.00,130223,,,*3B $GPGGA,050222.000,2728.0004,S,15301.0057,E,1,04,1.0,0.0,M,0.0,M,,*7C $GPGSA,A,3,,,,,,,,,,,,,1.00,1.00,1.00,*2F Screen 4: the I command sends GPS sentences to the virtual serial terminal so that you can confirm the data being produced. This setting can be saved to flash, so the GPS data continues to be sent to the USB virtual serial port even after it reboots. Practical Electronics | June | 2024 The problem is that the Wi-Fi Time Source has a higher current demand than most GPS modules, and the circuitry sometimes cannot provide enough current to drive it. New GPS-Synchronised Analogue Clock – September 2023 The most recent GPS-synchronised clock was published in September 2023. Like many of our recent GPS projects, it uses the VK2828U7G5LF GPS module. In fact, we recommend this module as a replacement for all the previous GPS modules we have used in clock projects. The VK2828U7G5LF has six connections, but you only need four for the Time Source. The connections are all fairly straightforward, although they don’t all connect to the GPS module header – see Fig.3. The black and blue wires are connected to the obvious points on the GPS module header. The red wire feeds power directly from the battery to the Pico W’s VSYS pin; one of the pins of the ICSP header is ideal for this purpose. Note that we’ve used a header pin for this connection, so power can be disconnected when we connect to the USB socket for programming. This prevents 5V from the USB cable being fed into the battery. With just these three wires, the Pico W would run continuously. So the green wire connects the 3V3_EN pin to pin 7 of IC1 on the Clock PCB. This pin is usually used to control the Clock’s boost regulator. This connects underneath the PCB, as shown in the photo, since it is easier to connect to the corresponding pad. This scheme bypasses the boost regulator on the New GPS-Synchronised Analogue Clock, which is possible as the Pico W has its own buck/boost regulator. That also means that if you are building the Clock board from scratch, you can leave off the boost regulator IC and its associated components. With this arrangement, the Pico W will power up even when the battery is down to 2V, the lower limit of the Clock. By that stage, there wasn’t enough voltage to power the blue LED on the Clock, but everything else worked as expected. The photos show the Time Source connected via short wires and then mounted on the ICs using a pad of double-sided tape. Note how the Pico W’s Wi-Fi antenna is clear of the PCB below. The Wi-Fi Time Source typically takes about 25 seconds to ‘get a fix’, Fig.3: connecting to the New GPS-Synchronised Analogue Clock using the 3V3_EN pin on the Pico W makes the most efficient use of the Pico W’s onboard boost regulator, bypassing the Clock’s own boost regulator (the Pico W is shown larger than life size in Figs.3-6 for clarity). In this case, you could omit IC3, L1 and the two 10μF capacitors. Fig.4: how to connect the Time Source to the GPS-synchronised Analogue Clock Driver from 2018. This also bypasses the Clock’s onboard regulator to power the Pico W. Note that we have not tested this configuration. Practical Electronics | June | 2024 21 The Wi-Fi Time Source wired to the New GPSSynchronised Analogue Clock from 2023. To save battery power, the boost regulator on the clock PCB is bypassed; in fact, those onboard components could be left off entirely. The photo at upper left shows the green wire connecting directly to pin 7 of IC1 on the reverse of the PCB. often faster and occasionally longer if it does not connect to the Wi-Fi network immediately. This should be the same with most Clocks that use the Time Source. After powering on the Clock with the Time Source connected, the Clock would flash its LED once or twice, after which the Time Source’s LED would come on and start flashing at the same rate as the Clock LED. After a few more seconds, the LED on the Time Source would turn off, showing that the Clock has obtained the correct time and powered down the Time Source. Generally, the Clock LED should also turn off after half an hour at most (and the clock should start ticking), so if it continues flashing for longer than that, you should investigate. In general, we found that if the data displayed on the USB serial terminal appeared correct, the Time Source would work correctly when connected to the Clock. Fig.5: connections to a 2017 Nixie Clock (not a PE project). LK1 (which chooses between a 3.3V and 5V supply for the connected module) should be set to the 5V position. Still, this design is not powered by a battery, so efficiency is less critical. Fig.6: the High Visibility 6-Digit LED GPS Clock uses the same header pinout as the Nixie Clock, so the wiring is much the same, as is the choice to set LK1 to the 5V position. 22 Practical Electronics | June | 2024 Table 2 – Time Source pin mapping compared to GPS modules Pico W VK2828 EM408 Pin 1 GP0 (NMEA data) TxD(4, blue) Tx(4) Pin 2 GP1 (1PPS) 1PPS (6, white) Not connected Pin 3/38 GND GND (2, black) GND(2) Pin 39 VSYS VCC (5, red) V+(5) Pin 40 VBUS Not connected Not connected Not needed EN (1, yellow) EN (1) Not needed RxD (3, green) RX(3) GPS-synchronised Analogue Clock Driver – February 2018 The GPS-synchronised Analogue Clock Driver from February 2018 also recommended the VK2828U7G5LF GPS module. Note that we have not tested this arrangement or any of the following arrangements with clocks before 2022. Here we propose a variation that will avoid a small amount of inefficiency by also bypassing the Clock Driver’s boost regulator. Since the Pico W can work from voltages down to 1.8V at VSYS, we take 3V directly from the input of the boost regulator, as shown in Fig.4. GET T LATES HE T COP Y OF TEACH OUR -IN SE RIES AVAILA BL NOW! E Notes Not needed for most applications Or another source of 1.8V to 5.5V GPS clocks from 2017 All the earlier GPS clocks we published used external power supplies, so they should not have any problems due to the limitations of a battery supply. Fig.5 and Fig.6 show how to connect the Wi-Fi Time Source to the 6-Digit Retro Nixie Clock Mk.2 and High Visibility 6-Digit LED GPS Clock, respectively. Note that both use the same header pinout for connections to their respective GPS modules, corresponding to the connections shown in Table 2. For efficiency reasons, the GPS power supply voltage link for these projects (LK1 for both projects) should be set to Order direct from Electron Publishing PRICE £8.99 (includes P&P to UK if ordered direct from us) the 5V position, since the Pico W will happily work with 5V at its VSYS input. If you have problems after connecting the Time Source to one of the other clocks, it is most likely a power problem. Check that the 3V3_OUT pin is near 3.3V. If not, the circuit may not be able to supply enough current for the Pico W. Conclusion The Pico W board provides helpful features in roles like this, such as its integrated buck-boost power supply, dedicated USB peripheral allowing a separate configuration console and good software support. The Wi-Fi Time Source is a natural progression of the original Clayton’s GPS Time Source from 2019 and is similarly simple and well-priced. The Pico W variant adds extra features, particularly the ability to connect automatically to one of several Wi-Fi networks. At the time of writing, Bluetooth support is in its early (beta) stages, so we will investigate if it is possible to add a Bluetooth interface for configuration. This would be very handy for updating settings as it would remove the need to connect a USB cable. Reproduced by arrangement with SILICON CHIP magazine 2024. www.siliconchip.com.au EE FR -ROM CD ELECTRONICS TEACH-IN 9 £8.99 FROM THE PUBLISHERS OF GET TESTING! Electronic test equipment and measuring techniques, plus eight projects to build FREE CD-ROM TWO TEACH -INs FOR THE PRICE OF ONE • Multimeters and a multimeter checker • Oscilloscopes plus a scope calibrator • AC Millivoltmeters with a range extender • Digital measurements plus a logic probe • Frequency measurements and a signal generator • Component measurements plus a semiconductor junction tester PIC n’ Mix Including Practical Digital Signal Processing PLUS... YOUR GUIDE TO THE BBC MICROBIT Teach-In 9 – Get Testing! Teach-In 9 A LOW-COST ARM-BASED SINGLE-BOARD COMPUTER Get Testing Three Microchip PICkit 4 Debugger Guides Files for: PIC n’ Mix PLUS Teach-In 2 -Using PIC Microcontrollers. In PDF format This series of articles provides a broad-based introduction to choosing and using a wide range of test gear, how to get the best out of each item and the pitfalls to avoid. It provides hints and tips on using, and – just as importantly – interpreting the results that you get. The series deals with familiar test gear as well as equipment designed for more specialised applications. The articles have been designed to have the broadest possible appeal and are applicable to all branches of electronics. The series crosses the boundaries of analogue and digital electronics with applications that span the full range of electronics – from a single-stage transistor amplifier to the most sophisticated microcontroller system. There really is something for everyone! Each part includes a simple but useful practical test gear project that will build into a handy gadget that will either extend the features, ranges and usability of an existing item of test equipment or that will serve as a stand-alone instrument. We’ve kept the cost of these projects as low as possible, and most of them can be built for less than £10 (including components, enclosure and circuit board). © 2018 Wimborne Publishing Ltd. www.epemag.com Teach In 9 Cover.indd 1 01/08/2018 19:56 PLUS! You will receive the software for the PIC n’ Mix series of articles and the full Teach-In 2 book – Using PIC Microcontrollers – A practical introduction – in PDF format. Also included are Microchip’s MPLAB ICD 4 In-Circuit Debugger User’s Guide; MPLAB PICkit 4 In-Circuit Debugger Quick Start Guide; and MPLAB PICkit4 Debugger User’s Guide. ORDER YOUR COPY TODAY: www.electronpublishing.com Practical Electronics | June | 2024 23