--- # Hardware: LilyGO T-PCIE with SIM7600 module # Pinout: # GPIO4 Modem PWRKEY -> modem_powerkey (switch gpio) # GPIO12 LED -> led (switch gpio) (inverted) # GPIO21 -> system_i2c (i2c sda) # GPIO22 -> system_i2c (i2c scl) # GPIO25 Modem power enable -> modem_enable (switch gpio) # GPIO26 Modem TXD -> atmodem (modem rx_pin) # GPIO27 Modem RXD -> atmodem (modem tx_pin) # GPIO32 Modem DTR -> modem_dtr (binary_sensor gpio) # GPIO33 Modem RI -> modem_ri (binary_sensor gpio) # GPIO36 Modem STATUS -> modem_status (binary_sensor gpio) # I2C: # 0x34 pmu_axp (axp192), LDO3 powers the GNSS antenna # 0x3C OLED (display ssd1306_i2c) substitutions: device: tracker name: Tracker area: DEV comment: LTE GPS tracker esphome: name: mcu-${device} friendly_name: ${name} area: ${area} comment: ${comment} on_boot: priority: 600 then: - logger.log: turning modem on - switch.turn_on: led - switch.turn_on: modem_enable - delay: 1s - switch.turn_on: modem_powerkey - delay: 500ms - switch.turn_off: modem_powerkey - switch.turn_on: gnss_enable - delay: 4s - wait_until: condition: binary_sensor.is_on: modem_status timeout: 30s - logger.log: modem on - modem.enable esp32: variant: esp32 framework: type: esp-idf advanced: flash_chip: generic sram1_as_iram: true # packages: # common: !include common/common.yaml # modem only for now, no WiFi # ipv6_only: !include common/ipv6_only.yaml external_components: - source: github://m5stack/esphome-yaml/components components: [axp192] refresh: 1h - source: github://pr#6721 components: [modem] logger: level: VERBOSE i2c: - id: system_i2c sda: 21 scl: 22 scan: true axp192: id: pmu_axp address: 0x34 i2c_id: system_i2c modem: id: atmodem rx_pin: 26 tx_pin: 27 model: SIM7600 apn: o2internet enable_on_boot: false # on_boot powers the modem up first # pin_code: "" init_at: - AT+AUTOCSQ=1,1 # URC +CSQ on every signal change - AT+CPSI=60 # URC +CPSI (system mode, operator) every 60 s # The modem comes up in CFUN=0 (SIM off) and the component sets the APN before # turning the radio on, so AT+CGDCONT fails until this - AT+CFUN=1 - AT+CGNSSMODE=15,1 # GNSS all navigation systems - AT+CGPS=1 # GPS on # API is unreachable over LTE, the tracker has to talk MQTT mqtt: id: mqtt_client broker: !secret mqtt_ext username: !secret mqtt_username password: !secret mqtt_password discovery: true output: # DLDO3 in the m5stack component = AXP192 LDO3 - platform: axp192 id: gnss_power channel: DLDO3 voltage: 3300 binary_sensor: - <<: !include common/binary_sensor/status.yaml - platform: gpio id: modem_dtr pin: 32 - platform: gpio id: modem_ri pin: 33 - platform: gpio id: modem_status pin: 36 button: - <<: !include common/button/restart.yaml sensor: - <<: !include common/sensor/uptime.yaml - platform: template id: modem_rssi name: Modem Signal device_class: signal_strength unit_of_measurement: dBm entity_category: diagnostic update_interval: never # - platform: modem # rssi: # name: rssi # ber: # name: ber # latitude: # name: Latitude # longitude: # name: Longitude # altitude: # name: Altitude switch: - platform: gpio id: modem_powerkey pin: 4 - platform: gpio id: led pin: 12 inverted: true - platform: gpio id: modem_enable pin: 25 - platform: output id: gnss_enable output: gnss_power # - platform: modem # gnss: # name: GNSS # restore_mode: ALWAYS_ON text_sensor: - <<: !include common/text_sensor/version.yaml - platform: template id: modem_network name: Modem Network entity_category: diagnostic update_interval: never # Signal and network mode come as URCs; the component has no sensors for them yet - platform: modem urc: id: modem_urc internal: true on_value: - lambda: |- int a, b; if (sscanf(x.c_str(), "+CSQ: %d,%d", &a, &b) == 2) { id(modem_rssi).publish_state(a >= 0 && a <= 31 ? -113 + 2 * a : NAN); } else if (x.rfind("+CPSI: ", 0) == 0) { // +CPSI: ,[,-,...] char mode[16], op[16]; int n = sscanf(x.c_str(), "+CPSI: %15[^,],%*[^,],%15[^,]", mode, op); if (n >= 1) id(modem_network).publish_state(n == 2 ? std::string(mode) + " " + op : std::string(mode)); } - platform: template id: modem_ip name: Modem IP Address entity_category: diagnostic update_interval: 60s lambda: |- char buf[network::IP_ADDRESS_BUFFER_SIZE]; auto ip = id(atmodem).get_ip_addresses()[0]; return std::string(ip.is_set() ? ip.str_to(buf) : ""); # - platform: modem # network_type: # name: network type # signal_strength: # name: Signal strength font: - file: "gfonts://Roboto" id: font_small size: 12 display: - platform: ssd1306_i2c model: "SSD1306 128x64" address: 0x3C i2c_id: system_i2c update_interval: 2s lambda: |- it.printf(0, 0, id(font_small), "%s", id(modem_network).has_state() ? id(modem_network).state.c_str() : "--"); if (id(modem_rssi).has_state() && !std::isnan(id(modem_rssi).state)) it.printf(127, 0, id(font_small), TextAlign::TOP_RIGHT, "%.0f dBm", id(modem_rssi).state); it.printf(0, 16, id(font_small), "PPP: %s", id(atmodem).is_connected() ? "OK" : "--"); it.printf(127, 16, id(font_small), TextAlign::TOP_RIGHT, "MQTT: %s", id(mqtt_client)->is_connected() ? "OK" : "--"); it.printf(0, 32, id(font_small), "%s", id(modem_ip).state.c_str()); it.printf(0, 48, id(font_small), "Up %.2f d", id(uptime_sensor).state);