Skip to content

Instantly share code, notes, and snippets.

@Elwell
Last active May 25, 2026 00:29
Show Gist options
  • Select an option

  • Save Elwell/37a2c24a7b84bde20351019a69232310 to your computer and use it in GitHub Desktop.

Select an option

Save Elwell/37a2c24a7b84bde20351019a69232310 to your computer and use it in GitHub Desktop.
NTP to GPRMC in esphome to sync a nixie clock
---
# Wemos D1 R2 (esp8266) in office for providing fake GPS time signal from NTP
esphome:
name: nixie-ntp
comment: NTP to GPRMC time sync for nixie clock
includes: std_includes.h
esp8266:
board: d1_mini
wifi:
min_auth_mode: WPA2
fast_connect: true
power_save_mode: none
domain: .iot.elwell.au
networks:
- ssid: Telemetry_2G
password: !secret telemetry_pw
hidden: true
network:
enable_ipv6: true
logger:
level: DEBUG
api:
encryption:
key: !secret api_pw
ota:
platform: esphome
password: !secret ota_pw
text_sensor:
- platform: template
# name: NMEA
id: nmea
update_interval: 6s
lambda: |-
std::string UTC_T = id(my_time).utcnow().strftime("%H%M%S");
std::string UTC_D = id(my_time).utcnow().strftime("%d%m%y");
std::string out1 = "GPRMC," + UTC_T + ",A,4307.316,S,14713.705,E,0.0,000," + UTC_D + ",,,A,M";
char checksum = 0;
for (char c : out1) {
checksum ^= c;
}
std::stringstream cs;
cs << std::hex << std::uppercase<< (int)(unsigned char)checksum ;
std::string out2 = "$" + out1 + "*" + cs.str();
return {out2};
on_value:
- uart.write:
id: nixie_sync
data: !lambda |-
std::string str = id(nmea).state + "\r\n";
std::size_t pos;
return std::vector<uint8_t>(str.begin(), str.end());
time:
- platform: sntp
id: my_time
timezone: Australia/Hobart
servers:
- time.vk7hpc.net
uart:
tx_pin:
number: GPIO2
inverted: true
baud_rate: 4800
id: nixie_sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment