Pushpak Goswami
Published © CC BY-ND

Observing Of Temprature And Its Alert By Utilizing Bolt IoT

The gadget which notifies by means of Whatsapp message and through SMS simultaneously at whatever point the temperature crosses the limit.

BeginnerFull instructions provided3 hours681
Observing Of Temprature And Its Alert By Utilizing Bolt IoT

Story

Read more

Schematics

Temprature Monitoring System

Temprature Monitoring System

Code

Main Code

Python
This is the main file where the actual logic of the project is given in which we are importing two configuration files as stated before and checking by if the statement if the sensor value reached the threshold or not if yes then send the alert message both in Whatsapp and via SMS.
import conf, mconf
from boltiot import Sms, Bolt
import json, time

minimum_limit = 20
maximum_limit = 30  


mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms1 = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
sms2 = Sms(mconf.SID, mconf.AUTH_TOKEN, mconf.TO_NUMBER, mconf.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'])
        Temprature= (100*sensor_value)/1024
        if Temprature > maximum_limit or sensor_value < minimum_limit:
            print("Making request to Twilio to send a whatsapp Message")
            response1 = sms1.send_sms("The Current temperature sensor value is " +str(Temprature))
            print("Making request to Twilio to send a SMS ")          
            response2 = sms2.send_sms("The Current temperature sensor value is " +str(Temprature))
            print("Response received from Twilio is: " + str(response1))
            print("Status of Whatsapp at Twilio is :" + str(response1.status))
            print("Response received from Twilio is: " + str(response2))
            print("Status of SMS at Twilio is :" + str(response2.status))

    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Pushpak Goswami
1 project • 0 followers

Comments