Language used – Python (Machine Learning)
Information – Sending an Email using Mailgun services when temperature is not within the prescribed range. Sending an SMS when fridge is opened using Twilio services (Using Z-score Analysis i.e. when anomaly in temperature graph is detected.)
Steps :1) Connect the LM35 to the bolt Module· Hold the sensor in a manner such that you can read LM35 written on it.
· In this position, identify the pins of the sensor as VCC, Output and Gnd from your left to right.
· 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.
2) Creating a product on Bolt cloud to get the upper, lower
temperature limits of the Refrigerator
Save the code and click on exit.
Later link the product to the bolt module and deploy the configuration.
4) Let the module rest for about 2 hours and see the output.As you can see the sudden change is when the module is kept in the fridge.
From the graph it is clear that :
minimum_limit = 75 (in terms of sensor value)
maximum_limit = 35 (in terms of sensor value)
6) Writing python code on the terminal or any other virtual system
Note : You need a mailgun account before this step. In case you don't have one refer your bolt iot training for the same.
Login into the server by entering the IP address of your digital ocean droplet. If you have not used Digital Ocean droplet, you can directly login to your Virtual Machine via VirtualBox or VMWare.
After successful login, create a file named email_conf.py which will store all the credentials related to Mailgun. To create a new file type sudo nano email_conf.py in the terminal. After that write below code to
save all the credentials in a single file.
And save the file.
b)
Note : You need a twilio account before this step. In case you don't have one refer your bolt iot training for the same.
Login into the putty by entering the IP address of your digital ocean droplet.
After successful login, create a file named sms_conf.py which will store all the credentials related to Twilio. To create a new file type sudo nano sms_conf.py in the terminal. After that write below code to save all the credentials in a single file.
And save the file.
c)
Now create one more file named anomaly_detction.py, using the following command
Algorithm:
1) Fetch the latest sensor value from the Bolt device.
2) Store the sensor value in a list, that will be used for computing z-score.
3) Compute the z-score and upper and lower threshold bounds for normal and anomalous readings.
4) Check if the sensor reading is within the range for normal readings. i.e. no sudden increase in temperature
5) If it is not in range, send the mail.
6) Check if the sensor value is in the range specified in our min and max values.
7) If it is not in range, send the SMS.
8) Wait for 10 seconds.
9) Repeat from step 1
Comments