Temperature sensor error....showing 100

i am doing a project of monitoring temperature which includes buzzer…when the temperature goes high the buzzer beeps… i am facing a issue in the output of the code …

This is the output IMG-20201023-WA0003|230x500

Code is

import conf, json, time, math, statistics
from boltiot import Sms, Bolt
def compute_bounds(history_data,frame_size,factor):
    if len(history_data)<frame_size :
        return None

    else:
        del history_data[0:len(history_data)-frame_size]
    Mn=statistics.mean(history_data)
    Variance=0
    for data in history_data :
        Variance += math.pow((data-Mn),2)
    Zn = factor * math.sqrt(Variance / frame_size)
    High_bound = history_data[frame_size-1]+Zn
    Low_bound = history_data[frame_size-1]-Zn
    return [High_bound,Low_bound]

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SSID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
history_data=[]

min_limit = 25
max_limit = 30

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(20)
        continue
    temp1 = int(data['value'])
    temp1 = (100*temp1)/1024
    print ("This is the value "+str(temp1))

    try:
        sensor_value = temp1
    except e:
        print("There was an error while parsing the response: ",e)
        continue

    bound = compute_bounds(history_data,conf.FRAME_SIZE,conf.MUL_FACTOR)
    if not bound:
        required_data_count=conf.FRAME_SIZE-len(history_data)
        print("Not enough data to compute Z-score. Need ",required_data_count," more data points")
        history_data.append(temp1)
        time.sleep(20)
        continue

while True:
    try:
        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(20)
            continue
        else:
            temp1 = int(data['value'])
            temp1 = (100*temp1)/1024
            print ("This is the value "+str(temp1))


        if sensor_value > bound[0] :
            print ("The temperature level increased suddenly!! \n Something is Burning up...\n Sending an SMS.")
            response = sms.send_sms("Alert!!! \n Chances of fire in the room... \n temperature detected " + str(sensor_value))
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
            history_data.append(sensor_value);

        if sensor_value > max_limit:
            print("temperature is High")
            print ("This is the value "+str(sensor_value))
            print("Turning on the buzzer \n or \n Already turned on")
            response1 = mybolt.digitalWrite('1', 'HIGH')
            print(response1)

        elif sensor_value < max_limit and sensor_value > min_limit:
            print("temperature is normal")
            print ("This is the value "+str(sensor_value))
            print("Turning off the buzzer \n or \n Already turned off")
            response1 = mybolt.digitalWrite('1', 'LOW')
            print(response1)

        else:
            print("It's too cold here!!! Get some warm Cloths... \n The Current temperature sensor value is " +str(sensor_value))

    except Exception as e:
        print ("Error",e)
    time.sleep(20)

Circuit diagram

As your shared screenshot …there is no error,the values goes 10 to 0 then there the temp values will be shown and buzzer beeps accordingly…just like that…

Yes but it 100 value doesn’t change … like yours changes to 65… etc and message from Twilio also is not coming…and temperature is not shown also[quote=“erinepereira27, post:3, topic:15459, full:true”]
Yes but it 100 value doesn’t change … like yours changes to 65… etc and message from Twilio also is not coming…and temperature is not shown also

@2019peb5400 pls answer

Hi @enid.fernandes14,

Check your sensor connection again. You will get the sms when the temperature values crosses the threshold.

Do let me know in case you need further assistance.

1 Like

I have checked the connections several times…from 3 days days I have been removing the circuit and doing it agian…

Do I have to change the temperature of the room

Pls answer sir @rahul.singh1

check your sensor again