--- # Hardware: M5Stack M5Stamp C3, GNSS test bench with two receivers # Pinout: # GPIO0 Grove A pin 4, UART TX -> uart_m10 (uart tx_pin) # GPIO1 Grove A pin 3, UART RX -> uart_m10 (uart rx_pin) # GPIO18 Grove B pin 4 (USB D-), UART TX -> uart_neo6m (uart tx_pin) # GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_neo6m (uart rx_pin) # GPIO20 UART0 RX (on-board USB to UART), unused: logger is API only # GPIO21 UART0 TX (on-board USB to UART), unused: logger is API only # Grove pin order: GND, 5V, signal, signal # Receivers: # Grove A XYZ GNSS YM-250, u-blox M10 (ROM SPG 5.10, PROTVER 34.10), 38400 baud -> gnss_m10 (ubx) # Grove B APM NEO-6M, u-blox 6 (7.03), 9600 baud -> gnss_neo6m (nmea) substitutions: device: eworkbench name: Electronics Workbench area: Office R comment: Electronics Workbench esphome: name: mcu-${device} friendly_name: ${name} area: ${area} comment: ${comment} platformio_options: board_build.flash_mode: dio esp32: variant: esp32c3 toolchain: esp-idf framework: type: esp-idf advanced: flash_chip: generic packages: common: !include common/common.yaml ipv6_only: !include common/ipv6_only.yaml external_components: # gnss hub + nmea and ubx platforms, esphome/esphome#23301 (stacked on #23293) - source: github://pr#23301 components: [gnss, nmea, ubx] logger: # The C3 has two UARTs and both receivers need one; logs go over the API only baud_rate: 0 uart: - id: uart_m10 rx_pin: 1 tx_pin: 0 baud_rate: 38400 # Test aid: decode the answers to the polls in interval below debug: direction: RX after: bytes: 1024 timeout: 50ms sequence: - lambda: |- for (size_t i = 0; i + 8 <= bytes.size(); i++) { if (bytes[i] != 0xB5 || bytes[i + 1] != 0x62) continue; const uint8_t cls = bytes[i + 2], id = bytes[i + 3]; const size_t len = bytes[i + 4] | (bytes[i + 5] << 8); if (i + 6 + len > bytes.size()) break; const uint8_t *p = bytes.data() + i + 6; if (cls == 0x0A && id == 0x28 && len >= 8) { ESP_LOGI("ubxdbg", "MON-GNSS supported 0x%02X default 0x%02X enabled 0x%02X (bit0 GPS 1 GLO 2 BDS 3 GAL), max %u at once", p[1], p[2], p[3], p[4]); } else if (cls == 0x01 && id == 0x35 && len >= 8) { static const char *const NAMES[] = {"GPS", "SBAS", "GAL", "BDS", "IMES", "QZSS", "GLO", "NAVIC"}; int tracked[8] = {0}, used[8] = {0}, sbas_corr = 0; std::string sbas; const uint8_t num = p[5]; for (uint8_t k = 0; k < num && 8 + 12 * (k + 1) <= len; k++) { const uint8_t *b = p + 8 + 12 * k; const uint32_t flags = b[8] | (b[9] << 8) | (b[10] << 16) | ((uint32_t) b[11] << 24); const uint8_t g = b[0] & 7; if (b[2] > 0) tracked[g]++; if (flags & (1u << 3)) used[g]++; if (flags & (1u << 16)) sbas_corr++; if (b[0] == 1 && b[2] > 0) { char buf[16]; snprintf(buf, sizeof(buf), " %u:%u", b[1], b[2]); sbas += buf; } } std::string summary; for (int g = 0; g < 8; g++) { if (tracked[g] == 0) continue; char buf[24]; snprintf(buf, sizeof(buf), " %s %d/%d", NAMES[g], used[g], tracked[g]); summary += buf; } ESP_LOGI("ubxdbg", "NAV-SAT used/tracked:%s; SBAS-corrected %d; SBAS PRN:cno%s", summary.c_str(), sbas_corr, sbas.c_str()); } i += 5 + len; } - id: uart_neo6m rx_pin: 19 tx_pin: 18 baud_rate: 9600 gnss: - platform: ubx id: gnss_m10 uart_id: uart_m10 update_interval: 10s - platform: nmea id: gnss_neo6m uart_id: uart_neo6m update_interval: 10s sensor: - platform: gnss gnss_id: gnss_m10 type: latitude name: M10 Latitude - platform: gnss gnss_id: gnss_m10 type: longitude name: M10 Longitude - platform: gnss gnss_id: gnss_m10 type: altitude name: M10 Altitude - platform: gnss gnss_id: gnss_m10 type: speed name: M10 Speed - platform: gnss gnss_id: gnss_m10 type: course name: M10 Course - platform: gnss gnss_id: gnss_m10 type: satellites name: M10 Satellites - platform: gnss gnss_id: gnss_m10 type: hdop name: M10 HDOP - platform: gnss gnss_id: gnss_m10 type: horizontal_accuracy name: M10 Horizontal Accuracy - platform: gnss gnss_id: gnss_m10 type: vertical_accuracy name: M10 Vertical Accuracy - platform: gnss gnss_id: gnss_neo6m type: latitude name: NEO-6M Latitude - platform: gnss gnss_id: gnss_neo6m type: longitude name: NEO-6M Longitude - platform: gnss gnss_id: gnss_neo6m type: altitude name: NEO-6M Altitude - platform: gnss gnss_id: gnss_neo6m type: speed name: NEO-6M Speed - platform: gnss gnss_id: gnss_neo6m type: course name: NEO-6M Course - platform: gnss gnss_id: gnss_neo6m type: satellites name: NEO-6M Satellites - platform: gnss gnss_id: gnss_neo6m type: hdop name: NEO-6M HDOP time: - platform: gnss id: gnss_time gnss_id: gnss_m10 on_time_sync: - logger.log: GNSS time synced interval: # Test aid: constellations and satellites of the M10 - interval: 60s then: - uart.write: id: uart_m10 data: [0xB5, 0x62, 0x0A, 0x28, 0x00, 0x00, 0x32, 0xA0] - delay: 2s - uart.write: id: uart_m10 data: [0xB5, 0x62, 0x01, 0x35, 0x00, 0x00, 0x36, 0xA3]