Vishal Kumar Singh
Published © LGPL

Room Temperature Regulation with Automation & Voice Control

App and Voice control home-automation along with auto-temperature regulation which saves electricity, money and your health.

IntermediateFull instructions provided2 hours70
Room Temperature Regulation with Automation & Voice Control

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
Charging cable comes along with it. Give 5 volt supply to it from laptop/PC USB port or from the mobile charger.
×1
Temperature Sensor
Temperature Sensor
×1
Grove - 2-Channel SPDT Relay
Seeed Grove - 2-Channel SPDT Relay
Use Generic Relay module which is available at Amazon. Prefer 4-channel relay if you wish to control more switches.
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×4
Male/Male Jumper Wires
×3
USB Cable, Male - Female
USB Cable, Male - Female
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
Snappy Ubuntu Core
Snappy Ubuntu Core
Set up a Digital Ocean account and create an Ubuntu virtual server with it. Then install putty software on your desktop to access the Ubuntu server.
SMS Messaging API
Twilio SMS Messaging API
Telegram App

Hand tools and fabrication machines

Torque, Screwdriver
Torque, Screwdriver
Tape, Electrical
Tape, Electrical
Scissor, Electrician
Scissor, Electrician

Story

Read more

Schematics

Circuit Diagram

Circuit Connections

Code

Bolt Automation App Program

HTML
This program is written in Bolt Cloud which gives a face/look to our Bolt App.
<!DOCTYPE html>
<html>
    <head>
        <title>HOME AUTOMATION</title>
        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
        <script>
        setKey('{{ApiKey}}','{{Name}}');
        </script>
    </head>
    <body>
        
        <center>
        <div style="position: fixed; top: 5px; left: 10px; width: 375px; height: 45px; background-color:yellow;"> 
                      Room Temperature Regulation with Automation</div>
        </center>

        <div style="position: fixed; top: 60px; left: 80px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(1, 'HIGH');">
                 <img src="https://clipartart.com/images/bulb-light-clipart-8.jpg" width="100" height="150"></imgbutton></div>

        <div style="position: fixed; top: 60px; left: 210px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(1, 'LOW');">
                <img src="https://img.favpng.com/13/13/23/incandescent-light-bulb-lamp-clip-art-christmas-clip-art-png-favpng-PSpA15kzJ9EfXDABbeGGEYh8e.jpg"
                                                                                 width="100" height="150"></imgbutton></div>
        <div style="position: fixed; top: 265px; left: 80px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(2, 'HIGH');" >
                <img src="https://cdn-www.ahs.com/cs/ahs/image/running-fan.jpg"  width="100" height="150"></imgbutton></div>
        
        <div style="position: fixed; top: 265px; left: 210px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(2, 'LOW');" >
                <img src="https://productexpert.in/wp-content/uploads/2019/03/Best-Ceiling-Fan-in-India.jpeg"
                                                                                width="100" height="150"></imgbutton></div>
        <div style="position: fixed; top: 460px; left: 80px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(1, 'HIGH');">
                 <img src="https://ph-test-11.slatic.net/shop/fda01be88e75243760ddf498c87ea896.jpeg" 
                                                                               width="100" height="150"></imgbutton></div>
        <div style="position: fixed; top: 460px; left: 210px; width: 120px; height: 160px; background-color:white;">
            <imgbutton onclick="digitalWrite(1, 'LOW');">
                <img src="https://cf.shopee.ph/file/a040a6338c05fea78248a7bee52f1a7c" width="100" height="150"></imgbutton></div>

        <div style="position: fixed; top: 220px; left: 90px; width: 120px; height: 20px; background-color:white;">LIGHT ON</div>
        <div style="position: fixed; top: 220px; left: 220px; width: 120px; height: 20px; background-color:white;">LIGHT OFF</div>
        <div style="position: fixed; top: 425px; left: 100px; width: 120px; height: 20px; background-color:white;">FAN ON</div>
        <div style="position: fixed; top: 425px; left: 230px; width: 120px; height: 20px; background-color:white;">FAN OFF</div>
        <div style="position: fixed; top: 610px; left: 80px; width: 120px; height: 20px; background-color:white;">COOLER ON</div>
        <div style="position: fixed; top: 610px; left: 210px; width: 120px; height: 20px; background-color:white;">COOLER OFF</div>
  
  </body>
</html>

Auto-Temperature Regulation Program

Python
When the temperature of the room falls below a certain threshold value stated in the program, then the AC/Cooler running in the room will automatically switch OFF and the Fan will be switched ON to regulate the temperature.
import conf, requests
from boltiot import Sms, Email, Bolt
import json, time


threshold = 28


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL, conf.RECIPIENT_EMAIL)


def send_telegram_message(message):
    """Sends message via Telegram"""
    url = "https://api.telegram.org/" + conf.telegram_bot_id + "/sendMessage"
    data = {
        "chat_id": conf.telegram_chat_id,
        "text": message
    }
    try:
        response = requests.request(
            "POST",
            url,
            params=data
        )
        print("This is the Telegram URL")
        print(url)
        print("This is the Telegram response")
        print(response.text)
        telegram_data = json.loads(response.text)
        return telegram_data["ok"]
    except Exception as e:
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False

while True:

    print ("Reading sensor value")
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    sensor_value = int(data['value'])
    temp = (100*sensor_value)/1024
    print("Tempeature value is: " + str(temp) + "°C" )

    try:
        if temp < threshold:

            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The Current temperature temperature is "                                                                   +str(temp)+ "°C")
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status)
            
            print("Making request to Mailgun to send an email")
            response = mailer.send_email("Alert", "The Current temperature is "                                                                 +str(temp)+ "°C")
            response_text = json.loads(response.text)
            print("Response received from Mailgun is: " + str(response_text['mess                                                                           age']))

            print("Switching ON the FAN")
            message = "Alert! The Current temperature is "  +str(temp)+ "°C"
            telegram_status = send_telegram_message(message)
            print("This is the Telegram status:", telegram_status)

            mybolt.digitalWrite('1','HIGH')               #FAN SWICHED ON   
            mybolt.digitalWrite('2','LOW')                #AC/COOLER SWITCHED OFF

            time.sleep(15000)

    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(300)

Credits

Vishal Kumar Singh

Vishal Kumar Singh

1 project • 0 followers

Comments

Add projectSign up / Login