Revathy Jayakumar
Published © GPL3+

Save Light Energy using IoT!!!!

Its a very heavy task to check whether our room is under the power supply or not unnecessarily. Come !!!Lets check it in an easy way.

BeginnerFull instructions provided1 hour338
Save Light Energy using IoT!!!!

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Breadboard (generic)
Breadboard (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

Step 1:

Connect one end of LDR to 3V3 pin of the bolt WiFi module(orange wire)and the other end to the A 0 pin of the WiFi module(violet wire).

Step 2:

Connect one end of the resistor to A0 pin(violet wire) and the other end to the Ground pin(dark blue wire).

Step 3:

Connect the negative pin of the buzzer(smaller lead)to the Ground(dark blue wire)and positive end(longer lead)to the 0 pin(Grey wire).

Code

Python Code

Python
import pro_conf      #my Configuration File
from boltiot import Sms, Bolt
import json, time, requests

minimum_limit = 300
maximum_limit = 600  


mybolt = Bolt(pro_conf.API_KEY, pro_conf.DEVICE_ID)
sms = Sms(pro_conf.SID, pro_conf.AUTH_TOKEN, pro_conf.TO_NUMBER, pro_conf.FROM_NUMBER)


while True: 
    print ("Reading sensor value")
    response = mybolt.analogRead('A0') 
    data = json.loads(response) 
    print("Sensor value is: " + str(data['value']))
    try: 
        sensor_value = int(data['value']) 
        if sensor_value > maximum_limit :
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Someone have turned ON light in the room")
            url = "https://cloud.boltiot.com/remote/"+pro_conf.API_KEY+"/digitalWrite"
            urldata = {"pin":0, "state":'HIGH', "deviceName":pro_conf.DEVICE_ID }
            comm = requests.request("GET",url, params=urldata)
            print(comm.text)
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
        elif sensor_value < minimum_limit :
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Have turned OFF the light")
            url = "https://cloud.boltiot.com/remote/"+pro_conf.API_KEY+"/digitalWrite"
            urldata = {"pin":0, "state":'LOW', "deviceName":pro_conf.DEVICE_ID }
            comm = requests.request("GET",url, params=urldata)
            print(comm.text)
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Revathy Jayakumar
1 project • 0 followers

Comments