ESPHome: GPS Time
In my previous post I used Homeassistant to get the current time and show it on a display. GPS sensors are pretty cheap and I have a few of them in my electronics box. So why not use GPS to get the current time for the display.
GPS chips are connected via UART. I used Pin 16 and 17 and connected the RX pin of the GPS with the TX pin of the Pico (Pin 16). And the TX pin of the GPS then to Pin 17 (RX) on the Pico.
GPS needs a bit time to find satellites, so the time starts at 01:00 until it is set to the correct time. The GPS module (at least the one I am using) is blinking blue when it gets new data. Per default the GPS ESPHome code is announcing Latitude, Longintude, Speed, Altitude, Course and Satellites. So these values could be added in Homeassistant easily.
On the display I wanted of course see the current time. But to show how to add values from the GPS I added the number of satellites.
I moved the display to different pins, because I used a breadboard. So the I2C pins are 20 and 21.
ESPHome config of GPS with display (api, wifi, logger, ota removed)
uart: tx_pin: 16 rx_pin: 17 baud_rate: 9600 gps: satellites: # add id to reference it for the display id: num_sat time: - platform: gps id: gpstime timezone: Europe/Berlin font: - file: "gfonts://Roboto" id: font1 size: 24 - file: "gfonts://Roboto" id: font2 size: 18 i2c: sda: 20 scl: 21 scan: false display: - platform: ssd1306_i2c model: "SH1106 128x64" address: 0x3C lambda: |- it.strftime(0, 0, id(font1), "%H:%M", id(gpstime).now()); it.printf(0, 31, id(font2), "Satellites: %1.0f", id(num_sat).state);