Foot-Fall counter with the Bolt Cloud PRO

Planning for a big event in the near future?

Want to keep track of how many people come to your event, so you can brag about how good your event was?

Don't have the man power to keep track?

Yes word in 3D isolated over a white background

If the answer to the all the the questions above, is yes the Bolt Cloud PRO is here to rescue you.

 

Things that you will need:

Business man pointing the text Checklist

 

  1. A Bolt WiFi module.
  2. Proximity sensor.
  3. Connecting berge pin cables.
  4. micro USB cable.
  5. Standard USB wall charger.
  6. A computer with Internet access or a droplet on Digital Ocean.
  7. Bolt Cloud account with Bolt Cloud PRO. (Click here to upgrade to Bolt Cloud PRO).

If you have all of the above, let's get started.

Hardware Connections:

Refer to the following diagram for the circuit connection.

Screenshot 2019-08-20 at 2.56.24 PM

  • Connect the output pin of the sensor to pin 0 of the Bolt WiFi module.
  • Connect the GND pin of the sensor to GND pin of the Bolt WiFi module.
  • Connect the VCC pin of the sensor to the 5V pin of the Bolt WiFi module.

Use the wall charger and micro USB cable to power up the Bolt WiFi module, and your circuit connections are ready.

Hardware Setup:

Well there is hardware connections and then there is hardware setup. The difference is sooo subtle, you may miss it and never realise. While you have connected the all the hardware required, if you don't place it correctly.

Spoilers: We have done quite a few of these steps in earlier blogs, so I will be adding links to the Cloud documentation for most of them. This is for the benefit of the people who are not familiar with the Bolt Cloud.

 

  • To get a good reading place the sensor right outside the entry door, in a manner where it will be able to detect a person moving through the door. You can test out whether the sensor detects a person entering the venue by going through the door yourself, and checking if the sensor lights up.

giphy

  • Next you have to setup the Bolt WiFi module to connect to the Cloud. You can look up the steps by clicking here.
  • Create a new product on the Bolt Cloud as a GPIO input type of product. You can look up the steps by clicking here.
  • Configure the new products hardware section to monitor the GPIO 0 pin of the Bolt WiFi module. Remember to select 'TRIGGER' as the data collection rate. You can look up the steps for configuring the hardware, by clicking here
  • Link your device to the newly created product, and hit the deploy configurations button. You can look up the steps by clicking here.

And you are done with the hardware configurations!!!

Software Setup:

System setup:

For the software setup, you will need a linux computer with an internet connection, and the capability to run python codes. You could also setup a Digital Ocean droplet to run your python code. A quick Google search will give you lots of resources on how to setup such a system.

Next via a terminal run the following commands.

sudo apt-get install cron
sudo apt-get install python3.6
pip install boltiot

With this you have all the software you require to run your code.

Twilio setup:

To get SMS notifications regarding the footfall, you will need to setup your twilio account. You can look up the steps by clicking here.

You will need to get details such as 'SID', 'AUTH_TOKEN', 'FROM_NUMBER' from your twilio console. These details will be required in the code.

Code:

giphy


On your computer system, create a new file named 'footfall.py' and put the following code inside of it.


from boltiot import Sms
import requests
import json, datetime

SID = 'You can find SID in your Twilio Dashboard'
AUTH_TOKEN = 'You can find on your Twilio Dashboard'
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device'

sms = Sms(SID, AUTH_TOKEN, TO_NUMBER, FROM_NUMBER)

print("Pulling data from the Bolt Cloud.")
response=requests.get("https://cloud.boltiot.com/remote/%s/fetchData?deviceName=%s" % (API_KEY, DEVICE_ID))
response_data = json.loads(response.text)
data = response_data["data"]
count = 0
today = str(datetime.date.today())

print("Going through the data.")
for count_entry in data:
    if not str(count_entry[0]).startswith(today):
        continue
    if count_entry[1] != "1":
        continue
    count = count + 1

print("Today's footfall is %s." % str(count))
print("Sending update via SMS.")
sms.send_sms("The footfall for today is %s." % str(count))
print("All done.")

Replace the entries in the code for 'SID', 'AUTH_TOKEN', 'FROM_NUMBER' and 'TO_NUMBER' from the details that you get on your Twilio console.

Replace the entries such as the API_KEY and DEVICE_ID, from the Bolt Cloud dashboard.

Use the following command to test run the code

python footfall.py

And you have a working code, that can give you updated about how many people came to your venue today.
 
The only thing left is to setup a cronjob to run this code everyday at 23:55 pm. You can do that by running the following command.
 
{ crontab -l; echo "55 23 * * * /usr/bin/python $(pwd)/footfall.py"; } | crontab -

And that's all folks!!

You will get a message every night at 11:55 pm, telling you exactly how many people entered your event!

giphy

 

 

footfall events

There are no related posts