Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32 and Neo 6M GPS Module Battery-Powered GPS Tracker

View and Edit Project In Cirkit DesignerImage of ESP32 and Neo 6M GPS Module Battery-Powered GPS Tracker

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates an ESP32 microcontroller, a Neo 6M GPS module, a 18650 Li-ion battery, and a Rocker Switch (SPST). The ESP32 is programmed to read GPS data from the Neo 6M module and output the information via serial communication. The circuit is powered by a 18650 Li-ion battery, with a rocker switch to control the power supply.

Component List

ESP32 (30 pin)

Neo 6M GPS Module

18650 Li-ion Battery

Rocker Switch (SPST)

Wiring Details

ESP32 (30 pin)

Neo 6M GPS Module

18650 Li-ion Battery

Rocker Switch (SPST)

Code Documentation

sketch.ino

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

#define GPS_BAUDRATE 9600  // The default baudrate of NEO-6M is 9600

TinyGPSPlus gps;  // the TinyGPS++ object

void setup() {
  Serial.begin(9600);
  Serial2.begin(GPS_BAUDRATE); // serial2 for GPS UART

  Serial.println(F("ESP32 - GPS module_Simulation"));
}

void loop() {
  if (Serial2.available() > 0) {
    if (gps.encode(Serial2.read())) {
      if (gps.location.isValid()) {
        Serial.print(F("Latitude: "));
        Serial.println(gps.location.lat(), 6);

        Serial.print(F("Longitude: "));
        Serial.println(gps.location.lng(), 6);

        Serial.print(F("Altitude: "));
        if (gps.altitude.isValid())
          Serial.println(gps.altitude.meters());
        else
          Serial.println(F("INVALID"));
      } else {
        Serial.println(F("Location: INVALID"));
      }

      Serial.print(F("Speed: "));
      if (gps.speed.isValid()) {
        Serial.print(gps.speed.kmph());
        Serial.println(F(" km/h"));
      } else {
        Serial.println(F("INVALID"));
      }

      Serial.print(F("GPS date&time: "));
      if (gps.date.isValid() && gps.time.isValid()) {
        Serial.print(gps.date.year());
        Serial.print(F("-"));
        Serial.print(gps.date.month());
        Serial.print(F("-"));
        Serial.print(gps.date.day());
        Serial.print(F(" "));
        Serial.print(gps.time.hour());
        Serial.print(F(":"));
        Serial.print(gps.time.minute());
        Serial.print(F(":"));
        Serial.println(gps.time.second());
      } else {
        Serial.println(F("INVALID"));
      }

      Serial.println();
    }
  }

  if (millis() > 5000 && gps.charsProcessed() < 10)
    Serial.println(F("No GPS data received: check wiring"));
}

This code initializes the ESP32 to communicate with the Neo 6M GPS module via UART (Serial2). It reads GPS data and prints the latitude, longitude, altitude, speed, and date & time to the serial monitor. If no GPS data is received within 5 seconds, it prompts to check the wiring.