Monday, February 26, 2024

Smart GPS Geofencing System

Ashwini Kumar Sinha

- Advertisement -

ashwiniGeofencing is one of the greatest technologies of the 21st century. It has a multitude of applications such as car tracking and parcel location tracking. Here is a more exhaustive list of the applications of Smart GPS Geofencing System-

  • Can be used for livestock and other animals to track their movement
  • Can be used to monitor prisoners or people under house-arrest
  • Can be used for the protection of valuable items
  • Can be used by parents for child monitoring
  • Can be used in rental cars

Geofencing systems are easy to make and have plenty of uses, which is why today we will be making a smart Geosystem. We will be using the SIM800l module and a Buzzer for the Distance Alert and notification system. For geolocation, we will use a NEO 6M Gps module. We will also connect an I2C OLED Display that tells us the distance between the base and the current location. In this device, we will set a base location and a threshold distance.

When the device detects that it is moving beyond the prescribed distance, the buzzer attached to pin 13 will automatically start to alert and at the same time, the Sim800l will send a message to set numbers alerting them of the crossing of the set distance.

- Advertisement -

Let’s start our project by shopping for the following components:

Bill of Materials 

GPS Geofencing System Components

Prerequisites 

Assuming that Arduino IDE is already installed in your system, we have to do some basic setup of the required library. To do so, go to Sketch menu–>click the manage library option –>in Library manager window search the library (“Adafruit FONA”, ”NMEA GPS” and “SSD1306 ASCII”) one by one and install them.

Now after the installation of the library, we can proceed to the coding part.

Smart GPS Geofencing System – Code 

In the first part of the code we need to initialize the required library (“Adafruit FONA”, ”NMEA GPS” and “SSD1306 ASCII” ) then we have to define the pin numbers for Serial Communication with SIM800l Module. After that, we will set up the base location from where we want to start the geo-fencing, or, you can say, the center point of Geofencing. (Refer Fig 1, 2).

Smart GPS Geofencing System Arduino Code
Fig 1
Geofencing System Code
Fig 2

Next, we will create a setup function where we have set the baud rate for the sim800l Module to 4800 which is the default baud rate of our GSM Module. Next, we will set the baud rate for GPS Module as 9600. Here, we have used the hardware serial port of Arduino for both serial debugging and for communication with the GPS module. Next, we will set the OLED Display and initialize communication with the OLED Display.

Code for Smart GPS Geofencing System
Fig 3.

Next, we will create a loop function that runs repeatedly and checks the GPS Location, and updates the location on OLED DIsplay. In the same loop, we have created an If condition where we have set the threshold distance or, you can say, the max distance up to which one can be allowed to travel from the base location. If anyone crosses this distance, the device sends an alert and also sends a message to set numbers informing them of the geofencing break.

Smart GPS Geofencing System Code
Fig 4

Now, after completing the code, select the Right Port and Board of Arduino and upload it to the Arduino board. After the successful upload of code connect all the components as shown in Circuit Diagram in Fig 5.

Smart GPS Geofencing System – Circuit Diagram

Circuit Diagram of GPS Geofencing System
Fig 5. Connection diagram created in Fritzing

Testing

Now after connecting all the components, cross-check the connection and then power the Arduino board with a 5-10 V battery and wait a few minutes. This allows the GPS Module to search the satellite and calculate the location of the device. When the GPS Module gets the location and establishes the connection with the satellite, the red light on the board will start to blink.

Now insert a 2G sim in the SIM800l module and wait for a few minutes so that the module registers to the network. Now the display starts showing you the distance away from the base location and when you go too far from the base location and cross the threshold distance, the device will automatically alert you and send the message to the phone.

Smart GPS Geofencing System

Download Source Code

31 COMMENTS

  1. what do you mean by :
    #error You must uncomment at least one of NMEAGPS_PARSE_RMC, NMEAGPS_PARSE_GGA or NMEAGPS_PARSE_GLL in NMEAGPS_cfg.h!

    #error You must uncomment GPS_FIX_LOCATION in GPSfix_cfg.h!

    it is giving me errors in these lines and there is nothing to uncomment in the code ??

    • I have tested and compiled the code it compiled without warning or error . I have checked the code and its working fine . However what you have shared is warning the code will compile and work check

SHARE YOUR THOUGHTS & COMMENTS

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Calculators