Archishman Chattopadhyay
Created March 22, 2019

Anomaly detection in Temparature Monotoring system

Here in this project we are interested on anomaly detection on temparature reading and sending alert when it goes beyond the threshold.

BeginnerProtip3 hours56
Anomaly detection in Temparature Monotoring system

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

Ubuntu
SMS Messaging API
Twilio SMS Messaging API
Virtual Box

Story

Read more

Schematics

Bolt Iot module

Temparature sensor connection with Bolt module

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.

Circuit connection

Ubuntu VB outout of Temparature monitoring

When it lies within the threshold it accepts next value and when it crosses it requests twilio send a messege as alert.

Twilio Output

Getting messege as an alert

Code

conf.py

Python
This will held all the credentials generated on twilio account and Bolt unique API for performing project.
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' 

test_sms.py

Python
This will execute the main function and detect if there any anomaly and send a alarm messege over Twilio account.
import conf
from boltiot import Sms, Bolt
import json, time

minimum_limit = 300
maximum_limit = 600  


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 or sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("The Current temperature sensor value is " +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

Archishman Chattopadhyay

Archishman Chattopadhyay

1 project • 0 followers
Thanks to BOLT IOT.

Comments