Riddhesh Misal
Published © GPL3+

Automatic Room Lighting System

This project is nothing but self altering of intensity of LED according to changes in brightness of its surroundings.

BeginnerProtip2 hours537
Automatic Room Lighting System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
5 mm LED: Red
5 mm LED: Red
×1
Resistor 1k ohm
Resistor 1k ohm
you can use 330ohm resistance as well according to your surrounding light
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Male Jumper Wires
×3

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

Hardware connections

Code

Code for the saving the credentials

Python
I have made a file temp_sms.py and saved it. It actually contains all the credential related to Twilio.
Following is the code for same
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' 

Final code for the alert message

Python
This is code for the alert. You can set here your own threshold limit depending on how much brightness you want in the room. I have set the max limit as 300.
import temp_sms
from boltiot import Sms, Bolt
import json, time

max = 300
 


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


while True: 
    print ("Reading the sensor value")
    response = mybolt.analogRead('A0') 
    data = json.loads(response) 
    print("The current sensor value is: " + str(data['value']))
    try: 
        sensor_value = int(data['value']) 
        if sensor_value > max:
            print("Making request send a SMS")
            response = sms.send_sms("Light intensity in the rrom is very high. The Current sensor value is " +str(sensor_value))
            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

Riddhesh Misal

Riddhesh Misal

1 project • 0 followers
Thanks to Mr. Pranav Pai Vernekar.

Comments