Geofencing 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
Prerequisites
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.
Coding
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).


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.

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.

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.
Connection

Testing
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 .
Good day! Where is the full code for this project. Thank you and more power
Can you share your email address??
please provide full code
Full code attached end of article
Can I use Arduino Uno for this project? How will the Arduino send an alert to the phone? Is the sim connected?
yes can use Arduino
Hi, the code link provided at the end is not working..
Can you please help?
Hi Raghav, we have shared the source code via email.
Plz provide me code of it .
Thank you ?
Source code share via email
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 ??
Hi, detailed explanation. Please, can i get the complete code?
email: [email protected]
Hii…can i please get the full code?
Hi, we have shared the source code on your email address.
Please share the source code to this mail.
[email protected]
Thank you
We have emailed you the source code.
Can you share the full code please
The Source code is present at the end of the article.
Can you please share the source code as i am not able to find it here
email id: [email protected]
Source code is present at the end of the article.
please send me full code at [email protected]
Hi Lokesh, we have shared the Source Code on your email id.
Can you send this full code on my gmail
[email protected]
The Source code is present at the end of the article.
hello,
finalsimple.ino:78:59: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
I don’t understand the error can you fix it.
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
can u share the code please
The Source code is present at the end of the article.
Source code attached at end of article
Please share the whole working source code to my mail
[email protected]
Thanks in advance for this project idea really interesting and helpful
The source code is present at the end of the article.