Apeksha Kamat
Published © Apache-2.0

Safe untouched Doorbell (covid- 19 special)

Because of the covid-19 situation its unsafe to even touch a doorbell. This untouched Doorbell can come with a good help.

BeginnerFull instructions providedOver 7 days553
Safe untouched Doorbell (covid- 19 special)

Things used in this project

Hardware components

Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×4
Male/Female Jumper Wires
Male/Female Jumper Wires
×2
Breadboard (generic)
Breadboard (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×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

Story

Read more

Custom parts and enclosures

circuit connections

Schematics

circuit diagram

Code

conf.py

Python
SID = 'AC56f775baf319ca284e19769fb083bb98'
AUTH_TOKEN = 'ab59e38060b0f24295bd6d235aa3adf4'
FROM_NUMBER = '+12028580795'
TO_NUMBER = '+918867256549'
API_KEY = '5242b1ed-bce7-4053-945a-d185ca959104'
DEVICE_ID = 'BOLT8021292'
FRAME_SIZE = 20
MUL_FACTOR = 10

contactless doorbell code

Python
import conf, json, time, math, statistics
from boltiot import Sms, Bolt
from datetime import datetime

def compute_bounds(history_data,frame_size,factor):
    if len(history_data)<frame_size :
        return None

    if len(history_data)>frame_size :
        del history_data[0:len(history_data)-frame_size]
    Mn=statistics.mean(history_data)
    Variance=0
    for data in history_data :
        Variance += math.pow((data-Mn),2)
    Zn = factor *math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size-1]+Zn
    Low_bound = history_data[frame_size-1]-Zn
    return [High_bound,Low_bound]

mybolt = Bolt(conf.API_KEY,conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data=[]

while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:"+data['value'])
        time.sleep(5)
        continue
    print ("Receiving Data...")
    print ("This is the value "+data['value'],"(time:", datetime.now().strftime("%H:%M:%s"),")")
    sensor_value=0
    try:
        sensor_value = int(data['value'])
    except e:
        print ("There was an error while parsing the response: ",e)
        continue
 bound = compute_bounds(history_data,conf.FRAME_SIZE,conf.MUL_FACTOR)
    if not bound:
        required_data_count=conf.FRAME_SIZE-len(history_data)
        print ("Not enough data to compute Z-score. Need ",required_data_count,"more data points")
        history_data.append(int(data['value']))
        time.sleep(5)
        continue

    try:
        if sensor_value > bound[0] :
            print ("doorbell on")
            resp = mybolt.analogWrite('0','150')
            print (resp)
            response = sms.send_sms("check the door")
            print ("This is the response",response)
        elif sensor_value < bound[1]:
             print ("doorbell on")
             resp = mybolt.digitalWrite('0','0')
             print (resp)
             response = sms.send_sms("open the door please")
             print ("This is the response",response)
        history_data.append(sensor_value);
    except Exception as e:
        print ("Error",e)
    time.sleep(5)

Credits

Apeksha Kamat
1 project • 1 follower

Comments