Prajesh Gawhale
Published © GPL3+

Smart Home Automation Using Bolt IOT

Control your home lights from your phone

IntermediateFull instructions provided2 hours861
Smart Home Automation Using Bolt IOT

Things used in this project

Hardware components

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

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Schematics

Circuit Connections

Code

HTML Mobile app code

HTML
Its a HTML code for bolt mobile application you need to paste it in Bolt Cloud
<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 Project</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 LED Over Internet </h1>

        <center>

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

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

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

    </body>

</html>

Program Code

Python
This is the Python code where Thresholds are set and other factors
import config
from boltiot import Bolt, Sms
import json, time

mybolt = Bolt(config.API_KEY, config.DEVICE_ID)
sms = Sms(config.SID, config.AUTH_TOKEN, config.TO_NUMBER, config.FROM_NUMBER)
min_limit = 120
max_limit = 600

def led_on():
    mybolt = Bolt(config.API_KEY, config.DEVICE_ID)
    response = mybolt.digitalWrite("1", "HIGH")
    print(response)
def led_off():
    mybolt = Bolt(config.API_KEY, config.DEVICE_ID)
    response = mybolt.digitalWrite("1", "LOW")
    print(response)

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_limit):
            print("Turning off the lights")
            led_off()
            print("Making request to Twilio to send sms")
            response = sms.send_sms("Smart Home : Turning off the lights")
            print("Status of the sms at Twilio is:" + str(response.status))
        elif (sensor_value < min_limit):
            print("Turning on the Lights")
            led_on()
            print("Making request to Twilio to send sms")
            response = sms.send_sms("Smart Home : Turning on the lights")
            print("Status of the sms at Twilio is:" + str(response.status))
    except Exception as e:
        print("error occured: Below are the details")
        print(e)
    time.sleep(10)    

Credits

Prajesh Gawhale
1 project • 1 follower

Comments