Fight COVID-19 Contactless lighting using Bolt IoT

Untitled design

This project was made by Sujithraa Sampath as a part of the "Fight COVID-19 using IoT and ML" Challenge.  Here is a video made by Sujithraa Sampath showing how the project works. You can build the project yourself by going through the rest of the blog.


Respiratory viruses like coronavirus disease (COVID-19) spread when mucus or droplets containing the virus get into your body through your eyes, nose or throat. The virus can spread from one person to the next, if a healthy person touches a surface which was previously touched by an infected person.

Unfortunately a lot of the work that we do, requires us to touch several surfaces throughout the day. Sujithraa has setup a system, which allows people to turn on their lights without touching the light switch. With this project, you will not need to touch the light switch, thereby reducing the chances of virus spread.

Let's quickly look at how we can replicate this project.

Things used in this project

Hardware components

  • Bolt WiFi Module
  • 2 IR sensors.
  • 1 LED
  • 330ohm resistor
  • Breadboard
  • Jumper wires
  • USB cable.

Software, Apps and online services

  • Bolt Cloud
  • DigitalOcean

Hardware setup

Step 1] Make the circuit connections as shown in the fritzing diagram below.

Schematic Diagram

Step 2] Power up the circuit using a micro USB cable.

Step 3] If you have not already done so, click here to see a video which will you how to configure the Bolt WiFi module to connect to the internet.

Software Programming

Step 1]Log in to, go to the API tab, and copy over the API. This will be used later.

5. Copy API key

Step 2] Go to the devices tab, and copy over the device id.

4. Copy Device ID

Step 3] Log in to your DigitalOcean droplet, and install the required software using the following instructions.

	sudo apt-get -y update
	sudo apt install python3-pip
	sudo pip3 install boltiot

Step 4] Use the "nano" command to create a python file and add the following code to the python file. NOTE remember to replace <API key> and <Device ID> with the API key that you copied in step 1, and the device id that you copied in step 1.

from boltiot import Bolt
import json, time

mybolt = Bolt(<API key>, <Device id>)

people = 0

while True:
        #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')
            mybolt.digitalWrite('4', 'LOW')
        response = mybolt.digitalRead('3')
        data = json.loads(response)
        print("The number of people in the hall = " +str(people))
        print("Sleep for 10 seconds")
    except Exception as e:
        print("Something went wrong: ",e)
        print("Restarting Bolt...")
        response = mybolt.restart()

Step 5] Exit the nano editor by pressing "ctrl +x" and then press enter.

Step 6] Run the python code using the command "sudo python3"


With this system in place, you can turn on or turn off your room lights just by entering or leaving the room.

Want to build more such IoT and ML projects? Want to learn IoT and ML from basics?

Check out the Bolt IoT and ML training. This online video training is excellent for those who want to start with IoT and ML because it teaches you to build projects from the basics. Click on the button below to know more about the training.

Learn more about Bolt IoT & ML Training


Home Automation COVID-19