Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based GPS and GSM Emergency Locator

Image of Arduino UNO Based GPS and GSM Emergency Locator

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with a SIM800L GSM Module and a Neo 6M GPS Module to send an SMS with GPS location data when a pushbutton is pressed. A 9V battery powers the GSM module, while the Arduino UNO powers the GPS module. A resistor is used in conjunction with the pushbutton to form a pull-down circuit, ensuring a stable digital input to the Arduino.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

Pushbutton

  • A simple switch mechanism for controlling some aspect of a machine or a process. Buttons are typically made out of hard material, usually plastic or metal.

SIM800L GSM Module

  • A complete Quad-band GSM/GPRS solution in an LGA package that can be embedded in customer applications, offering the highest reliability and robustness.

Resistor (10k Ohms)

  • A passive two-terminal electrical component that implements electrical resistance as a circuit element.

9V Battery

  • A standard size of battery typically used in portable electronics that require higher voltage.

Neo 6M GPS Module

  • A standalone GPS receiver that features high performance of the u-blox 6 positioning engine.

Wiring Details

Arduino UNO

  • 5V connected to Neo 6M GPS Module VCC and through a resistor to the pushbutton
  • GND connected to Neo 6M GPS Module GND, Pushbutton Pin 4, and SIM800L GSM Module GND
  • D11 connected to SIM800L GSM Module SIM_RXD
  • D10 connected to SIM800L GSM Module SIM_TXD
  • D4 connected to Neo 6M GPS Module TX
  • D3 connected to Neo 6M GPS Module RX
  • D2 connected to Pushbutton Pin 1

Pushbutton

  • One side (Pin 1) connected to Arduino UNO D2
  • Other side (Pin 4) connected to Arduino UNO GND
  • Pin 2 connected to one side of the resistor (other side connected to 5V from Arduino UNO)

SIM800L GSM Module

  • 5V connected to 9V Battery +
  • GND connected to 9V Battery -
  • SIM_TXD connected to Arduino UNO D10
  • SIM_RXD connected to Arduino UNO D11

Resistor (10k Ohms)

  • One side connected to Pushbutton Pin 2
  • Other side connected to 5V from Arduino UNO

9V Battery

  • + connected to SIM800L GSM Module 5V
  • - connected to SIM800L GSM Module GND

Neo 6M GPS Module

  • VCC connected to Arduino UNO 5V
  • GND connected to Arduino UNO GND
  • TX connected to Arduino UNO D4
  • RX connected to Arduino UNO D3

Documented Code

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

// Define pin numbers
const int buttonPin = 2;  // Push button connected to digital pin 2
const int gsmRxPin = 10;  // RX pin of GSM module
const int gsmTxPin = 11;  // TX pin of GSM module
const int gpsRxPin = 4;   // RX pin of GPS module
const int gpsTxPin = 3;   // TX pin of GPS module

// Create software serial objects
SoftwareSerial gsmSerial(gsmRxPin, gsmTxPin);
SoftwareSerial gpsSerial(gpsRxPin, gpsTxPin);

// Create a TinyGPS++ object
TinyGPSPlus gps;

// Variables
int buttonState = 0;
bool messageSent = false;
const char* phoneNumber = "+1234567890";  // Replace with the desired phone number
const char* message = "Emergency! Help needed at this location: ";

void setup() {
  Serial.begin(9600);
  gsmSerial.begin(9600);
  gpsSerial.begin(9600);
  
  pinMode(buttonPin, INPUT_PULLUP);
  
  // Initialize GSM module
  delay(1000);
  gsmSerial.println("AT");
  delay(1000);
  gsmSerial.println("AT+CMGF=1"); // Set SMS text mode
  delay(1000);
}

void loop() {
  // Update GPS data
  while (gpsSerial.available() > 0) {
    gps.encode(gpsSerial.read());
  }

  buttonState = digitalRead(buttonPin);

  if (buttonState == LOW && !messageSent) {
    sendSMS();
    messageSent = true;
  }
  
  if (buttonState == HIGH) {
    messageSent = false;
  }
}

void sendSMS() {
  Serial.println("Button pressed, sending SMS with location...");
  
  String locationMessage = message;
  
  if (gps.location.isValid()) {
    locationMessage += "http://maps.google.com/maps?q=";
    locationMessage += String(gps.location.lat(), 6);
    locationMessage += ",";
    locationMessage += String(gps.location.lng(), 6);
  } else {
    locationMessage += "GPS location not available";
  }
  
  // Send SMS
  gsmSerial.println("AT+CMGS=\"" + String(phoneNumber) + "\"");
  delay(1000);
  gsmSerial.print(locationMessage);
  delay(100);
  gsmSerial.write(26); // End SMS with Ctrl+Z character
  
  Serial.println("SMS sent with location!");
  delay(1000);
}

This code is designed to be uploaded to an Arduino UNO. It initializes the GSM and GPS modules and checks for button presses. When the button is pressed, it sends an SMS with the current GPS location to a predefined phone number. The code uses the TinyGPS++ library to parse the GPS data and SoftwareSerial to communicate with the GSM and GPS modules.