Let us suppose you want to monitor any room on the basis of its temperature. If you want the temperature to regulate between some threshold values and also you want to detect if the flow of regulation breaks or we can say there is a sudden rise or fall in the temperature at any instant, this project is for you.
The main concept is sensing data using LM 35 temperature sensor, sending the data on cloud using Bolt wifi module, modulating the data and calculating Z-score threshold values, detecting any anomaly if the temperature crosses the threshold and sending an alert signal if the anomaly is detected.
Let us discuss in more detail.
This is LM 35
It has 3 terminals: Vcc, output and ground
This is Bolt wifi module
This is the Buzzer used for alerting the authorities in case of anomaly detection.
The positive side of buzzer is connected to '0' GPIO pin of wifi-module. The negative side is connected to ground of the module. The Vcc side of LM-35 is connected to 5V pin, Ouput side to 'A0' pin and ground side to ground of the module.
The complete circuit can be viewed from the cover photo of this project. Also we need to power the wifi-module using any power source like laptop, adapter or power bank.
Working: The LM-35 would first sense the temperature of the room to be monitored. Then Z-score threshold values would be calculated. Z-score threshold depend on the past values of the temperature values. It basically changes based on the trend of the past values. It is used to detect any sudden anomaly in the trend of any variable changing with time. If there is large and sudden rise or fall in the temperature values, I would get an alert by the sound of the buzzer. For sudden rise the buzzer would sound after 2 beeps. For sudden fall the buzzer would sound after 1 beep. Also if the temperature crosses the given minimum or maximum value, the buzzer would sound normally.
Now comes the coding part. Code can be viewed from the figure below.
Explanation: First we are importing libraries like boltiot to take reading from the wifi-module, json to convert into json (Javascript Object Notation) format etc. After that, declaration of api_key and deice_id of the module is done. Frame size and multiplication factor are used to calculate Z-score threshold values which is calculated in the function compute_bounds which returns the upper and lower Z-score threshold values. Min_Threshold and Max_Threshold are the min and max values of the allowed temperature in the room. After that response is being read from wifi-module. It is converted into json format in data variable. Z-score threshold values are calculated and stored in a list variable bound. Now I performed the 4 condition. Also there is pause of 8 seconds between any consecutive reading of the sensor.
Comments