connect@howdiyworld.com
|

Personal Tracking

What is Needed?

GPS Module
GSM Module
Sim Card
Jumpers
HowDIY

BLOCK DIAGRAM

Procedure

  1. GSM & GPS Module
  2. Connection
  3. Program
  4. Output

Procedure

GSM Module

A GSM module or a GPRS module is a chip or circuit that will be used to establish communication between a mobile device or a computing machine and a GSM or GPRS system.

GPS Module

GPS is a system of 30+ navigation satellites circling Earth. We know where they are because they constantly send out signals. A GPS receiver in your phone listens for these signals. Once the receiver calculates its distance from four or more GPS satellites, it can figure out where you are.

Connections

  • Connect GPS’s Tx (Transmitter) to 10th pin
  • Connect GPS’s Ground (GND) to 9th pin
  • Connect GPS’s VCC to 4th
  • Connect GSM’s Rx to 8th pin
  • Connect GSM’s Ground (GND) to 6th pin
  • Connect GSM’s VCC to 2nd

Program

import serial               #import serial pacakge

from time import sleep

import webbrowser           #import package for opening link in browser

import sys

import RPi.GPIO as GPIO     #import system package

GPIO.setmode(GPIO.BOARD)

GPIO.setwarnings(False)

GPIO.setup(11,GPIO.IN,pull_up_down=GPIO.PUD_UP)

 

def GPS_Info():

    global NMEA_buff

    global lat_in_degrees

    global long_in_degrees

    global nmea_latitude

    global nmea_longitude

    nmea_time = []

    nmea_latitude = []

    nmea_longitude = []

    nmea_time = NMEA_buff[0]                    #extract time from GPGGA string

    nmea_latitude = NMEA_buff[1]                #extract latitude from GPGGA string

    nmea_longitude = NMEA_buff[3]               #extract longitude from GPGGA string

   

    print(“NMEA Time: “, nmea_time,’n’)

    print (“NMEA Latitude:", nmea_latitude,"NMEA Longitude:", nmea_longitude,’n’)

   

    lat = float(nmea_latitude)                  #convert string into float for calculation

    longi = float(nmea_longitude)               #convertr string into float for calculation

   

    lat_in_degrees = convert_to_degrees(lat)    #get latitude in degree decimal format

    long_in_degrees = convert_to_degrees(longi) #get longitude in degree decimal format

def sms_send():

    ser = serial.Serial (“/dev/ttyS0", 9600)

    ser.write(str.encode(‘AT’+’rn’))

    sleep(1)

    ser.write(str.encode(‘AT+CMGF=1’+’rn’))

    sleep(1)

    ser.write(str.encode(‘AT+CMGS="Your_mobile_number"‘+’rn’))

    sleep(1)

   # port.write(lat_in_degrees)

    #port.write(long_in_degrees)

    ser.write(str.encode(nmea_latitude +’rn’))

    ser.write(str.encode(nmea_longitude+’rn’))

    ser.write(str.encode(’emergency’+’rn’))

    sleep(1)

    ser.write(str.encode(“x1A"))

    sleep(1)

#convert raw NMEA string into degree decimal format  

def convert_to_degrees(raw_value):

    decimal_value = raw_value/100.00

    degrees = int(decimal_value)

    mm_mmmm = (decimal_value – int(decimal_value))/0.6

    position = degrees + mm_mmmm

    position = “%.4f" %(position)

    return position

   

 

 

gpgga_info = “$GPGGA,"

ser = serial.Serial (“/dev/ttyS0")              #Open port with baud rate

GPGGA_buffer = 0

NMEA_buff = 0

lat_in_degrees = 0

long_in_degrees = 0

 

try:

    while True:

        received_data = (str)(ser.readline())                   #read NMEA string received

        GPGGA_data_available = received_data.find(gpgga_info)

        input=GPIO.input(11)                           #check for NMEA GPGGA string                

        if (GPGGA_data_available>0):

            GPGGA_buffer = received_data.split(“$GPGGA,",1)[1]  #store data coming after “$GPGGA," string

            NMEA_buff = (GPGGA_buffer.split(‘,’))               #store comma separated data in buffer

            GPS_Info()                                          #get time, latitude, longitude

 

            print(“lat in degrees:", lat_in_degrees," long in degree: “, long_in_degrees, ‘n’)

            map_link = ‘http://maps.google.com/?q=’ + lat_in_degrees + ‘,’ + long_in_degrees    #create link to plot location on Google map

            print(“<<<<<<<>>>>>n")               #press ctrl+c to plot on map and exit

            print(“————————————————————n")

        if input==True:

            sms_send()           

except KeyboardInterrupt:

    webbrowser.open(map_link)        #open current position information in google map

    sys.exit(0)

Output

Now in this screen you can get the gps location (latitude and longitude) and if you press the button it will send your location through SMS

Social media & sharing icons powered by UltimatelySocial
Facebook
Twitter
YouTube
LinkedIn
Instagram