LTE Connectivity
The base station is equipped with a SIM7672X series cellular modem for LTE communication. This enables the device to connect to the internet and communicate with the MQTT broker when Wi-Fi is unavailable.
Functionality
- Automatic Failover: The system prioritizes Wi-Fi for MQTT communication. If Wi-Fi is not connected or loses connectivity, the system will attempt to connect via LTE. If Wi-Fi becomes available again, the system will switch back to Wi-Fi for MQTT.
- SIM Card Detection: The system checks for the presence and readiness of a SIM card.
- Network Registration: The modem automatically registers on the LTE network.
- APN Configuration: The Access Point Name (APN) can be configured. This is typically set via BLE or remote configuration.
- MQTT Communication: Once connected to the LTE network and GPRS is active, the device establishes an MQTT connection to the broker for data transmission and command reception.
- Signal Strength Monitoring: The LTE signal strength (RSSI) is monitored and can be queried.
- IMEI Retrieval: The International Mobile Equipment Identity (IMEI) of the modem can be retrieved.
- AT Command Interface: AT commands can be sent to the modem via the BLE Serial Debugging Characteristic for diagnostics and configuration.
Key Operations and Code References
- Initialization and Connection:
- The
connectToLTE()
function inmain.ino
handles the modem initialization, network registration, and GPRS connection. - It checks for SIM card presence using
simCardPresent()
(main.ino
). - Sets modem to LTE-only mode (
AT+CNMP=38
) and preferred network selection (AT+CMNB=3
). - APN, GPRS user, and GPRS password are used from
config.h
(though typically APN is configured dynamically).
- The
- MQTT over LTE:
reconnectModemMqtt()
inMQTT.ino
handles connecting to the MQTT broker over the LTE connection.modemMqttClient
(PubSubClient instance) is used for MQTT operations.modemCallback()
inMQTT.ino
processes incoming MQTT messages when connected via LTE.sendModemMqttData()
inMQTT.ino
publishes data to the MQTT broker via LTE.- The MQTT broker details (server, port, user, password) are defined in
config.h
.
- Signal Strength:
getRSSI()
inmain.ino
sends theAT+CSQ
command to the modem to retrieve signal quality.parseSignalStrength()
inmain.ino
parses the modem's response to extract the RSSI value.processSignalStrength()
inmain.ino
orchestrates displaying signal strength on the OLED.
- IMEI:
- The
getIMEI()
function inmain.ino
sendsAT+CGSN
(or similar) to retrieve the modem's IMEI.
- The
- Connectivity Check:
- The
connectivityCheck
task inSMARTA_L_v2.ino
periodically checks the status of both Wi-Fi and LTE connections (modem.isNetworkConnected()
). - If
wifiOnly
is false, LTE will be used as a fallback. - The system can be configured to reboot if both Wi-Fi and LTE connectivity are lost for a specified number of attempts (
rebootOnConnectivityLoss
andinternet_reconnect_attempts
).
- The
Configuration via BLE
The APN for the LTE modem can be set via the BLE "Wi-Fi Credentials" characteristic. Although named for Wi-Fi, the parsing logic in the mobile app and firmware can handle APN data if formatted correctly (e.g., ssid,,apn_name
). The firmware stores the APN in preferences.
AT Commands for Modem Interaction
The BLE Serial Debugging characteristic (f3b5a8d4-2b6e-4a1b-8b1e-3c4d5e6f7a93
) allows sending AT commands directly to the SIM7672X modem (via Serial1
). This is useful for:
- Checking SIM status: AT+CPIN?
- Checking network registration: AT+CREG?
or AT+CGREG?
- Checking signal quality: AT+CSQ
- Getting IMEI: AT+CGSN
- Getting IP address: AT+CGPADDR=1
- Other diagnostic and configuration commands.
The firmware often adds the "AT+" prefix to commands received via BLE if not already present. Responses from the modem are sent back as notifications on this characteristic.