Let’s Imagine there is a pharmaceutical company, everything was going fine but suddenly some unwanted incident happened in pharmaceutical industry as a result government took some strong decision and asked companies to implement these rules immediately, failing to comply would lead to cancellation of the pharmaceutical production permit.
- Company have to maintain the temperature of the tablets withing limits.
- Also, the manufacturer should maintain a log of when the cooling chamber for the production of the tablets is opened.
Well there is a big issue to implement these rules for the companies, but let’s suppose you are in such situation where you have to implement such regulations, obviously we don’t have those such cooling cambers to maintain such low temperature but we have refrigerator.
So, we have some several tasks to do that:- Write the product code required to run the polynomial regression algorithm on the data sent by the Bolt. Using the prediction data, we are able to take early action, whenever the graph predicted that the temperature would be beyond thresholds.
- Keep the temperature monitoring circuit inside your fridge with the door of the fridge closed, and let the system record the temperature readings for about 2-3 hours.
- Write a python code which will fetch the temperature data, every 10 seconds, and send out telegram alert, if the temperature goes beyond the temperature thresholds.
- Modify the python code, to also do a Z-score analysis and send telegram alert “Someone opened fridge door” when an anomaly is detected.
Let’s do step by step, first step is to do connections with your Bolt module, here we are going to use LM-35 sensor, which are best for such objectives.
- Step 1: Hold the sensor in a manner such that you can read LM-35 written on it.
- Step 2: In this position, identify the pins of the sensor as VCC, Output and GND from your left to right.
- Step 3: Now connect VCC : 5V, Output : ‘A0’ pin, GND : Ground.
- Set these codes for polynomial regression and save.
Now Link this to your Bolt and deploy configuration.
- Now connect your Bolt with a power-bank and place it inside the fridge.
- Initially we do not have much values so our device page would look something like this.
Now we have to wait for some time like around 2-3 hours for good amount of data for better predictions.
After getting enough data we can view device page for tuning the parameters for predictions.
Tune the parameters such that predicted line best fits the original line.
- First let’s import all the libraries and set credentials that are required in this code.
- Let’s define functions that we are going to use later.
In the above code we calculated the Z-score value and given the boundries for anomaly.
- Now start the coding part, we are going to run the infinite loop so that it can get continuous data after every certain interval.
Make sure to convert returned temperature value into Celsius.
Here we are giving sleep timer for 5 sec which means this loop will repeat itself after every 5 sec.
For calculating Z-score first it will take 10 values in that period, code will not give any alerts, to get alerts you have to wait for calculating Z-score value and it’s boundries, after that if any anomaly happens or value crosses the thresholds then you will get a telegram alert like this.
Comments
Please log in or sign up to comment.