Sujithraa
Published

Auto Light To Avoid Spreading Of COVID-19

COVID-19 will spread by the direct contact with the switches. Since, auto light is used to avoid making physical contact with the switches.

IntermediateFull instructions provided15 hours648
Auto Light To Avoid Spreading Of COVID-19

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
IR sensor
×2
LED (generic)
LED (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×6
Male/Male Jumper Wires
×5
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
Mailgun
IFTTT

Story

Read more

Schematics

Auto light

The light will automatically turn on when the people enter the hall. This will be helpful in avoiding the spreading of covid-19.

Code

Main coding

Python
from boltiot import Bolt, Email
import conf
import json, time

mybolt = Bolt(conf.api_key, conf.device_id)
mailer = Email(cinf.mg_api_key, conf.sandbox_url, conf.sender_EM, conf.receipient_EM)

people = 0

while True:
        try: 
            #Read input and determine number of people entering in the room
            response = mybolt.digitalRead('0') #IR sensor for entry door
            data = json.loads(response)
            if data['value'] == "0" :
                 people = people + 1
            #Read input and determine number of people existing in the room
            response = mybolt.digitalRead('1') #TR sensor for exit door
            data = json.loads(response)
            if data['value'] == "0" :
                 people = people - 1
                 if people < 0:
                         people = 0
                         
            #Take action on lights             

            if people > 0:
                   mybolt.digitalWrite('4', 'HIGH')
            else:
                   mybolt.digitalWrite('4', 'LOW')
                   
            #Send Email alert       

            response = mybolt.digitalRead('3') 
            data = json.loads(response)
            if peolpe > 0:
                   response = mailer.send_email("Room Info", "Light is turning ON. The number of people in the room= " +str(people))
                   response_text=json.loads(response.text)
            elif people == 0:
                   response = mailer.send_email("Room Info", "Light is turning OFF. The number of people in the room= " +str(people))
                   response_text=json.loads(response.text)
            print("The number of people in the hall = " +str(people))
            print("Sleep for 10 seconds")
            time.sleep(10)

        except Exception as e:
            print("Something went wrong: ",e)
            print("Restarting Bolt...")
            response = mybolt.restart()      

Credits

Sujithraa

Sujithraa

1 project • 0 followers

Comments