Ghana Tej
Published

Be alert when temperature crosses threshold

Designed a device that continuously monitors the temperature through sensors and sends an SMS alert when the temperature in the surrounding

BeginnerFull instructions provided1 hour37
Be alert when temperature crosses threshold

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×3
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

SMS alert when Temperature crosses threshold

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

minimum_limit = 300
maximum_limit = 600  


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 or sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Ghana Tej
1 project • 0 followers

Comments