Back to Tutorial

ESP32 with AI Thinker GP-02 GPS Module


✅ What is AI Thinker GP-02?

The AI Thinker GP-02 is a GNSS (GPS) module, designed to work with satellite navigation systems to provide:

  • Real-time location data (latitude, longitude)
  • Speed
  • Altitude
  • Time (UTC)
  • and more

It supports multiple satellite constellations:

  • GPS (USA)
  • GLONASS (Russia)
  • Galileo (EU)
  • BeiDou (China)

It communicates using UART (Serial) and is ideal for ESP32, Arduino, STM32, etc.


🧩 Features of GP-02 (AI Thinker GNSS Module):

FeatureDetail
CommunicationUART (TX/RX)
ProtocolNMEA0183
Baud Rate9600 bps (default)
Voltage3.3V logic and power
Satellite supportGPS, GLONASS, BDS, Galileo
Accuracy~2.5m
Update Rate1Hz (default), can be increased

📌 Pinout of AI Thinker GP-02:

GP-02 PinFunction
VCC3.3V
GNDGround
TXSerial TX (data from GPS to ESP32)
RXSerial RX (data from ESP32 to GPS)

🧠 Note: You only need TX → RX and VCC/GND for location data reading.


🔌 Connecting GP-02 to ESP32

Use SoftwareSerial alternative like HardwareSerial in ESP32:

GP-02ESP32
VCC3.3V
GNDGND
TXGPIO 16 (RX of ESP32)
RXGPIO 17 (TX of ESP32)

You can use any available hardware UART (ESP32 has 3 UARTs: Serial0, Serial1, Serial2)


📄 Arduino Code Example for ESP32 + GP-02

We’ll use the TinyGPSPlus library to parse GPS data:

🛠️ Step 1: Install Library

Go to Arduino IDE:

  • Sketch > Include Library > Manage Libraries
  • Install TinyGPSPlus

📌 Use Cases for GP-02

ProjectDescription
📍 GPS TrackerReal-time location tracking via GSM/LoRa/WiFi
🚴 Bike SpeedometerGet speed, distance, and log path
🛰️ IoT Location LoggerStore location logs in SD card or send to server
🚗 Geo-fencingTrigger actions based on location boundaries
🧭 Navigation DevicePortable handheld GPS tool with OLED display

🧠 Pro Tips

  • Must be outdoors or near a window for best signal.
  • Cold start may take 30–60 seconds for the first lock.
  • Use a small GPS patch antenna for better reception if available.
HOW TO OPERATE

#include <TinyGPS++.h>
#include <HardwareSerial.h>

TinyGPSPlus gps;
HardwareSerial GPS(1);  // UART1

#define RXD2 16  // Connect to GP-02 TX
#define TXD2 17  // Connect to GP-02 RX

void setup() {
  Serial.begin(115200);  // Debug Serial Monitor
  GPS.begin(9600, SERIAL_8N1, RXD2, TXD2);  // Start GPS UART

  Serial.println("GP-02 GPS Location to Google Maps");
}

void loop() {
  while (GPS.available()) {
    gps.encode(GPS.read());

    if (gps.location.isUpdated()) {
      float lat = gps.location.lat();
      float lon = gps.location.lng();

      Serial.println("Location Updated:");
      Serial.print("Latitude: "); Serial.println(lat, 6);
      Serial.print("Longitude: "); Serial.println(lon, 6);

      // Google Maps URL
      Serial.print("Google Maps: ");
      Serial.print("https://www.google.com/maps/place/");
      Serial.print(lat, 6);
      Serial.print(",");
      Serial.println(lon, 6);

      Serial.println("-----------------------------");
      delay(5000);  // Wait before printing next update
    }
   
  }
   Serial.println("INVALID LOCATION");
}
ESP32 with AI Thinker GP-02 GPS Module

Share this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Tutorial