Overview

I have a very nice nixie tube clock from tubehobby.
I've had it for years and it has a nice feature to turn on and off at a set time.
This works quite well, however it sometimes gets out of sync with its time.

The clock supports a GPS device to be attached to help with time sync.
I don't fancy hanging GPS antenna's around my home. Thus I wanted a way to send a NMEA sentence to the clock.

The idea would be have a server that runs on a Linux box that is synced via NTP. This server then would translate the date and time into a GPMRC NMEA sentence for the clock's client device to consume. In this case the client device would be a ESP32 running micropython.

Requirements

  • ESP32 micro, I am using the firebeetle from dfrobot.
  • pynmea2 python library.
  • RS232 level converter, MAX232 etc.
  • My nmea faker codebase.

Server

The server is a simple restful application, written in python3.
It needs only two command line options, an IP address and port to bind to on the host.

Example :

./nmea_server.py 127.0.0.1 5000

However you can also pass it the '--debug' flag to get extended debug messages as per most flask based applications.
If you run the server in the foreground it will also print out when a client connects and what it requested.

You can easily query the server via curl:

curl -X put -H "Content-Type: application/json" -d '{"lat": "123","lon": "456"}' http://localhost:5000/api/v1/nmea_faker/sentence

You can set your current latitude and longitude, this will then form part of the NMEA sentence that is returned.
The above curl should return something like :

"$GPRMC,135424,A,123.0,N,456.0,E,0.168,,080118,,,A*63"

Micropython client

The ESP32 seemed like an ideal platform for the client.
The code is also written in python3.
I can run it off the same power source as the clock, using a LM805 or something similar.
It has Wifi Support, and I can wire up a TTL RS232 port.

The client contains two parts :

  • nmea_client.py, the library that takes care of the REST query and the serial output.
  • main.py, the code that micropython will execute on boot.

To make use of the nmea client library you can do something like this :

import nmea_client

nmea_client = nmea_client.NMEA_client(25,26,'127.0.0.1:5000')

Where 25 and 26 are the software defined RX and TX pins.

The main.py simply connects to your Wifi, then every 60 seconds it will query the NMEA faker server for the GPMRC sentence.
It makes use of the built in 'wifi_setup' library to handle the Wifi connection tasks.

Keep in mind this code will prevent the REPL prompt from spawning, unless there is an issue.

Deploy

The clock needs between 9v and 12v, I used a simple LM805 voltage regulator circuit and a MAX3232CPE based circuit to shift the TTL levels to RS232.
I packaged this up in a neat small container along with the ESP32.
Power plugs into the box, the box has the Mini DIN connector for GPS and a DC jack to power the clock.
I now have a GPS synced clock without a real GPS.