Gaurav Mittal
Published

Temperature Analyzer

In this project we are measuring the temperature of the environment using temperature Sensor (LM375).

IntermediateFull instructions provided4 hours514
Temperature Analyzer

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LM375 Sensor
×1
Breadboard (generic)
Breadboard (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
Mailgun
Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Custom parts and enclosures

Temperature Analyser Documentation

Schematics

Temperature Analyser Circuit Diagram

Code

Temperature Analyser code

Python
from boltiot import Bolt ,Sms, Email
import json, time, math, statistics
min=200*0.0977
max=600*0.0977
apikey="49##################################7a"
deviceid="BOLT####"
mybolt=Bolt(apikey,deviceid)
def cbounds(old_data,size factor):
  if len(old_data)<size:
    return None
  if len(old_data)>size:
    del _data[0:len(old_data)-size]
mn=statistics.mean(old_data)
var=0;
for d i in old_data:
  var=var+math.pow((d-mn),2)
zn=factor*math.sqrt(var/size)
hbound=old_data[size-1]+zn
lbound=old_data[size-1]-zn
return [hbound,lbound]
def message():
  sms=Sms("your SSID","your AUTH_TOKEN","your FROM_NUMBER", "your TO_NUMBER" )
  res1=sms.send_sms("The Temperature is"+str(sensor_value))
  mail=Email("your MAILGUN_API_KEY" ,"your SANDBOX_URL","your SENDER_EMAIL" ,"your RECIPIENT_EMAIL" )
  res2=mail.send_email("Alert","The temperature is"+str(sensor_value))
  time.sleep(300)
  return 0
old_data=[]
c=0
while True:
  response=mybolt.analofRead('A0')
  data=json.loads(response)
  sensor_value=(int(data[value]))*0.0977
  print("the temperature is "+str(sensor_value))
  if sensor_value>25 and sensor_value<26:
    c=c+1
  bound=cbounds(old_data,10,3)
  if not bound:
    req_size=10-len(old_data)
    print("not enough data")
    old_data.append(sensoe_value)
    time.sleep(10)
    continue
  try:
    if sensor_value>bound[0] or sensor_value<bound[1]:
      print("temp out of bound")
      print("the door is open")
      message()
    if c>12:
      print("the temperature is betwen 25 and 26 degree celcius for more than 20 minutes")
      message()
      c=0
  except Exception as e:
    print("Error",e)
  time.sleep(10)

    

Credits

Gaurav Mittal

Gaurav Mittal

1 project • 1 follower

Comments