Tunir Das
Published

Automation to Prevent Spread of COVID-19 using Bolt IoT

Complete Automation for Home/Office using Bolt IoT to restrict spreading of COVID-19.

IntermediateFull instructions provided3 hours1,934
Automation to Prevent Spread of COVID-19 using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
IR Sensor Module
×2
LED (generic)
LED (generic)
×2
Buzzer, Piezo
Buzzer, Piezo
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
Mailgun
VMware Workstation 12 Player

Story

Read more

Schematics

System Schematics

Code

Smart_Appliances_Control

HTML
Control of lights in the room and provides manual turning OFF of the Buzzer Alarm, via Bolt Android App/Bolt Cloud.
<!DOCTYPE html>
<html>
  <head>
    <title>Smart Appliances Control</title>
    <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
    <script>
    setKey('{{ApiKey}}','{{Name}}');
    </script>
  </head>
  <body>
    <center>
    <h1>Smart Light</h1>
    <button onclick="digitalWrite(2, 'HIGH');">HIGH</button>
    <button onclick="analogWrite(2, '175');">MEDIUM</button>
    <button onclick="analogWrite(2, '100');">LOW</button>
    <button onclick="digitalWrite(2, 'LOW');">OFF</button>
    <h1>Buzzer Alert Control</h1>
    <button onclick="digitalWrite(0, 'LOW');">OFF</button>
    </center>
  </body>
</html>

Configuration.py

Python
We store all the credentials in a separate file since it is sensitive data which should not be shared with anyone. Hence it is a good practice to avoid using credentials in code directly. I have named the file storing the credential data as Configuration.py.
""" MAILGUN CONFIGURATION """  
MAILGUN_API_KEY = "You can find in your Mailgun dashboard"
SANDBOX_URL = "You can find in your Mailgun dashboard"
SENDER_MAIL = "Mail Address of Mailgun." 
RECIEVER_MAIL = "Write Your mail" 
""" BOLT IOT CONFIGURATION """  
bolt_api_key = "This is your Bolt Cloud account API key"
bolt_device_id = "This is the ID of your Bolt device"

AutomationtoPreventCOVID

Python
The main that is used to run and control the entire system.
import json
import config
import time

from boltiot import Email, Bolt

people=0
count=0

mybolt = Bolt (Configuration.bolt_api_key, Configuration.bolt_device_id)
mailer=Email(Configuration.MAILGUN_API_KEY, Configuration.SANDBOX_URL, Configuration.SENDER_EMAIL, Configuration.RECIPIENT_EMAIL)

while True: 
  
  try: 
    
    #COUNTING NUMBER OF PEOPLE IN THE ROOM
    
    response=mybolt.digitalRead ('1')
    data=json.loads(response)
    if data['value']==0:
      people=people+1
    response=mybolt.digitalRead ('4')
    data=json.loads(response)
    if data['value']==0:
      people=people-1
    if people<0:
      people=0
    if people>0:
      response=mybolt.digitalWrite('3','HIGH')
    print("Number of people in room:"+str(people))
    
    #ALERT FOR OVERCROWDING
    
    if people>5:
      response=mybolt.digitalWrite ('0','HIGH')
      print(response)
      print("Requesting Mailgun to send Alert for Overcrowding")
      response = mailer.send_email("ALERT!", "MORE THAN 5 PEOPLE IN ROOM.STOP OVERCROWDING. MAINTAIN SOCIAL DISTANCING")
      response_text = json.loads(response.text)
      print("Response from Mailgun:" + str(response_text['message']))
      
    #REMINDER FOR HAND SANITIZING
    
    if count%3600==0:
      response=mybolt.digitalWrite ('0','HIGH')
      print("SANITIZE/WASH YOUR HANDS...STAY SAFE!")
      time.sleep(5)
    count=count+60
  
  except Exception as e: 
    print ("Error occured: Below are the details")
    print (e)
  time.sleep(60)

Credits

Tunir Das

Tunir Das

3 projects • 4 followers
YouTube: https://www.youtube.com/channel/UCqUo_xeyKlJ8mN1cT7zjQ6Q?

Comments