Arduino Leonardo Soldier Tracking System with GPS, GSM, and Environmental Sensors
View and Edit Project In Cirkit Designer
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
- Description: GSM/GPRS module for cellular communication.
- Pins: GND, DB9-3 (RXD), DB9-2 (TXD), 5V, 3VR, 5VR, 3VT, 5VT, VCC, Ring, RESTART, RESET, STATUS.
LCD Display 16x2
- Description: A 16x2 character LCD display for user interface.
- Pins: LEDK, LEDA, DB7, DB6, DB5, DB4, DB3, DB2, DB1, DB0, E, RW, RS, VO, VDD, VSS.
I2C Module
- Description: An interface module to facilitate I2C communication.
- Pins: SCL, SDA, VCC, GND.
Arduino Leonardo (Rev3b)
- Description: A microcontroller board based on the ATmega32u4.
- Pins: D0/RX, D1/TX, D2/SDA, D3 PWM/SCL, D4/A6, D5 PWM, D6 PWM/A7, D7, n.c., IOREF, RESET, 3V3, 5V, GND, VIN, A0, A1, A2, A3, A4, A5, D8/A8, D9 PWM/A9, D10 PWM/A10, D11 PWM, D12/A11, D13 PWM, AREF, SDA, SCL.
Temperature Sensor (LM35)
- Description: An analog temperature sensor.
- Pins: +Vs, Vout, GND.
KY-018 LDR Photo Resistor
- Description: A light-dependent resistor for detecting light levels.
- Pins: Signal, VCC, Ground.
GPS NEO 6M
- Description: A GPS module for location tracking.
- Pins: VCC, RX, TX, GND.
Wiring Details
SIM900A GSM Module
- GND connected to common ground.
- DB9-3 (RXD) connected to Arduino Leonardo D8/A8.
- DB9-2 (TXD) connected to Arduino Leonardo D7.
- VCC connected to 5V power supply.
LCD Display 16x2
- Connected via I2C module.
I2C Module
- SCL connected to Arduino Leonardo SCL.
- SDA connected to Arduino Leonardo SDA.
- VCC connected to 5V power supply.
- GND connected to common ground.
Arduino Leonardo (Rev3b)
- GND connected to common ground.
- D0/RX connected to GPS NEO 6M TX.
- D1/TX connected to GPS NEO 6M RX.
- 5V connected to 5V power supply for various components.
- A0 connected to KY-018 LDR Photo Resistor Signal.
- A1 connected to Temperature Sensor (LM35) Vout.
Temperature Sensor (LM35)
- +Vs connected to 5V power supply.
- Vout connected to Arduino Leonardo A1.
- GND connected to common ground.
KY-018 LDR Photo Resistor
- Signal connected to Arduino Leonardo A0.
- VCC connected to 5V power supply.
- Ground connected to common ground.
GPS NEO 6M
- VCC connected to 5V power supply.
- RX connected to Arduino Leonardo D1/TX.
- TX connected to Arduino Leonardo D0/RX.
- GND connected to common ground.
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