Applications of Soft Sensors: an experiment with Arduino and Dash
In my previous article, I introduced soft sensors and explained what they are and their advantages for industry 4.0. Furthermore, I also mentioned their use cases and applications. In this article, I will describe two different applications of soft sensors practically and how they can reduce downtime and maintenance costs for manufacturers. But, first of all, I would like to thank my colleagues, Mr. Constantin Dohr and Mr. Wilco van de Burgwal, who helped me prepare and run this experiment to do it in the best way.
I used Arduino UNO as the microcontroller for this experiment and Dash [1] to prepare a dashboard. This experiment has two parts; in the first part, we used the data fusion technique and then used its output to change the brightness of an LED. In the second part, we used a soft sensor as a backup solution for an intensity light sensor, which observes the brightness changes for a LED. Finally, I used python and Dash (Plotly) to develop a dashboard to monitor real-time measurement. This dashboard can show temperature, humidity, data fusion output, LED input, LED brightness, and soft sensor.
I ran the experiment for 24 hours and measured variables every 10 seconds. However, I should say that the primary goal of this experiment was not to control the changing of temperature or humidity for a long time; I just used this information as an input value for this experiment to show the different applications of the soft sensors. Therefore, I assumed that the condition of the room within a year is almost the same. For example, this assumption could be valid for a greenhouse. In the following sections, I will explain each part in detail.
Explanation of experiment
Part 1: Data fusion
The main goal of the first part of this experiment is to use temperature and humidity to change the brightness of the LED. For this part, I used a data fusion technique. Data fusion is a technique that integrates multiple data sources to produce more valuable and accurate information for other processes.
I used a DHT11 sensor to measure the temperature (°C) and humidity (%). Then, I used data fusion to have an output, which can be used for the LED. This method is very general to control the temperature inside a house or greenhouse [2]. For instance, it is implemented to control AC temperature. For the data fusion, I used fuzzy logic. Fuzzy logic is a method based on the degree of truth between 0 and 1, rather than classical logic, which offers 0 for false and 1 for true[3]. The following plots show the inputs and output of the fuzzy logic. For the fuzzy logic, I used skfuzzy library[4].
However, because I wanted to use the output of fuzzy logic as an input voltage for the LED and control its brightness in a wide range, I had to change the range of sensibility and desired output temperature. Hence, you can see a difference between this experiment and other experiments such as this article[2]. Moreover, I increased the output five times more, as Constantin offered to have more visible changes in the brightness of the LED.
The first two plots show humidity in percent and temperature in Celsius, respectively. As you can see, when the temperature and humidity are changed, the output of the fuzzy logic is changed too (third plot). This output is the input voltage of the LED. Sending this voltage to Arduino and record LED input causes a delay between the plot for data fusion and LED input. The last plot shows the measurement from the light sensor.
Part 2: Soft sensor
There are two main goals for this part; first, to show how a soft sensor can work as a backup solution for a real sensor, in case it is damaged or loses connection to the center, and second, to show how it can help to detect anomalies in the process. For our goal, the critical parameter is the LED brightness. It means we want to monitor its changes every 10 seconds, and these changes are crucial.
As mentioned before, I used temperature and humidity information as my input to change the LED brightness, and for monitoring it, I used the BH1750 light sensor. It is an almost sensitive sensor and showed a slight fluctuation in the output. The output of this sensor was my target to train a machine learning model for the soft sensor.
During the experiment, the temperature fluctuated between 20 °C to 25 °C, and the humidity changes were between 47% and 65%. I assumed these changes are always the same, which means it is independent of outdoor temperature and humidity.
After collecting data, I used it to train my machine learning model to prepare my soft sensor. Furthermore, I used MinMaxScaler[5] for normalization, XGBRegressor [6] for regression, and GridSearchCV [7] to select the best parameters from the listed hyperparameters for XGBoost. Finally, the best estimator is used as a core of the soft sensor.
Application of Soft sensors
Scenario 1: Backup solution for the damaged light sensor
Now assume for any reason, the light sensor (here BH1750) will be damaged, or it will lose its connection to the center or cloud in case of using IoT. As mentioned before, the changes in brightness are crucial for us. Then what can we do? Must we shut down our system until to buy and replace a new light sensor? How long does it take to replace a new sensor? If there would be no connection between sensor and cloud, how can we know about the current brightness?
Shutting down and waiting for replacing a new sensor means increasing downtime and maintenance costs. Both these two factors are crucial for any manufacturers. The solution is the soft sensor. Based on historical data, the soft sensor that I trained can estimate the current brightness based on temperature and humidity. It means it can work instead of the light sensor until we have a new sensor. Therefore, we can reduce the downtime and maintenance costs with the soft sensors.
For an IoT project, assume we monitor our system (here, the brightness of the LED) online via a cloud supplier. If there is no connection between the light sensor and cloud, then the soft sensor can again help us estimate the brightness based on the temperature and humidity.
Scenario 2: Anomaly in the process and backup solution
After preparing the soft sensors, I used an external light source to simulate an anomaly in the process. The maximum value of the luminosity of the sensor during the data taking was 128 lx. If you look at the following figure and compare the output of the light sensor (258 lx) and soft sensor (116 lx), immediately you can recognize that there is something wrong with the process.
However, you can confirm this issue with the trend of temperature and humidity too. Here the problem is because of the anomaly in the process. Now assume in a real scenario, and when we do not know about the source of the anomaly, then what can we do? Should we shut down the process to find out the source of the anomaly? How long does it take to solve the problem? If so, then it causes increasing downtime, and of course, maintenance costs too.
In this scenario, the soft sensor supports us to recognize any deviation in the output of the real sensor from the expected value based on the input data. It also helps us as a backup solution to show us the estimation of the LED brightness while finding the source of anomaly without unnecessarily shutting down the process.
Conclusion
As mentioned before, the main goal of this experiment is to show the application of soft sensors. I did this experiment with simple Arduino and sensors. However, we can extrapolate the concept and result of this experiment to industry. Reducing downtime and maintenance costs are two critical factors for any manufacturers. Many companies invest remarkable money to implement expensive sensors to control the manufacturing chain and reduce these two factors. But if something happens for sensors, it causes increasing downtime and maintenance costs. Hence, the soft sensor can support and help any company in this situation, and it was the main objective of this experiment that I did.
However, there are other applications for soft sensors. For example, in some chemistry processes, some measurements should be done in a lab, and no special sensor can do that in the real-time of the process. Therefore, based on these measurements from the lab and input data from the available sensors, we can develop a soft sensor, which estimates the output in real-time.
The last point that I would like to mention in this article is that I mentioned the condition of this experiment. For this experiment, I ignored the concept drift that could happen if we run this experiment for a long time. And this is the subject of my next article about the soft sensor.
If you have any questions or want to know how you can implement soft sensors in your business or company, you are most welcome to contact me.
[2] Febryan Hari Purwanto, Ema Utami, and Eko Pramono. “Design of Server Room Temperature and Humidity Control System using Fuzzy Logic Based on Microcontroller”, 978–1–5386–0954–5/18/$31.00 ©2018 IEEE. DOI: 10.1109/ICOIACT.2018.8350770
[3] J. S. R. Jang, C. T. Sun and E. Mizutani, “Neuro-Fuzzy and Soft Computing-A Computational Approach to Learning and Machine Intelligence [Book Review],” in IEEE Transactions on Automatic Control, vol. 42, no. 10, pp. 1482–1484, Oct. 1997, doi: 10.1109/TAC.1997.633847.
[4] https://pythonhosted.org/scikit-fuzzy/
[5] https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html
[6] https://xgboost.readthedocs.io/en/latest/index.html
[7] https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html