Abhishek Sinha
Created February 14, 2020 © GPL3+

Sending an SMS while temperature crosses Threshold

Through this device we can constantly monitor the temperature of cold storages and vary the temperature also when needed.

IntermediateFull instructions provided3 hours1
Sending an SMS while temperature crosses Threshold

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LM35 SENSOR
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

Circuit

1..) VCC pin of the LM35 connects to 5v of the Bolt Wifi module.
2.) Output pin of the LM35 connects to A0 (Analog input pin) of the Bolt Wifi module.
3.) Gnd pin of the LM35 connects to the Gnd.

Code

Temperature Monitor Sensor code

Python
first write configuration code (eg : conf.py)in which we have to write following code :
SID = 'You can find SID in your Twilio Dashboard'
AUTH_TOKEN = 'You can find on your Twilio Dashboard'
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device'

After that we will import it in our main program , and write rest of our code where we will fetch data and send alert to user.
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  values from sensor")
    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 to user ")
            response = sms.send_sms("The Current temperature sensor value is " +str(sensor_value))
            print("Response  from Twilio is: " + str(response))
            print("Status of SMS  :" + str(response.status))
    except Exception as e: 
        print ("Error:")
        print (e)
    time.sleep(10)

Credits

Abhishek Sinha

Abhishek Sinha

0 projects • 0 followers

Comments