Chirag Gupta
Created September 3, 2019

Smart Home Alarm System

This system rings the alarm , turns on the light and it also sends a Good Morning message to the user as soon as sunlight falls on sensor.

IntermediateFull instructions provided824
Smart Home Alarm System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×5
Breadboard (generic)
Breadboard (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×2

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
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Schematics

Connections

Code

smart_alarm.py

Python
import confy, json, time
from boltiot import Bolt,Sms

limit = 400

mybolt = Bolt(confy.API_KEY, confy.DEVICE_ID)
sms = Sms(confy.SID, confy.AUTH_TOKEN, confy.TO_NUMBER, confy.FROM_NUMBER)
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 > limit:
      print("Making a request to Twilio to send SMS")
      response = sms.send_sms("Wake UP. GOOD MORNING Have a great day ahead")
      print("Switching ON the lights")
      print("Switching ON the alarm")
      mybolt.digitalWrite('1','HIGH')
      print("Response recieved from Twilio is: "+str(response))
      print("Status of the SMS at twilio is: "+str(response.status))
    else:
      print("There is still night")
      print("Do not send the message through Twilio")
      print("Do not turn ON the lights")
      print("Do not turn ON the alarm")
      mybolt.digitalWrite('1','LOW')
  except Exception as e:
      print("Error occured.Below are the details")
      print(e)
  time.sleep(10)    

confy.py

Python
SID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
AUTH_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
FROM_NUMBER = 'XXXXXXXXXXX'
TO_NUMBER = 'XXXXXXXXXXXX'
API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
DEVICE_ID = 'BOLTXXXXXXXX'

Credits

Chirag Gupta

Chirag Gupta

1 project • 0 followers

Comments