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

Arduino Leonardo Soldier Tracking System with GPS, GSM, and Environmental Sensors

View and Edit Project In Cirkit DesignerImage of Arduino Leonardo Soldier Tracking System with GPS, GSM, and Environmental Sensors

Circuit Documentation

Summary

This circuit is designed to track a soldier's location and vital signs, and communicate this information via SMS. It includes a GPS module for location tracking, a temperature sensor for monitoring the environment or body temperature, an LDR photoresistor for detecting light levels which could be used as a proxy for heartbeat or other cyclic changes, an LCD display for user interface, an I2C module to facilitate communication between the LCD and the microcontroller, and a SIM900A GSM module for sending SMS messages. The Arduino Leonardo serves as the central microcontroller to process data and control the flow of information.

Component List

SIM900A GSM Module

LCD Display 16x2

I2C Module

Arduino Leonardo (Rev3b)

Temperature Sensor (LM35)

KY-018 LDR Photo Resistor

GPS NEO 6M

Wiring Details

SIM900A GSM Module

LCD Display 16x2

I2C Module

Arduino Leonardo (Rev3b)

Temperature Sensor (LM35)

KY-018 LDR Photo Resistor

GPS NEO 6M

Documented Code

#include <TinyGPS.h>
#include <SoftwareSerial.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial Gsm(7, 8);
char phone_no[] = "+91XXXXXXXXXX"; //replace with phone no. to get sms

TinyGPS gps;  //Creates a new instance of the TinyGPS object
int state; 
String textMessage; 
const int sensor=A1;
const int ldrPin = A0;// Assigning analog pin A5 to variable 'sensor'

float tempc; //variable to store temperature in degree Celsius
float vout; //temporary variable to hold sensor reading

void setup()
{
  Serial.begin(9600);
  Gsm.begin(9600); 
  delay(2000);

  // AT command to set SIM900 to SMS mode
  Serial.print("AT+CMGF=1\r"); 
  delay(100);
  // Set module to send SMS data to serial out upon receipt 
  Serial.print("AT+CNMI=2,2,0,0,0\r");
  delay(100); 
  pinMode(6,INPUT);
  pinMode(sensor,INPUT);
  pinMode(ldrPin, INPUT);
  lcd.begin();
  lcd.backlight();
  lcd.clear();
  lcd.print("Searching ");
  lcd.setCursor(0,1);
  lcd.print("Network....... "); 
  delay(3000);
}

void loop()
{
  lcd.clear();
  lcd.print("Soldier Tracking");
  lcd.setCursor(0,1);
  lcd.print("System...!!"); 
  delay(100);

  bool newData = false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (Serial.available())
    {
      char c = Serial.read();
      Serial.print(c);
      if (gps.encode(c)) 
        newData = true;  
    }
  }

  // Read temperature sensor
  vout=analogRead(sensor);
  vout=(vout*500)/1023;
  tempc=vout; 

  // Read LDR status
  int ldrStatus = analogRead(ldrPin);

  // Check for incoming SMS
  if(Gsm.available()>0){
    textMessage = Gsm.readString();
    textMessage.toUpperCase();   
    delay(10);
  } 

  // If 'LOCAL' command is received, send back the current location
  if(textMessage.indexOf("LOCAL")>=0){
    sendLocation("Message Recevived", "Getting Location", "Sending location", "To Base....", "location Sent");
  }
  
  // Check for a panic state, if so, send location and alert
  state= digitalRead(6);
  if(state==1)
  {
    sendLocation("Alert I need help....", "Sending location", "To Base....", "location Sent");
  }
  else
  {
    lcd.clear();
    lcd.print("Soldier Tracking");
    lcd.setCursor(0,1);
    lcd.print("System "); 
    delay(10);
  }
}

void sendLocation(String initialMessage, String waitMessage, String sendingMessage, String baseMessage, String sentMessage) {
  lcd.clear();
  lcd.print(initialMessage);
  delay(3000);
  lcd.clear();
  lcd.print(waitMessage);
  lcd.setCursor(0,1);
  lcd.print("Location ");
  delay(3000);
  float flat, flon;
  unsigned long age;
  gps.f_get_position(&flat, &flon, &age);   
  Gsm.print("AT+CMGF=1\r"); 
  delay(400);
  Gsm.print("AT+CMGS=\"");
  Gsm.print(phone_no);
  Gsm.println("\"");   
  lcd.clear();
  lcd.print(sendingMessage);
  lcd.setCursor(0,1);
  lcd.print(baseMessage);
  delay(3000);
  Gsm.println("Asheesh ,Battalion No. 1233456 ");
  Gsm.print("Temperature is  ");
  Gsm.println(tempc);
  Gsm.print("Heartbeat is  ");
  Gsm.println(ldrStatus/10);
  Gsm.print("http://maps.google.com/maps?q=loc:");
  Gsm.print(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
  Serial.print(",");
  Gsm.print(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
  delay(200);
  Gsm.println((char)26); // End AT command with a ^Z, ASCII code 26
  delay(200);
  Gsm.println();
  delay(10000);
  lcd.clear();
  lcd.print(sentMessage);
  delay(3000);
}

Note: The code provided is a simplified version of a soldier tracking system. It includes functions for reading sensor data, parsing GPS data, and sending SMS messages with location and sensor information. The sendLocation function is a helper function to avoid code duplication