Cars are slowly becoming a necessity now owing to the pandemic situation prevalent all over the world. It becomes quite important for the owner of an automobile to be able to protect their cars from theft. Some people simply do not have a garage to keep their cars in. Others need a security solution for times when they park their car in unknown spots. These problems demand a solution to be able to track down their car in real-time if the car gets stolen.
This project is developed to provide the user a solution to track their vehicle in real-time if someone tries to break into the vehicle and steal it. The system sends alerts to the owner of the vehicle on Telegram, providing the GPS coordinates of the car on a Google Map link, every 10 seconds. Apart from this, a buzzer also rings to alert the people near the car that the vehicle is being stolen.
So, let’s take a detailed look into the system.
Hardware SetupTo create an automobile anti-theft system, we need to go through the following steps to make proper connections for the system.
Step 1: On the breadboard, connect one column at the very end of the breadboard to the 3.3V supply from the Arduino. The next column on this side is connected to the 5V supply from the Arduino.
Step 2: On the column of points at the other end of the breadboard, connect it to the GND from the Arduino.
Step 3: Connect the positive terminal of a Blue LED with a 330-ohm resistor on the breadboard. From the other leg of the resistor, connect a wire to the pin D5 of the Arduino. The negative leg of the LED is connected to the GND supply on the breadboard.
Step 4: A buzzer is placed on the breadboard with its negative leg connected to the GND supply of the breadboard and its positive leg to the pin D4 of the Arduino.
Step 5: An LM393 LDR module is placed on the breadboard. It’s Vcc and GND terminals are connected to the 3.3V and GND supplies on the breadboard respectively. The A0 pin from the LDR module is connected to the A0 pin of the Arduino.
Step 6: A laser module is placed on the breadboard in such a way so that the laser faces the photoresistor of the LDR module. The negative terminal is grounded from the GND supply of the breadboard. The Signal pin of the laser module is connected to the 5V supply on the breadboard.
Step 7: D0 pin of the Bolt WiFi module is connected to the D2 pin of the Arduino. This will be used to signal the system whether the user has enabled or disabled the system.
Step 8: The Tx pin of the Bolt WiFi module connects to the D0 pin of the Arduino and the Rx pin of the Bolt WiFi module connects to the D1 pin of the Arduino.
Step 9: The Vcc and GND connections on the GPS module are connected to the 3.3V and GND pins on the Bolt WiFi module. The Tx pin of the GPS module connects to pin D7 of the Arduino and the Rx pin of the GPS module connects to pin D8 of the Arduino.
Step 10: The Bolt WiFi module and the Arduino UNO are connected to the power supply using a mini USB and Type B USB cable respectively.
The entire circuit is shown below:
Telegram Channel Creation:
- We need to create a channel on Telegram first. A channel on Telegram is analogous to a Group in Whatsapp. We will receive all the notifications from the system on this channel.
- On your mobile phone, open the Telegram app. Click on the pencil-shaped icon on the bottom right of the app screen. The New Message screen comes up. On this screen, click on ‘New Channel’.
- On the ‘New Channel’ screen, type a name for the channel. There is also an option to upload an image as an icon for the Channel. Type in a suitable description regarding what purpose the channel serves. Then, click on the ‘tick’ mark on the top right corner of the screen.
- The ‘Channel Settings’ screen comes up. On this screen, set the channel to ‘Public channel’. Type a permanent link that acts as the public link for the channel. There shouldn’t be any space in the link name for the bot. Click on the ‘tick’ mark on the top right corner of this screen.
- The ‘Add Subscribers’ screen appears. Do not add any subscribers. simply click on the arrow icon on the bottom right of this screen.
- The channel has now been created.
Telegram Bot Creation:
- On the main screen of the Telegram app, click on the search icon on the top right corner of the screen.
- Search for ‘BotFather’ and wait for the search results to appear. From the list of search results click the BotFather with a blue tick beside it.
- The BotFather chat screen now appears. The BotFather is like the master which can be used to create new bots. Bots will help in sending notifications to the Channel created by us in the previous block. On this BotFather screen, type ‘/start’ and click on send.
- This brings up a list of commands which can be used to control the BotFather. Next, type ‘/newbot’ and click on send.
- BotFather asks for a bot name that will be used to refer to the new bot being created by us. Enter a suitable name for the bot and click on send.
- BotFather asks for a username for the bot. The username should be such that it must include the word ‘bot’ at the end. Enter a username of your liking and click on send.
- If the username is taken by someone else, the same will be shown on this chat screen. This requires the user to select some other username followed by a click on the send button.
- On successful creation of the bot, BotFather will come up with a message stating that the new bot has been created successfully. This message will also provide a link for the bot and an HTTP API token for the bot which have to be saved for later use.
On creation of the bot, this bot has to be added as an Admin to your Channel. This is done as follows:
- On the main screen of Telegram app, click on the name of the Channel just created. This opens up the chat screen for the channel.
- On this screen, click on the name of the channel at the top of the screen. This shows several kinds of information about the channel. From the ‘Members’ tab, click on ‘Subscribers’.
- On the ‘Subscribers’ screen, the name of the user can be seen. Apart from this, there is an ‘Add Subscriber’ button. Click on it.
- From the ‘Add Subscribers’ screen, search for the username of the bot just created. From the search results click on the appropriate one. A message pops up saying that bots can only be added as administrators. On this message, click on ‘MAKE ADMIN’.
- From the next screen which is the ‘Admin Rights’ screen, check the option ‘Post Messages’ if it is not already checked, and then click on the ‘tick’ icon on the top right corner of the screen. Thus, the bot has been successfully added as an Admin to your Channel.
For a bot to send notifications to a channel, you need to make an HTTP request to the bot via a program. This program needs to be present on the cloud of the Bolt module. This is done using Ubuntu Server on Oracle VM Virtual Box.
Step 1: Power up the Ubuntu Server on Virtual Box. Create a directory for the new project. The directory is created as follows-
sudo mkdir test
Step 2: Change to the newly created directory by using the cd command-
cd test
Step 3: Create a configuration file that will contain all the data necessary for communicating with the bolt module as well as the Telegram bot. This is done inside a python file using the following command-
nano carconf.py
‘.py’ resembles a python file. ‘nano’ command opens up a file editor. In this file, type the following lines-
bolt_api_key=”xxxxxxxxxx” //Enter your API key for Bolt module heredevice_id=”BOLTXXXXXXX” //The unique ID for your Bolt moduletelegram_chat_id=”@XXXX” //Channel permanent link for your channeltelegram_bot_id=”botXXXXXXXXXXXX” //Bot HTTP API token for accessing the bot via HTTP requestsmapurl=”http://maps.google.com/maps?q=” //Part of the google maps link to be sent as notification on the Telegram Channel
Save the file by pressing ‘Ctrl+X’, followed by ‘Y’ and ‘Enter’.
The file looks something like this:
Step 4: The main code for the cloud has to be created now. This part of the code will scan for any string being sent from the Arduino to the Bolt module via serial port (RX, TX). If it receives any string, it passes the string through a set of validation checks. On passing the validation check, the string is considered to be either the Latitude or the Longitude of a location. The Latitude and Longitude are sent from the Arduino to the Bolt module at a gap of 1 second. So, every string received at odd intervals is the Latitude and every string received at even intervals is the Longitude. On receiving the Latitude and Longitude values, the program sends an HTTP request to your telegram bot with an appropriate message and a google maps link to track the vehicle using the received pair of latitude and longitude values. To open the code editor for the main code file, type the following in the shell-
nano gps.py
Once the code editor opens up, type the following-
Step 5: Press ‘Ctrl+X’, followed by ‘Y’ and ‘Enter’, to save the file.
Thus, the cloud side of the Bolt module has been successfully programmed.
Programming the User Interface of the Bolt Device page for Mobile phoneThe next step is to program the User side of the Anti-theft system. The user side of the anti-theft system looks something like this-
The screen shows two buttons, ‘Enable’ and ‘Disable’. These buttons are used to enable or disable respectively, the anti-theft system, according to the choice of the user.
Step 1: In order to create such a page, go to the Bolt Cloud page using the following link and login using your credentials-
https://cloud.boltiot.com/
Step 2: The cloud page for Bolt ‘Devices’ appears. This page shows the ID of your Bolt module along with its availability. Click on ‘Products’ from the left-hand side menu on this screen.
Step 3: The products page appears. On this page, click on ‘Add Product’ followed by ‘Create New Product’. The ‘Build Product’ page will appear. This looks something like this-
Step 4: On this page, give a suitable name to the product, select ‘Output devices’ as its type, and set the data collection method to ‘GPIO’. Optionally, a picture of the device can also be uploaded. Finally, click on ‘Done’.
The product page for this system looks something like this-
Step 5: Select the newly created product from the left-hand side list of products and click on the configure icon on the top right side of this page. The icon looks something like the one marked red in the following image-
This will open up the ‘Products: Setup’ page for this product, like the one shown below.
Step 6: On this page, select ‘Hardware’ from the horizontal top menu and mark the radio button beside ‘0’ in the hardware layout for the Bolt module. On the right-hand side of this page, name the ‘0 Digital’ pin as ‘enable’. Then press ‘Ctrl+S’ or click on the Save icon on the top right corner of this page to save the details.
Step 7: Next, select ‘Code’ from the top horizontal menu. This will open up the coding page for this product. Type in a name for the file and select Javascript or ‘.js’ as the extension. Type the following code into the coding window-
singleButton({name:”Enable”, action:”digitalWrite”, pin:”0″, value:”LOW”});singleButton({name:”Disable”, action:”digitalWrite”, pin:”0″, value:”HIGH”});
The page will look like this-
Finally, click on the Save icon from the top right corner of this page and the ‘Close’ icon to close the setup page.
Step 8: On the ‘Products’ page, select the newly created product from the left-hand side list of products, and from the top right corner of this page, click on the ‘Link device to this product’ icon which looks something like the red marked icon in the following image-
This will come up with a page to select the device with which the product is to be linked. The page will show the name of your bolt device.
Step 9: Click on the name of your Bolt device and finally click on ‘Done’.
Thus, the product page for the mobile phone has been successfully created. In order to view the page from the phone, open the Bolt app from the phone, click on the name of your Bolt device and the page appears which contains the ‘Enable’ and ‘Disable’ buttons.
Programming the ArduinoThe next and final task which remains is to program the Arduino. Make the necessary circuit connections as described in the ‘Hardware Setup’ section. Open up the Arduino IDE and type the following code in the code editor-
Two header files, namely, ‘BoltDeviceCredentials.h’ and ‘BoltIoT-Arduino-Helper.h’ have been used. These two files can be downloaded from the following link-
https://github.com/Inventrom/boltiot-arduino-helper/tree/master/src
‘BoltDeviceCredentials.h’ was edited to include the Device ID and API key for the necessary Bolt device. The library was renamed to ‘BoltDevCredentials.h’.
The ‘BoltIoT-Arduino-Helper.h’ library was edited to change all instances of the SoftwareSerial library to NeoSWSerial. SoftwareSerial clashes with the NeoSWSerial library in the main code. So, instances of the SoftwareSerial have to be replaced with NeoSWSerial. The header file is then renamed to ‘BoltIoT-Renew-Helper.h’.
Apart from these two libraries, the ‘NMEAGPS.h’ library, the ‘string.h’ library, and the ‘NeoSWSerial.h’ library has also been used.
Working and DemonstrationIt can be seen that the hardware setup has an LED. This LED is the status LED which depicts whether the system is enabled or disabled. The system can be enabled or disabled using the Bolt app page from the mobile. The laser module and the LDR module are placed in such a way so that they face each other. In real-life situations, the LDR module is fit inside the door of the car and the Laser module is fit inside the body of the car, the two modules facing each other.
It can be easily made out that when the door of the car opens, the LDR module moves with the door. The Laser module continuously emits a stream of Laser light which falls on the LDR module.
When the system is in a disabled state, moving the LDR module by opening the door doesn’t have any effect. Once, the system is enabled by pressing the ‘Enable’ button on the Bolt mobile page, the status LED glows, showing that the system is in an enabled state. In this state, if someone tries to break into the car by opening the door, the LDR module moves with the door. This results in a fall in the amount of light falling on the LDR module. This action triggers a buzzer as an alarm that can alert people nearby that the car is being stolen. Along with this, the GPS module attached with the hardware sends the coordinates of the location of the car to the Bolt module every 10 seconds. The bolt module in turn calls an API to send a Telegram alert to the Telegram account of the owner of the car. The Telegram message states that the car is being stolen and contains a Google Maps link to track the car along with the message. So, every 10 seconds, the live location of the car can be tracked. The telegram message looks something like this-
This entire system can again be disabled by pressing the ‘Disable’ button on the Bolt mobile page.
The video demonstration of the system is shown as follows-
ConclusionLast year my family purchased a car. It was a happy moment for all of us. But we had something to worry about too. We did not have any garage and the car had to be kept on the road all the time. At night time, the streets would become really empty and each of us would be worried about the safety of the car. Moreover, there had been multiple reports of car theft from nearby areas. This would keep us up all night. If there could be a way where we would not have to get up and check on the car all night, that would be an excellent solution to our problem. This is a problem faced by many people all over the globe who do not have a garage but possess a vehicle.
Traditional car alert systems work on vibration detection to alert the people nearby. These systems tend to create false alarms. Moreover, once the car is stolen, there is no way of tracking it. This ‘Automobile Anti-Theft System based on the Bolt IoT platform’ solves the problem for us. The system provides an alarm for passers-by once a theft is attempted on the car. This also eliminates the problem of false alarms. Also, once the car is stolen, there is a way to know its location so that the vehicle can be easily recovered. This can be a potentially good solution to the worries of people who possess a vehicle but not a garage. So, they can safely sleep at night without worrying about the safety of their vehicle.
Comments