Issues with Arduino Nano ESP32 and GPS module

Hi there!

I’m trying to get an ESPHome NTP server running using an Arduino Nano ESP32 and a GPS module.

As far as I can tell, the module should work given that it uses NMEA to communicate, but the only output I get is -1 for every reading even after the red light starts flashing, indicating a good satellite lock.

Here’s what I get in the logs:

[12:28:03][I][app:100]: ESPHome version 2024.7.2 compiled on Jul 25 2024, 20:36:57
[12:28:03][C][wifi:599]: WiFi:
[12:28:03][C][wifi:427]:   Local MAC: EC:DA:3B:60:19:08
[12:28:03][C][wifi:432]:   SSID: 'topsecret'
[12:28:03][C][wifi:435]:   IP Address: 10.13.15.13
[12:28:03][C][wifi:439]:   BSSID: FA:9F:C2:A4:68:E5
[12:28:03][C][wifi:440]:   Hostname: 'gps-esp32'
[12:28:03][C][wifi:442]:   Signal strength: -94 dB ▂▄▆█
[12:28:03][V][wifi:444]:   Priority: -65.0
[12:28:03][C][wifi:446]:   Channel: 6
[12:28:03][C][wifi:447]:   Subnet: 255.255.255.0
[12:28:03][C][wifi:448]:   Gateway: 10.13.15.1
[12:28:03][C][wifi:449]:   DNS1: 10.13.13.253
[12:28:03][C][wifi:450]:   DNS2: 10.13.13.254
[12:28:03][C][logger:185]: Logger:
[12:28:03][C][logger:186]:   Level: VERY_VERBOSE
[12:28:03][C][logger:188]:   Log Baud Rate: 115200
[12:28:03][C][logger:189]:   Hardware UART: UART0
[12:28:03][C][uart.arduino_esp32:151]: UART Bus 1:
[12:28:03][C][uart.arduino_esp32:155]:   RX Buffer Size: 256
[12:28:03][C][uart.arduino_esp32:159]:   Parity: NONE
[12:28:03][C][captive_portal:088]: Captive Portal:
[12:28:03][C][web_server:173]: Web Server:
[12:28:03][V][mdns:120]:   - _esphomelib, _tcp, 6053
[12:28:03][V][mdns:122]:     TXT: version = 2024.7.2
[12:28:03][C][esphome.ota:073]: Over-The-Air updates:
[12:28:03][C][esphome.ota:078]:   Password configured
[12:28:03][C][safe_mode:020]:   Boot considered successful after 60 seconds
[12:28:03][C][api:139]: API Server:
[12:28:03][C][api:140]:   Address: gps-esp32.iot.lan:6053
[12:28:03][C][api:142]:   Using noise encryption: YES
[12:28:03][C][wifi_signal.sensor:009]: WiFi Signal 'Wifi Signal Strength'
[12:28:13][VV][scheduler:226]: Running interval '' with interval=10000 last_execution=220901 (now=230901)
[12:28:14][VV][scheduler:226]: Running interval 'update' with interval=20000 last_execution=213260 (now=233260)
[12:28:14][V][sensor:043]: 'Latitude': Received new state -1.000000
[12:28:14][D][sensor:094]: 'Latitude': Sending state -1.00000 ° with 6 decimals of accuracy
[12:28:14][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 666130917
  state: -1
  missing_state: NO
}
[12:28:14][V][sensor:043]: 'Longitude': Received new state -1.000000
[12:28:14][D][sensor:094]: 'Longitude': Sending state -1.00000 ° with 6 decimals of accuracy
[12:28:14][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 2355190616
  state: -1
  missing_state: NO
}
[12:28:14][V][sensor:043]: 'Altitude': Received new state -1.000000
[12:28:14][D][sensor:094]: 'Altitude': Sending state -1.00000 m with 1 decimals of accuracy
[12:28:14][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 1141543723
  state: -1
  missing_state: NO
}
[12:28:14][V][sensor:043]: 'Satellites': Received new state -1.000000
[12:28:14][D][sensor:094]: 'Satellites': Sending state -1.00000  with 0 decimals of accuracy
[12:28:14][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 1135853463
  state: -1
  missing_state: NO
}
[12:28:14][W][component:237]: Component gps took a long time for an operation (106 ms).
[12:28:14][W][component:238]: Components should block for at most 30 ms.
[12:28:15][VV][scheduler:226]: Running interval 'update' with interval=30000 last_execution=204535 (now=234536)
[12:28:15][V][sensor:043]: 'Wifi Signal Strength': Received new state -93.000000
[12:28:15][D][sensor:094]: 'Wifi Signal Strength': Sending state -93.00000 dBm with 0 decimals of accuracy
[12:28:15][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 890054251
  state: -93
  missing_state: NO
}

…and here’s my current config:

substitutions:
  devicename: gps
  hostname: ${devicename}-esp32
  domain: .iot.lan
  fqdn: ${hostname}${domain}

esphome:
  name: ${hostname}

esp32:
  board: arduino_nano_esp32
  variant: ESP32S3
  framework:
    type: arduino
    version: 2.0.14

# Enable logging
logger:
  baud_rate: 115200
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: UART0
  level: VERY_VERBOSE
  logs: {}

external_components:
  source:
    type: git
    url: https://github.com/RobertJN64/ESPHome-NTP-Server
  refresh: 30s
  components: [ ntp_server ]


# Enable Home Assistant API
api:
  encryption:
    key: !secret api_enc_key
  port: 6053
  password: ''
  reboot_timeout: 15min


safe_mode:
  reboot_timeout: 5min
  num_attempts: 3


ota:
  - platform: esphome
    password: !secret ota_password
    version: 2
    port: 3232


# MAC: ec:da:3b:60:19:08
wifi:
  ap:
    ssid: ${hostname} Fallback Hotspot
    password: !secret fallback_wifi_password
    ap_timeout: 1min
  domain: ${domain}
  reboot_timeout: 15min
  fast_connect: true
  passive_scan: false
  enable_on_boot: true
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
    priority: 0.0
  use_address: ${fqdn}


captive_portal:

uart:
  - id: uart_gps
    rx_pin: GPIO6
    tx_pin: GPIO5
    baud_rate: 9600
    # debug:
    #   direction: BOTH
    #   dummy_receiver: true
    #   after:
    #     delimiter: "\n"
    #   sequence:
    #     - lambda: UARTDebug::log_string(direction, bytes);

gps:
  uart_id: uart_gps
  latitude:
    name: "Latitude"
  longitude:
    name: "Longitude"
  altitude:
    name: "Altitude"
  satellites:
    name: "Satellites"

ntp_server:

time:
  - platform: gps
    id: gps_time
    on_time:
      - seconds: '*'
        then:
          - lambda: 'ESP_LOGI("gps", "%02d:%02d:%02d", id(gps_time).now().hour, id(gps_time).now().minute, id(gps_time).now().second);'

sensor:
  - platform: wifi_signal
    name: Wifi Signal Strength
    update_interval: 30s


# Included for Prometheus metrics below.
web_server:


# Activate prometheus /metrics endpoint
prometheus:



If anyone has any tips on where I may be going wrong, I’m all ears. Thanks in advance!

I’ve confirmed as best I can that I’ve got TX on the GPS module (white wire) connected to RX on the ESP32 and RX on the GPS module (green wire) connected to TX on the ESP32.

I’m powering via USB-C, so the VBUS pin should be providing the correct 5v to the GPS module.