Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
VIVEK OJHA
Published © MPL-2.0

Refrigerator Monitoring System via SMS with Bolt IoT

Here I have built an IoT system that will send an SMS recommendation to the user as to when to switch on/off his refrigerator

IntermediateProtip2 hours328
Refrigerator Monitoring System via SMS with Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Gravity: Analog LM35 Temperature Sensor For Arduino
DFRobot Gravity: Analog LM35 Temperature Sensor For Arduino
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
Ubuntu server OS

Story

Read more

Schematics

Connecting the LM35 sensor to the Bolt

Step 1: Hold the sensor in a manner such that you can read LM35 written on it.

Step 2: In this position, identify the pins of the sensor as VCC, Output and Gnd from your left to right.
In the above image, VCC is connected to the red wire, Output is connected to the orange wire and Gnd is connected to the brown wire.Step 3: Using male to female wire connect the 3 pins of the LM35 to the Bolt Wifi Module as follows:

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

Code

Here's the Full Code

Python
IN UBUNTU SERVER TERMINAL
create a file named 'conf.py' which will store all the credentials related to Twilio. To create a new file type 'sudo nano conf.py' in the terminal. After that write below code to save all the credentials in a single file.

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'

Note:You can find the first four value in Twilio dashboard and the last two in Bolt Cloud dashboard.
import conf
from boltiot import Sms, Bolt
import json, time

minimum_limit = 10
maximum_limit = 45


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")
            response = sms.send_sms("I'm Hot... its time you turn me ON " +str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
        if sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Chilled... turn me OFF " +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

VIVEK OJHA
1 project • 0 followers

Comments