Skip to content

A touch sensor-based location tracker built using BOLT API and a node/express backend. Demo: https://youtu.be/dWXDC8owJAk

Notifications You must be signed in to change notification settings

rishabhAjay/bolt-iot-location-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bolt-iot-location-tracker

STORY

Imagine how convenient it would be to have a device that sends in your location to your family/loved ones on the fly. The instances where such a device comes handy is vast. The project simply sends in your location as an SMS to the number you have inputted.

Things used in this project

Hardware components

  1. Bolt IoT module
  2. TTP223 touch sensor
  3. Connecting wires
  4. Breadboard(to hold the sensor in place)

Software tools and services

  1. VS Code(IDE): https://code.visualstudio.com/download
  2. Node JS(Back-end runtime environment): https://nodejs.org/en/download/
  3. Bolt API: https://docs.boltiot.com/docs/api-request-syntax
  4. Twilio(SMS service): https://www.twilio.com/login
  5. Bootstrap(CSS framework): https://getbootstrap.com/docs/5.0/getting-started/introduction/

Hardware setup

When you have your touch sensor facing in this manner, the holes from left to right are VCC, I/O and GND respectively(The pin specifications are mentioned at the back of the sensor too).

  • Connect the VCC hole of the sensor to the 5V pin of the Bolt IoT module.
  • Connect the I/O hole of the sensor to digital pin 1 of the module.
  • Finally, Connect the GND hole to the GND pin of the module and Voila! The hardware part of the project is ready.

Software setup

STEP 1: To install Node JS and VS code on your Windows system, you can follow this video: Node js setup


STEP 2: If you have not worked with Node JS or Express before, I would suggest going through this tutorial to help you set your project up:

Additionally, you may look for other sources of information to deepen your understanding on them.


STEP 3: Here is a list of npm packages you should download in the project directory through your terminal with the command:

npm install "package-name" (no double quotes)


STEP 4: Create two new directories(views and public) in the main project directory. The views folder contains all the files with .ejs extension and the public folder consists of the static files.(NOTE: do not change the names of these directories)

  • The views folder contains index.ejs and home.ejs
  • The public folder contains styles.css

In the directory tree above,

  • Tracker2 is the name of the project directory
  • index.js is the main JavaScript file that houses the back-end code
  • .env is used to store environment variables
  • package.json file, package-lock.json file and node_modules directory are automatically created when you initialize the project and install the npm packages

STEP 5: In the .env file, replace the placeholders with your data. To get your Bolt Device ID and API key, have a look at the images below:

Click 'API' on the left and copy the key
Click on 'Devices' and copy the ID

To get the SID and AUTH token from Twilio, login to your Twilio account and follow the image below:

Copy your SID and token from the dashboard. Also save the phone number as you will be needing it later.

Now, replace the values obtained above to these placeholders in the .env file. Code:

//.env file

TWILIO_ACCOUNT_SID=Your Twilio SID
TWILIO_AUTH_TOKEN=Your Twilio auth token
DEVICE_ID=Your Bolt Device's ID
DEVICE_API=Your Bolt API key
//Make sure you don't have spaces in between and no quotes

STEP 6: The index.js file(entry point of the node JS application) has the following code:

Similarly, the code for index.ejs, home.ejs and styles.css is given below:

//styles.css 
.mainBody {
    display: flex;
    flex-direction: column;
    align-items: center;
}

To start your server locally, use node index.js in your terminal and head over to http://localhost:3000 on a web browser(preferably Chrome)

Interface guide

  • When you go to the http://localhost:3000, you get the page to check whether your device is online or not.
  • If your Bolt device is offline, a message pops up.
Device offline

  • If it is online, you are redirected to a new page which asks you for the Twilio phone number and your number. You will be required to fill in all the details and check the radio button. The phone numbers should start with +17 and +91 respectively.
  • After you are done entering the details, you will be redirected to a new page which MUST BE KEPT ACTIVE until you want the instance to end by clicking the "off" button. You must not QUIT, GO BACK or RELOAD the page. Since a cron job is running for the particular instance, it must be terminated by clicking the "off" button. You should keep the browser idle on this page until you want to switch the tracker off.
  • If in case you forgot to terminate the cron job or have multiple cron jobs running, you have to quit your local server(CTRL + C) and start over.
SWITCHING the tracker OFF after use is mandatory
  • You will be redirected to the first page after clicking the "off" button

Points to remember

- Make sure you don't click the BACK, QUIT or RELOAD buttons on your browser after starting the instance. You may end up creating multiple such instances which will cause a mess.

- Always SWITCH the tracker OFF and then quit the browser so that no instance is left hanging.

- If you wish to keep sending your location via the SMS and keep the sensor active, keep the browser IDLE after you initiate the instance(i.e. on the page that lets you switch OFF the tracker).

- The project utilizes JavaScript's built-in geolocation services so this project does not require a GPS module.

Demo of the project

To deploy your web application, you can use heroku or any other deploying service. You can follow this documentation to deploy your website on heroku: https://devcenter.heroku.com/articles/getting-started-with-nodejs

Conclusion

In this project, we integrated a node.js web application with Bolt API(source: https://forum.boltiot.com/t/support-for-node-js/17092/2?u=rishabhajay24) and built a prototype which sends your location to your friends/family with just a touch via a web application interface.

Any suggestions or improvements to the web application are welcome.

About

A touch sensor-based location tracker built using BOLT API and a node/express backend. Demo: https://youtu.be/dWXDC8owJAk

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published