Saturday, April 1, 2023

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 geofencing

  • 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 geo-location we will use a NEO 6M Gps module. We will also connect a I2C OLED Display that tells us the distance between the base and 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.

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

Bill Of Materials 

- Advertisement -


Assuming that Arduino IDE is already installed in your system, we have to do some basic setup of 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 installation of library we can proceed to the coding part.


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 SIM 800l Module. After that, we will setup 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).

Fig 1
Fig 2

Next we will create a setup function where we have set the baud rate for sim800l Module to 4800 that 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 debug and for communication with GPS module. Next we will set the OLED Display and initialise communication with the OLED Display.

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 upto which one can be allowed to travel from the base location. If any one crosses this distance, the device sends an alert and also sends a message to set numbers informing them of the geofencing break.

Fig 4

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


Fig 5. Connection diagram created in Fritzing


Now after connecting all the components, cross check the connection and then power the arduino board with 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 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 .

Download Source Code


  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



What's New @

Truly Innovative Tech

MOst Popular Videos

Electronics Components

Tech Contests