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

Arduino UNO-Based Ultrasonic and GPS Tracking System with GSM Alert

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Ultrasonic and GPS Tracking System with GSM Alert

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates an Arduino UNO microcontroller with various sensors and modules, including two HC-SR04 Ultrasonic Sensors, a GPS NEO 6M module, and a GSM SIM900 module. The circuit is designed to measure distances, obtain GPS coordinates, and send data via GSM.

Component List

Arduino UNO

HC-SR04 Ultrasonic Sensor (1)

HC-SR04 Ultrasonic Sensor (2)

GPS NEO 6M

GSM SIM900

Wiring Details

Arduino UNO

HC-SR04 Ultrasonic Sensor (1)

HC-SR04 Ultrasonic Sensor (2)

GPS NEO 6M

GSM SIM900

Code Documentation

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
#define trigPin 8
#define echoPin 9
int redled = 13;

void setup() {
  randomSeed(analogRead(0));
  Serial.begin(9600);
  mySerial.begin(9600); // original 19200. while enter 9600 for sim900A
  Serial.println(" logging time completed!");
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(redled, OUTPUT);
  digitalWrite(redled, LOW);
  delay(100);
}

void loop() {
  long time_duration, distance_in_cm;
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  time_duration = pulseIn(echoPin, HIGH);
  distance_in_cm = time_duration / 29 / 2;

  Serial.print(distance_in_cm);
  Serial.println(" cm");

  // Ranging Distance − 2cm – 400 cm
  // if the distance is equal or more then 10 cm
  if (distance_in_cm >= 10) {
    digitalWrite(redled, HIGH);
    Serial.println("Motion detected!");
    Serial.println("calling....");
    
    mySerial.println("AT"); // Once the handshake test is successful, it will back to OK
    updateSerial();
    
    mySerial.println("ATD+ +251712973006;"); // change ZZ with country code and xxxxxxxxxxx with phone number to dial
    updateSerial();
    delay(30000); // wait for 30 seconds...
    mySerial.println("ATH"); // hang up
    updateSerial();

    delay(3000);
  } else {
    digitalWrite(redled, LOW);
  }
}

void updateSerial() {
  delay(500);
  while (Serial.available()) {
    mySerial.write(Serial.read()); // Forward what Serial received to Software Serial Port
  }
  while (mySerial.available()) {
    Serial.write(mySerial.read()); // Forward what Software Serial received to Serial Port
  }
}

This code initializes the Arduino UNO to interface with the HC-SR04 Ultrasonic Sensors, GPS NEO 6M, and GSM SIM900. It measures distance using the ultrasonic sensors and sends an alert via GSM if the distance exceeds a certain threshold.