Abhishek Jadhav
Published © GPL3+

Home Automation using BOLT IOT with Voice Control

This smart home automation project consist of various techniques like Voice control and SMS updates for IOT

IntermediateFull instructions provided528
Home Automation using BOLT IOT with Voice Control

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Maker service
IFTTT Maker service
I used IFTTT WebHooks but can't find it in this list
Assistant SDK
Google Assistant SDK
I used IFTTT Google WebHooks but it is not in the list. (same for cortana)
Windows 10
Microsoft Windows 10

Story

Read more

Schematics

Circuit Diagram

Code

IOT_Smart_Home

Python
It is main project file and I use another file for configurations named "conf.py" it stores all API key, device id etc confidential information
from boltiot import Bolt,Sms
import conf,json,time

mybolt=Bolt(conf.API_KEY,conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
global flag1,flag2
flag1 = 0
flag2 = 0

def Turnoffdevices():
	mybolt.digitalWrite('0','LOW')
	mybolt.digitalWrite('1','LOW')
	print("Devices are turned off")

def roomlights():
	global flag1
	if flag1==0:
		response=mybolt.digitalWrite('0','HIGH')
		res=json.loads(response)
		if res['value']=='Device is offline':
			print("please connect the BOLT device to the internet then try again")
		else:
			print("Room lights are turned on")
			flag1=1
			response=mybolt.analogWrite('1','150')
			time.sleep(1)
			response=mybolt.analogWrite('1','0')
	else:
		response=mybolt.digitalWrite('0','LOW')
		res=json.loads(response)
		if res['value']=='Device is offline':
			print("please connect the BOLT device to the internet then try again")
		else:
			print("Room lights are turned off")
			flag1=0

def alarm():
	global flag2
	if flag2==0:
		response=mybolt.digitalWrite('1','HIGH')
		res=json.loads(response)
		if res['value']=='Device is offline':
			print("please connect the BOLT device to the internet then try again")
		else:
			print("Alarm is turned on")
			flag2=1
	else:
		response=mybolt.digitalWrite('1','LOW')
		res=json.loads(response)
		if res['value']=='Device is offline':
			print("please connect the BOLT device to the internet then try again")
		else:
			print("Alarm is turned off")
			flag2=0

def routine():
	global flag1,flag2
	while(True):
		print("Reading sensor value")
		response=mybolt.analogRead('A0')
		data = json.loads(response)
		sensor_value=int(data['value'])
		if sensor_value < 30 and flag1==0 and flag2==0:
			print("Making request to Twillio to send an SMS")
			response = sms.send_sms("Natural sunlight is low turning on the lights now :)")
			roomlights()
			print("Status of SMS at Twillio is :"+str(response.status))
		elif flag1==1 and flag2==1:
			print("There is enough sunlight turning off the lights")	
			Turnoffdevices()
		time.sleep(10)

while(True):
		choice=input("Press 1 to activate room lights\nPress 2 to activate alarm\nPress 3 to set a routine\nPress 4 to turn off all\nPress 5 to Exit\n")
		
		if choice == '1':
			roomlights()

		elif choice =='2':
			alarm()
				
		elif choice =='3':
			routine()	
 
		elif choice =='4':
			Turnoffdevices()
				
		else:
			print("GoodBye")
			Turnoffdevices()
			break

			 

Credits

Abhishek Jadhav
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.