Ayush Anand
Published

Bolt-Based Smart Light Control Equipped with Photoresistor

Depending upon the light intensity at that instant the lighting of the lighting system is adjusted using photoresistor [LDR].

BeginnerFull instructions provided3 hours643
Bolt-Based Smart Light Control Equipped with Photoresistor

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LED (generic)
LED (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Snappy Ubuntu Core
Snappy Ubuntu Core
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

conf

Python
configurations and credential file
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' 

main_code

Python
main working code for running the set-up
import conf
from boltiot import Sms, Bolt
import json, time

min_value = 500
max_value = 800


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, 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 > max_value:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("ALERT:Lights are on,The current brightness value is " +str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
            response = mybolt.digitalWrite('0','LOW')
        elif sensor_value < min_value:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("ALERT:Lights are off,The current brightness value is " +str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
            response = mybolt.digitalWrite('0','HIGH')
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Ayush Anand

Ayush Anand

1 project • 3 followers

Comments