Jitesh Kumar
Published

Thermostat using Bolt

Sense the temperature, if temperature crosses threshold sends an sms to the user.

BeginnerFull instructions provided1 hour368
Thermostat using Bolt

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Temperature Sensor
Temperature Sensor
LM35 sensor
×1
Jumper wires (generic)
Jumper wires (generic)
Male to Male & Male to Female both are used
×5
Breadboard (generic)
Breadboard (generic)
×1
Buzzer
Buzzer
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Story

Read more

Schematics

Circuit Connection of Thermostat using Bolt

Code

Coding for thermostat using Bolt

Python
First creating 'conf' file using command 'sudo nano conf.py' for holding the data of Twilio, Api key and device id of bolt device.
SID = 'ACa904024c9d5cdbf04ae9aeb2d31ce600'
AUTH_TOKEN = '01e59caa644f194f829d4a7055427ca2'
FROM_NUMBER = '+12513024533'
TO_NUMBER = '+919889799019'
API_KEY = '5021b89c-1fcf-44f5-b4e5-11fec09ba869'
DEVICE_ID = 'BOLT7420750'

Coding for thermostat using Bolt

Python
After creating 'conf' file save it using 'ctrl+x'
Now create another file 'sudo nano thermostat.py'
write the code
import conf
from boltiot import Sms, Bolt
import json, time

thereshold = 380

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

def get_sensor_value_from_pin(pin):
    """Returns the sensor value. Returns -999 if request fails"""
    try:
       response = mybolt.analogRead(pin)
       data = json.loads(response)
       if data["success"] != 1:
            print("Request not successfull")
            print("This is the response->", data)
            return -999
       sensor_value = int(data["value"])
       return sensor_value
    except Exception as e:
       print("Something went wrong when returning the sensor value")
       print(e)
       return -999
while True:
     print("************************")
     print("Loop Starting")
     mybolt.digitalWrite("0", "HIGH")
     time.sleep(1)
     mybolt.digitalWrite("0", "LOW")
     print("Reading time 15 secs...")
     time.sleep(15)
     sensor_value = get_sensor_value_from_pin("A0")

     if(sensor_value > thereshold):
       print("Making requests to Twilio to send a SMS")
       response = sms.send_sms("ALERT! Temperature crossing threshold and the temperature is " +str(sensor_value))
       print("Response received from Twilio is: " +str(sensor_value))
       mybolt.digitalWrite("0", "HIGH")

     else:
       print("Making requests to Twilio to send a SMS")
       response = sms.send_sms("Don't worry, the temperature is under controlable limit. The temperature is " +str(sensor_va$
       print("Response received from Twilio is: " +str(sensor_value))

       for _ in range(5):
            mybolt.digitalWrite("0", "HIGH")
            time.sleep(1)
            mybolt.digitalWrite("0", "LOW")
     print("nest cycle will start in 5 secs....")
     print("*****************************")
     time.sleep(5)

Temperature=(100*sensor_value)/1024 #converting temperature into deg. celcius

Credits

Jitesh Kumar
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.