Software/Arduino Core/Connectivity

LTE Modem

The A7683E library for a SIMCom A7683E LTE Cat-1 bis modem on the header UART, and the A7683EVideo library for uploading images.

advanced3 min read

The A7683E library drives a SIMCom A7683E cellular modem breakout connected to the Neuro N6 header. It provides power control, an AT command layer, packet data attachment and HTTP upload. The companion A7683EVideo library routes camera frames to the sketch for upload. The A7683E is LTE Cat-1 bis, a single receive antenna variant, and uses the A76XX AT command set.

Wiring

ModemNeuro N6DirectionNotes
VCCExternal 5 V2 A peak. Not supplied by the board
GNDSupply and board groundCommon ground is required
TXDD0 (PD0)Modem to boardUART4 RX, fixed
RXDD1 (PD1)Board to modemUART4 TX, fixed
PWRKEYAny free GPIOOutputOpen drain
RESETAny free GPIOOutputOpen drain
NETLIGHTAny free GPIOInputDriven by the modem

The library owns UART4 on PD0 and PD1. Serial remains on USB. The three control pins are run-time arguments; A7683E_NO_PIN denotes an unwired pin.

cpp
#include <A7683E.h>

A7683E.begin(MISO, D9, D10);           // PWRKEY, RESET, NETLIGHT
A7683E.powerOn();
A7683E.waitForReady();
A7683E.waitForNetwork();
A7683E.attachData("uk.lebara.mobi", "wap", "wap");
A7683E.httpBegin("http://host/ingest", "image/jpeg");
A7683E.httpPost(jpeg, jpegLen);

Control pins

PWRKEY and RESET are configured as open drain and only ever driven low. Released, the pin is high impedance and the modem's internal pull-up sets the level, so the board never sources current into a control rail that may not be 3.3 V.

PWRKEY is a toggle: 500 ms or more low switches the modem on, 2.5 s or more low switches it off. Pulsing a running modem switches it off, so powerOn() limits its attempts.

RESET is a hard reset and is safe to repeat.

NETLIGHT is an output of the modem. netlightState() samples it for a window and classifies the blink period: NETLIGHT_DARK, NETLIGHT_DATA (under 500 ms), NETLIGHT_SEARCHING (under 1.8 s), NETLIGHT_REGISTERED, NETLIGHT_SOLID or NETLIGHT_UNWIRED. Classification by measured period rather than a fixed table is used because timings differ between firmware builds while their ordering does not.

API

GroupMethods
Lifecyclebegin, beginOn(Stream&), setPins, end
PowerpowerOn, powerOff, reset, pulsePowerKey, pulseReset, isAlive
NETLIGHTnetlightState, netlightPeriodMs, netlightName
BaudfindBaud, syncBaud, baud
ATsendAT, sendATExpect, readLine, lastLine, writeRaw, writeBytes, flushInput
StatuswaitForReady, simReady, signalQuality, signalDbm, registrationStatus, isRegistered, waitForNetwork, getIMEI, getModel, getOperator
DatasetApn, setApnAuth, attachData, getLocalIP
HTTPhttpBegin, httpPost, httpStatus, httpEnd

Behaviours of the modem

Baud rate persistence. The AT+IPR setting is saved automatically. Once a sketch moves the modem to 921600 baud it remains there across power cycles, and a sketch assuming 115200 receives no response at all. findBaud() sweeps the common rates and adopts the one that answers; syncBaud() calls it first.

APN authentication order. The AT+CGAUTH write command takes the password before the username, while the read form reports them in the opposite order. setApnAuth() handles this.

HTTP data limits. AT+HTTPDATA takes its timeout in seconds and caps each transfer at 153600 bytes. httpPost() chunks larger bodies automatically.

UK APNs

NetworkAPNUsername, password
Lebara UKuk.lebara.mobiwap, wap
Vodafonepp.vodafone.co.ukwap, wap
giffgaffgiffgaff.comgg, p
EEeverywhereeesecure, secure
O2, Tescointernetnone
ThreeTMnone

Lebara requires the username and password; without them the modem attaches but receives no address.

Image upload

The LteThermalUpload example, under File > Examples > A7683EVideo, captures a VD66GY image, a Lepton thermal frame and a status record every thirty seconds and posts all three to a web server. Modem bring-up runs as a state machine in loop() rather than in setup(), so each step prints and a failed step retries. The upload is plain HTTP with a token in the URL and is not suitable for private data.

Clock profiles

UART4's kernel clock is derived from PLL1. The power save library's PS_CLOCK_ECO profile stops PLL1 and disables the UART. PS_CLOCK_LOW keeps it running. See Low Power.