GPS & AGPS Demystified
The definitive architectural guide to positioning on the A7: where the missing GPS_RX pin went, when to use GPS_TXD vs AT+GPSRD, how AT+AGPS speeds up locks, and fixing the active antenna bias blackout.
BLUF: Is AT+GPSRD Required to Read GPS Coordinates?
No, unless you only have a single UART.
If your microcontroller has two serial ports (ESP32, STM32, Arduino Mega 2560), connect MCU RX2 directly to GPS_TXD (Header P1 Pin 11) at 9600 baud and send AT+GPS=1. Standard NMEA sentences stream out of GPS_TXD continuously. Do not send AT+GPSRD in this setup. (For the zero-conflict ESP32 wiring map, see the ESP32 Pinout Guide.)
AT+GPSRD=1 is only required if you are using an Arduino Uno with a single serial port and want the module to mirror NMEA sentences onto the main AT serial port.
1. Where Did the GPS_RX Pin Go?
On standalone GPS modules like the u-blox NEO-6M, you transmit proprietary binary or PMTK configuration packets to a GPS_RX pin. On the AI-Thinker A7, there is no GPS_RX pin on either header.
This is because the GPS engine is an internal silicon block of the RDA8951G processor. The central ARM core controls the GPS receiver internally:
- You command the GPS engine using standard AT commands on the main UART (
U_RXD). - The GPS engine transmits standard NMEA 0183 sentences (
$GPRMC,$GPGGA,$GPVTG,$GPGSV) out of the dedicatedGPS_TXDpin (Header P1 Pin 11) at 9600 baud (8N1).
2. The Two Operating Modes: Hardware Stream vs AT+GPSRD
Direct Hardware Stream (GPS_TXD)
For ESP32, STM32, Arduino Mega 2560, and Raspberry Pi Pico:
- Wire MCU Serial 1 to
U_TXD/U_RXD(AT Commands @ 115200). - Wire MCU Serial 2 RX to
GPS_TXD(Fixed @ 9600 baud). - Send:
AT+GPS=1on Serial 1. - Read raw NMEA stream directly from Serial 2 using libraries like TinyGPSPlus.
✓ Clean architecture: AT command parser is never corrupted by incoming NMEA sentences.
AT Port Redirection (AT+GPSRD)
For Arduino Uno / Nano with only one hardware or software UART:
- Leave
GPS_TXDunconnected. - Wire MCU only to
U_TXDandU_RXD. - Send:
AT+GPS=1 - Send:
AT+GPSRD=1(Mirrors NMEA onto the AT port every 1 sec). - Crucial: Send
AT+GPSRD=0to stop before sending SMS!
! Warning: If left active, NMEA text will collide with your AT responses.
AT+GPSRD=1 is active, the A7 dumps multiple lines of NMEA text across the AT port every second. If your microcontroller tries to execute an AT command (like AT+CMGS to send an SMS or AT+CIPSTART to open a web socket), the incoming GPS sentences interleave directly with the modem's OK or > response, corrupting your parser! Always issue AT+GPSRD=0 prior to sending AT commands.
3. The Power of `AT+AGPS`: Slashing Lock Time to Seconds
Cold-start GPS locks take between 45 seconds and 3 minutes because satellites transmit orbital ephemeris data at an agonizingly slow 50 bits per second. The A7's Assisted GPS (AGPS) feature uses the cellular 2G GPRS connection to download ephemeris data from an internet server in ~2 seconds, slashing Time-To-First-Fix (TTFF) to 5–15 seconds.
How to Issue `AT+AGPS` Safely:
// 1. Ensure GPS is currently OFF (Crucial: prevents baseband freeze!)
AT+GPS=0
OK
// 2. Attach to GPRS cellular network
AT+CGATT=1
OK
// 3. Activate PDP context
AT+CGACT=1,1
OK
// 4. Issue the AGPS command (Module downloads ephemeris & turns on GPS)
AT+AGPS=1
OK
AT+AGPS=1 while AT+GPS=1 is already running, or if you issue AT+AGPS=1 without an active GPRS data connection, the baseband modem blocks indefinitely waiting on an internal socket timeout. Always ensure GPS is OFF (AT+GPS=0) and GPRS is active before calling AT+AGPS=1.
4. The 100-Iteration Firmware Memory Leak Bug
Discovered by Arduino forum members (threads 428348 and 519888), the RDA8951G firmware has a known heap memory leak in its RTOS GPS task initialization and teardown routines.
If your embedded code repeatedly turns GPS on and off to conserve battery (AT+GPS=1 → read fix → AT+GPS=0), after approximately 100 to 110 iterations, the GPS task crashes. The command returns ERROR, and no satellites are ever seen again until power is physically pulled from the board.
Proven Mitigations:
- Strategy A (Keep GPS Active): Keep
AT+GPS=1running continuously. The GPS receiver draws only ~35mA. When not logging, simply ignore the incoming serial data. - Strategy B (Watchdog Reset Counter):** If battery life requires cycling GPS off, maintain a cycle counter in microcontroller RAM. After every 50 GPS cycles, issue a clean software reboot via
AT+RST=1or toggle the hardwareRESETpin for 150ms. This resets the RTOS heap and completely prevents the freeze.
5. GPS Antennas: Active vs Passive & The Missing Bias Tee
If you plug a common black magnetic active GPS antenna into the A7's u.FL socket (J4), you will typically see zero satellites even under a clear sky.
The Root Cause: Active GPS antennas contain an internal Low-Noise Amplifier (LNA) that requires 3.0V–5.0V DC phantom power. The AI-Thinker A7 development board has NO DC bias circuitry on Port J4. It connects directly to the module pin. Without power, the antenna's unpowered LNA acts as a massive RF attenuator ($-25\text{dB}$), deafening the module.
Solution 1: Use a Passive Antenna
Passive ceramic patch antennas (15mm×15mm or 25mm×25mm) require no power. Plugged directly into J4, they work immediately out of the box.
Solution 2: The 1-Inductor Bias Mod
If an active antenna is required, solder a 47nH to 100nH RF choke inductor from the VCC4.0 (or 3.3V) rail to the center pin of the GPS u.FL socket, with a 100pF DC-blocking capacitor to the A7 pin. This injects phantom power into the coax.