Rohit kumar
Published © GPL3+

Home Automation & Lights controlling System

Control to ON/ OFF home out side light manually and automatically. When the light intensity goes down, this device sends a SMS to the owner

BeginnerFull instructions provided3 hours1,744

Things used in this project

Hardware components

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

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
SMS Messaging API
Twilio SMS Messaging API
Oracle VM Virtual Box or Digital Ocean

Story

Read more

Schematics

circuit diagram

circuit

Code

autolight_sms.py

Python
Main code for running the smart system
import requests, json, time, math 
from boltiot import Sms, Bolt
import conf 

minimum_limit = 80 #can be change
maximum_limit1 = 300 #can be change
maximum_limit2 = 350             


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 the sencer value')
    response_ldr = mybolt.analogRead('A0')
    ldr_data = json.loads(response_ldr)
    print(ldr_data['value'])
    try:
        sensor_value = int(ldr_data['value'])
        print(response_ldr)
        led_value_1 = int(sensor_value/4)
        if maximum_limit1 <sensor_value > maximum_limit2 :
            response = sms.send_sms("Hi this is your home outside lights plz Turn OFF me ")
            time.sleep(20)
            continue
            if led_value_1-1 > 255:
                led_value_1 = 255
                led_value = 255 - led_value_1 #Output value to LED based on LDR input value
                response_led = mybolt.analogWrite('0', led_value) #Write output at pin 0
                print("Automated LED value is: "+str(led_value)) 
                print(response_led)
        response = sms.send_sms('Hi I have Turned OFF ')
    elif sensor_value < minimum_limit:
        response = sms.send_sms("Hi this is your home outside lights plz Turn ON me ")
        time.sleep(20)
        response_led = mybolt.analogWrite('0', led_value_1)
        print("Automated LED value is: "+str(led_value_1)) 
        print(response_led)
        response = sms.send_sms('Hi I have Turned ON ')
  

    except exception as e:
        print("Error")
        print(e)
    
    time.sleep(900)    #Wait for 15 minute 

out_light.html

HTML
bolt cloud program
<html>

    <head>
        <style>
            
            
            h1 { text-align:center;}
            .button {
  background-color: #7FFF00; 
  border: none;
  color: red;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
        
        </style>

        <title>IoT Platform</title>

        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>

        <script>

        setKey('{{ApiKey}}','{{Name}}');

        </script>
        <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

    </head>
    
    <body >
        <h1 style = font-family:"courier",text-align:"center"> Controlling Street  LED Over Internet </h1>

        <center>

        <button class="button" onclick="digitalWrite(0, 'HIGH');">ON</button>

        <button class="button" onclick="digitalWrite(0, 'LOW');">OFF</button>

        </center>
        <center>
            <i class="material-icons" style="font-size:60px;color:#00FFFF;">cloud</i>
        </center>
        

    </body>

</html>

Credits

Rohit kumar

Rohit kumar

1 project • 6 followers
I am student of Electrical Engineering College - BTKIT Dwarahat, Uttarakhand India .

Comments