rani venigalla
Published © GPL3+

Crowd Detection Alert System

It detects the no of people entering a mall and if the value exceeds the threshold, then concerned staff is alerted to stop corona virus.

IntermediateFull instructions provided20 hours357
Crowd Detection Alert System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Buzzer
Buzzer
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
SMS Messaging API
Twilio SMS Messaging API
mailgun

Story

Read more

Schematics

circuit

Code

Crowd detection Alarm system

Python
import conf,email_conf
from boltiot import Email,Sms,Bolt
import json,time
#conf,email_conf contains keys required
threshold=#no of max people in mall

mybolt=Bolt(conf.API_KEY,conf.DEVICE_ID)
sms=Sms(conf.SID,conf.AUTH_TOKEN,conf.TO_NUMBER,conf.FROM_NUMBER)
mailer=Email(email_conf.MAILGUN_API_KEY,email_conf.SANDBOX_URL,email_conf.SENDER_EMAIL,email_conf.RECEPIENT_EMAIL)
count=0#no of people in mall or public place
while True:
    print("Reading sensor Value:")
    response=mybolt.digitalRead("0")
    data=json.loads(response)
    print("Sensor value is:"+str(data['value']))
    try:
        sensor_value=int(data['value'])
        if sensor_value==1:
            print("Person entered")
            count=count+1
            print("No of persons in mall at present:"+str(count))
            mybolt.digitalWrite('2','HIGH')
        else:
            print("No one entered")
            mybolt.digitalWrite('2','LOW')
        if count>threshold:
            mybolt.digitalWrite('1','HIGH')
            mybolt.digitalWrite('2','HIGH')
            print("Making request to Twillio to send sms")
            response1=sms.send_sms("The no of people in the mall has reached the threshold:"+str(threshold))
            print("Making request to Mailgun to send Email")
            response2=mailer.send_email("Crowd Increased","The no of people in the mall has reached the threshold:"+str(threshold))
    except Exception as e:
        print("error occured:",e)
    if count>threshold:
        break
    mybolt.digitalWrite('2','LOW')
    time.sleep(10)
print("Crowd has to be reduced!!")
mybolt.digitalWrite('1','LOW')
mybolt.digitalWrite('2','LOW')
            

conf.py

Python
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' 

email_conf.py

Python
MAILGUN_API_KEY = 'This is the private API key which you can find on your Mailgun Dashboard' 
SANDBOX_URL= 'You can find this on your Mailgun Dashboard' 
SENDER_EMAIL = 'test@' + SANDBOX_URL  # No need to modify this. The sandbox URL is of the format test@YOUR_SANDBOX_URL
RECIPIENT_EMAIL = 'Enter your Email ID Here'
API_KEY = 'This is your Bolt Cloud account API key'
DEVICE_ID = 'This is the ID of your Bolt device

Credits

rani venigalla
1 project • 0 followers

Comments