In this modern era we people look for Smart things like smart phones smart TVs etc. So in the same way I designed a smart appliance which is both smart and low power consuming which not only makes our work simple but also saves money. Along with which I designed another appliance which works as a Fire alarm which triggers us whenever there happens a fire accident in home.
1. IntroductionThis project "SMARTHOMEAPPLIANCE" has primarily two functionalities.
· To turn ON and OFF the AIR CONDITIONER (let us take as yellow LED) basing on the Current trmperature readings
·Acts as afire alarm by switching ON and OFF Buzzer and RED LED
*The first operation which is On and Off of AC is done by the LM35 temperature sensor which gives us current temperature values. Now we set a limit of MAXIMUM and MINIMUM current temperatures. If the value of temperature is in between Maximum and Minimum limit we send a request to twilio to send message and it send the message to mobile showing the current temperature and also telling that "ACwill be Turned ON as it was HOT". And when the temperature is less than Minimum temperature it immediately send message to user saying the current temperature and also " AC will be turned OFF as it was cool" and it switches of AC.
*The second operation is FIRE ALARM, so this works when the temperature sensor records temperature which is higher than Threshold, then immediately we get a message to user from Twilio saying "FIRE ALERT!!!" and also it switches OFF AC if turned ON and turns FIRE LED and FIRE BUZZER ON for This also includes a seconds and OFF again. This process continues.
2. DemonstrationSMART HOME APPLIANCE
Alert Notifications :
1 / 2 • SMS Alerts
3. Steps for building the projectPUSH BUTTON - Connect one terminal of buttton to digital pin 4 and other to supply voltage 3V3 pin.
3.1 Hardware Connections for SMART AIR CONDITIONERLED
Step 1: Take one leg of the led i.e. positive leg or attach the longer leg to one point on bread board.
Step 2: Attach the shorter leg of the led i.e. the negative led in the breadboard to the ground (GND) pin of bolt with the help of jumper wires (male to male).
Step 3: Now connect another leg of the LED to the digital pin 3 of the Bolt with the help of jumper wire.
Step 4: Now connect LM#% pins VCC to 5V, output to A0 and Gnd to common ground in breadboard this controlls the ON and OFF functionalities of air conditioner
3.2 Hardware Connections for Fire AlarmLM35 Temperature Sensor
Step 1: The VCC pin connects to 5V of Bolt Wifi Module.
Step 2:The output pin is connected to the analog pin (A0) of the module.
Step 3: The GND pin is connected to the ground pin of Bolt Wifi Module.
Step 4: Also a LED and a buzzer connected to the Bolt Wifi Module. The LED is connected to digtal pin 1 and the buzzer’s anode to pin 2 of the module.
When the device detects the fire, the pin 2, 1 will be set to HIGH so that both the LED and the buzzer is switched on, raising an alarm.
Fire Alarm
3.3 Using TwilioTwilio is a third-party SMS functionality provider. It is a cloud communications platform as a service (PaaS) company. Twilio allows software developers to programmatically make and receive phone calls and also send and receive text messages using its web service APIs.
Step 1: Visit twilio.com and create a free trial account.
Step 2: Verify your email id and your phone number.
Step 3: Go to the dashboard and click Get a Trial Number.
Step 4: Now you can find that Twilio would have assigned you a number.
Twilio Dashboard
3.4 Using Bolt CloudBolt cloud is a server which lets you communicate with your Bolt WiFi module over the internet. It offers features like receiving and storing the data collected by Bolt Modules, Storing the data, Analysing it via Data visualisation and Machine Learning as well as it lets your program your Bolt modules.
Step 1: Visit cloud.boltiot.com and create an account in the Bolt Cloud.
Step 2: Set up and link the microcontroller module to the Bolt Cloud.
Step 3: Create the product and link the product with the device on the cloud.
Bolt Cloud
3.5 Configuration FileThe python coding for this project has been done in Ubuntu (Linux). Before we start coding, we need to make a configuration file which will have the specific keys for each user/device. We will import this file in our main code and use the various attributes. The advantage of this is that each user will only have to change the contents the configuration file to use the product.
The following is the configuration file (named as conf.py):
SID = 'XXXXXX' # SID in Twilio Dashboard
AUTH_TOKEN = 'XXXXXX' # on Twilio Dashboard
FROM_NUM = 'XXXXXXXXXXXX' #This is the no. generated by Twilio on Twilio Dashboard
TO_NUM = 'XXXXXXXXXXXXXX' # your number with +91 in beginning
BOLT_API = 'XXXXXXXX' #Bolt Cloud accout API key
BOLT_ID = 'BOLTXXXXXXX' # Bolt device ID
- Section 3.3 explains how to get the above credentials from the twilio dashboard.
- Section 3.4 explains how to get the DEVICE_ID from the Bolt Cloud.
- Go to the API section to know the API KEY on Bolt Cloud.
API KEY
3.7 Python Codeimport config
import json, time, math
from boltiot import Bolt, Sms
mybolt = Bolt(config.BOLT_API, config.BOLT_ID)
sms = Sms(config.SID, config.AUTH_TOKEN, config.TO_NUM, config.FROM_NUM)
on = 1
off = 0
max_temp = 200
min_temp = 100
threshold = 250
def smart_home_mode():
while True:
response = mybolt.digitalRead('4')
data = json.loads(response)
print("status is" + str(data['value']))
try:
status = int(data['value'])
if status == on:
response = sms.send_sms("Smart home mode on")
time.sleep(5)
print("reading lm35 sensor value")
response1 = mybolt.analogRead('A0')
time.sleep(10)
data = json.loads(response1)
print("temperature is" + str(data['value']))
temp_value = int(data['value'])
if temp_value <= max_temp and temp > min_temp:
print("making request to twilio to send sms")
response2 = sms.send_sms("Room temperature is too hot" + str(temp_value) + "switching ON AC")
mybolt.digitalWrite('3','HIGH')
print("status of sms at twilio is: " + str(response2.status))
elif temp_value <= min_temp:
print("making request to twilio to send sms")
response3 = sms.send_sms("Room temperature is too cool" + str(temp_value) + "switching OFF AC")
mybolt.digitalWrite('3','LOW')
print("status of sms at twilio is: " + str(response3.status))
elif temp_value >= threshold:
print("making request to twilio to send sms")
response4 = sms.send_sms("FIRE ALERT!!!")
mybolt.digitalWrite('3',''LOW')
mybolt.digitalWrite('2','HIGH')
mybolt.digitalWrite('1','HIGH')
time.sleep(5)
mybolt.digitalWrite('2','LOW')
mybolt.digitalWrite('1','LOW')
print("status of sms at twilio is: " + str(response4.status))
if status == off:
response = sms.send_sms("Smart Home Mode OFF")
time.sleep(10)
except Exception as e:
print("Error occured while enabling smart home mode")
print(e)
time.sleep(10)
smart_home_mode()
3.8 Code Explanationimport conf
- In the code, we first have to import our conf file which has all the credentials. The python json, time and threading libraries are also imported in the same line. Since we have saved our conf file with the.py extension, we can directly import it.
import json, time
- json is a python library used for handling all operations on JSON objects. JSON is nothing but a data communication format widely used on the Internet for sending/receiving data between a client and server. 'json' is the python library used for handling JSON objects and JSON is a data communication format.
from boltiot import
Bolt,Sms
- In the above line, we are importing two objects. First one is Sms which will be used to send SMS alerts and the other one is Bolt which is used for accessing data from your Bolt device like the temperature reading.
max_temp= 1000
min_temp
= 100
threshold
= 1500
on = 1
off = 0
- Now initialize the two variables which will show status of push button ON and OFF
- the temperature limits tells us the status of room temperature
mybolt = Bolt(config.BOLT_API, config.BOLT_ID)
- Now to fetch the data from Bolt Cloud, we will create an object called 'mybolt' using which you can access the data on your Bolt. For the Bolt Cloud to identify your device, you will need to provide the API key and the Device ID when creating the mybolt object. Since the conf file holds the API key and Device ID variables, we can use it as mentioned above.
sms = Sms(config.SID, config.AUTH_TOKEN, config.TO_NUMBER, config.FROM_NUMBER)
- Now to send an SMS, we will create an object of the same and use the contents of configuration file like above.
def smart_home_mode():
- This declares the definition of the function of smart home enabling
while True:
- For the execution of the function smart home mode function in a loop.
response = mybolt.digitalRead('4')
data = json.loads(response)
print("status is" + str(data['value']))
- The code continuously fetches thevalue of buttonfrom digital pin 4
- The response from the Bolt Cloud using the digitalRead() function is in a JSON format, so we will need to load the JSON data sent by the cloud using Python's json library.
try:
- There is try-except block to handle any error that may occur in the code.
status = int(data['value'])
- The status of button from digital read is then converted to integer type weither 0 or 1.
if status == on:
- This shows button is on or off.
response = sms.send_sms("Smart home mode on")
time.sleep(5)
print("reading lm35 sensor value")
response1 = mybolt.analogRead('A0')
time.sleep(10)
data = json.loads(response1)
print("temperature is" + str(data['value']))
temp_value = int(data['value'])
- Here the smart home mode is enabled and user gets the message and the temperature sensor records the temperature from analogread pin A0 and covert to integer data type
if temp_value <= max_temp and temp > min_temp:
print("making request to twilio to send sms")
response2 = sms.send_sms("Room temperature is too hot" + str(temp_value) + "switching ON AC")
mybolt.digitalWrite('3','HIGH')
print("status of sms at twilio is: " + str(response2.status))
- Here by ranging temperature between maximum temperature and minimum temperature limit the Airconditioner switches ON by sending message to usersaying current temperature
elif temp_value <= min_temp:
print("making request to twilio to send sms")
response3 = sms.send_sms("Room temperature is too cool" + str(temp_value) + "switching OFF AC")
mybolt.digitalWrite('3','LOW')
print("status of sms at twilio is: " + str(response3.status))
- Here if temperature is cool lesssthan minimum limit them twilio sends message to user saying current tempperature and switches off AC
elif temp_value >= threshold:
print("making request to twilio to send sms")
response4 = sms.send_sms("FIRE ALERT!!!")
mybolt.digitalWrite('3',''LOW')
mybolt.digitalWrite('2','HIGH')
mybolt.digitalWrite('1','HIGH')
time.sleep(5)
mybolt.digitalWrite('2','LOW')
mybolt.digitalWrite('1','LOW')
print("status of sms at twilio is: " + str(response4.status))
Here
fire alarm is activated if ever temperature crosses or equalls threshold then we get a messsage as "FIRE ALERT!!!" and switches on both fire buzzer and fire indicator LED and they switches off after 5 seconds
if status == off:
response = sms.send_sms("Smart Home Mode OFF")
time.sleep(10)
Now
ifever the button is off the response shows in this way
except Exception as e:
print("Error occured while enabling smart home mode")
print(e)
time.sleep(10)
Here
it shows where the error lies in code execution
smart_home_mode()
The
entire code executed only if we call the function again.
3.9 Output Screen
- When the push button switch is pressed and the status became 1.
Pictures
showing different outputs at different conditions like !) greater than thereshold which is fire alarmBetween
max and min limit ON ACLessthan
MIN limit OFF AC
Final
circuit hardware connection
Comments