kasinadhuni vyshnavi supraja
Published © CERN-OHL

The Smart Fridge

This project can be useful to alert the user when a fridge is open and it alerts the user when the fridge is open.

BeginnerProtip2 hours420
The Smart Fridge

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1
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

Schematics

circuit connections for smart fridge

Code

code_fridge_open_alert

Python
This code is Written to get the sensor values and check if the temperature is increased or not... if the temperature is increased then it indicates that the fridge is open and gives a buzzer sound... also alerts the user with a message
import conf, json, time
from boltiot import Sms, Bolt
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data=[]
while True:
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    if data['success'] != 1:
        print("There was an error while retriving the data.")
        print("This is the error:"+data['value'])
        time.sleep(10)
        continue

    print ("This is the value "+data['value'])
    sensor_value=0
    try:
        sensor_value = int(data['value'])
        history_data.append(sensor_value)
    except e:
        print("There was an error while parsing the response: ",e)
        continue
    print(history_data)
    if(len(history_data)<=7):
          print("require some more values to process")
          time.sleep(10) 
          continue
    else:
        if(history_data[-1]>history_data[-2]):
            if(history_data[-1]>100):
                print("somebody opened the fridge.... sending alert")
                mybolt.digitalWrite(0, 'HIGH')
                print("Making request to Twilio to send a SMS")
                response = sms.send_sms("somebody ope ned the fridge door...")
                print("Response received from Twilio is: " + str(response))
                time.sleep(5)
                mybolt.digitalWrite(0, 'LOW')
                time.sleep(20)
            else:
                time.sleep(5)
                continue
                
    time.sleep(10)
      

configuration_file

Python
This code contains confidential information.
API_KEY='your bolt API key'
DEVICE_ID = 'your Bolt device id'
FRAME_SIZE = 10
MUL_FACTOR = 3
SSID = 'Your Twillo SSID' 
AUTH_TOKEN = 'TWillo authorized token.. THis token is present in your Twillo Dashboard'
FROM_NUMBER = 'this can be got from your Twillo page'
TO_NUMBER = 'This is the to_number to which you can send message..... You need to verify this number(This can be done with your Twillo page)'

Credits

kasinadhuni vyshnavi supraja

kasinadhuni vyshnavi supraja

1 project • 0 followers

Comments