Sakshi Doshi
Published

Smart doorbell for deaf people

A doorbell which can be controlled online via phone or computer which then glows the bulb and sends an SMS every time it is on.

IntermediateFull instructions provided1 hour914
Smart doorbell for deaf people

Things used in this project

Story

Read more

Schematics

Circuit Diagram

This diagram will help you understand how I have done the connections for my project

Code

main.html

HTML
This is the front end page of our app. Here we design the page with basic HTML and also define functions using javascript which then send response to our python file through json
<!DOCTYPE html>
<html>
    <head>
        <title>Smart Doorbell System</title>
       
        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
        <script>
        setKey('{{ApiKey}}','{{Name}}');
        </script>
        <style>
            button{width : 250px;height  : 200px;font-size : 100px;}
          
        </style>
    </head>
    <body>
        <center>
         <h1>Smart Doorbell System</h1>
        <button onclick="switchLEDoN()">ON</button>
        <button onclick="switchLEDoFF()">OFF</button>
        
        </center>

        <script>
            let status = 0;
            function switchLEDoN() {
                if(status == 0) {
                    status=1;
                    digitalWrite(2, 'HIGH');
                    fetch("http://localhost:5000/sendSMS?ledstatus=1")
                        .then(res=>res.json())
                        .then(data=>{
                            if(data.code==200)
                                console.log(data.data);
                        })
                }
            }
            function switchLEDoFF() {
                if(status == 1){
                    status = 0;
                    digitalWrite(2, 'LOW');
                }
            } 
        
        </script>
    </body>
</html> 

app.py

Python
In this code, we use flask to help us get the values of the function when the bulb is turned on. Via flask, it returns us the status of LED and based on the status we can make do certain actions such as sending an SMS, etc.
from flask import Flask, request
import conf
import json
import time
from boltiot import Sms, Bolt
import json
import time

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

app = Flask(__name__)


@app.route("/sendSMS", methods=['GET'])
def sendSMS():
    if request.method == 'GET':
        ledstatus = request.args.get('ledstatus')

        print(ledstatus)
        print(ledstatus == '1')

        res = {
            'code': "400",
            'data': "Bad request",
        }
        if ledstatus == '1':
            print(sms.send_sms('The door bell rang!'))
            res = {
                'code': 200,
                'data': "SMS sent"
            }

        elif ledstatus == '0':
            print("led off")

        return json.dumps(res)


app.run()

Credits

Sakshi Doshi

Sakshi Doshi

1 project • 2 followers

Comments