Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
![]() |
| × | 1 |
Hardware Setup
Code analysing sensor readings
Increasing the temperature using candle
Alert message
import conf
from boltiot import Sms, Bolt
import json, time
minimum_limit = 200
maximum_limit = 700
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.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 > maximum_limit:
print("Making request to Twilio to send a SMS")
response1 = sms.send_sms("FIRE ALERT!"+"\nRISE IN TEMPERATURE!"+"\nThe Current temperature sensor value is " +str(sensor_value))
print("Response received from Twilio is: " + str(response1))
print("Status of SMS at Twilio is :" + str(response1.status))
print("Making request to Mailgun to send an email")
response = mailer.send_email("Alert", "The Current temperature sensor value is " +str(sensor_value))
response_text = json.loads(response.text)
print("Response received from Mailgun is: " + str(response_text['message']))
except Exception as e:
print ("Error occured: Below are the details")
print (e)
time.sleep(10)
Comments
Please log in or sign up to comment.