--- # 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_at6668 (uart tx_pin) # GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_at6668 (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 M5Stack Cap LoRa-1262 GNSS, AT6668 (CASIC), 115200 baud -> gnss_at6668 (casic) 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: # geolocation hub + nmea, ubx and casic platforms: esphome/esphome#23301 (stacked on #23293) + casic, not upstream yet - source: github://randybb/esphome@geolocation-casic components: [geolocation, nmea, ubx, casic] 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_at6668 rx_pin: 19 tx_pin: 18 baud_rate: 115200 geolocation: - platform: ubx id: gnss_m10 uart_id: uart_m10 update_interval: 10s - platform: casic id: gnss_at6668 uart_id: uart_at6668 update_interval: 10s sensor: - platform: geolocation geolocation_id: gnss_m10 type: latitude name: M10 Latitude - platform: geolocation geolocation_id: gnss_m10 type: longitude name: M10 Longitude - platform: geolocation geolocation_id: gnss_m10 type: altitude name: M10 Altitude - platform: geolocation geolocation_id: gnss_m10 type: speed name: M10 Speed - platform: geolocation geolocation_id: gnss_m10 type: course name: M10 Course - platform: geolocation geolocation_id: gnss_m10 type: satellites name: M10 Satellites - platform: geolocation geolocation_id: gnss_m10 type: hdop name: M10 HDOP - platform: geolocation geolocation_id: gnss_m10 type: horizontal_accuracy name: M10 Horizontal Accuracy - platform: geolocation geolocation_id: gnss_m10 type: vertical_accuracy name: M10 Vertical Accuracy - platform: geolocation geolocation_id: gnss_at6668 type: latitude name: AT6668 Latitude - platform: geolocation geolocation_id: gnss_at6668 type: longitude name: AT6668 Longitude - platform: geolocation geolocation_id: gnss_at6668 type: altitude name: AT6668 Altitude - platform: geolocation geolocation_id: gnss_at6668 type: speed name: AT6668 Speed - platform: geolocation geolocation_id: gnss_at6668 type: course name: AT6668 Course - platform: geolocation geolocation_id: gnss_at6668 type: satellites name: AT6668 Satellites - platform: geolocation geolocation_id: gnss_at6668 type: hdop name: AT6668 HDOP time: - platform: geolocation id: gnss_time geolocation_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]