Vismaya KB
Published © GPL3+

Temperature monitoring system

A temperature monitoring system which will alert the user via SMS when the temperature crosses the threshold value.

IntermediateFull instructions provided-60 minutes90
Temperature monitoring system

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

Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

Complete Code for Temperature monitoring system

Python
The coding is used to monitor the temperature and send an alert message via SMS This file is saved as 'temp_sms.py' .
#temp_sms.py
import conf
from boltiot import Sms, Bolt
import json, time

minimum_limit = 50
maximum_limit = 150 


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)

This file stores all the credentials related to Twilio and it is saved as conf.py

Python
SSID='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
AUTH_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
FROM_NUMBER='+1x21XXXX70x'
TO_NUMBER='+91XXXXXXXXXX'
API_KEY='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
DEVICE_ID='BOLTXXXXXXX'

Credits

Vismaya KB

Vismaya KB

1 project • 0 followers

Comments