# Data-Driven and Machine-Learning-Based Real-Time Viscosity Measurement Using a Compliant Mechanism
## 6 Conclusions  
This work proposes a new system for viscosity measurements which comprises a compliant mechanism, an electromagnetic actuator, and a piezoelectric sensor. The compliant mechanism used in the mechanical structure is designed for the necessary directional stiffness and is subject to vibrations from the micro-motor. The piezoelectric sensor is used for vibration measurement. During the sensor's operation, the vibrating structure makes contact with the fluid whose viscosity is to be measured. The viscosity of the fluid affects the vibrations in the mechanical structure, and these vibrations are measured to estimate the fluid's viscosity. Experiments were conducted on a prototype, and NI Lab View hardware and software were used for the sensor data acquisition and analysis. A series of viscosity measurements was carried out within 10-60 cP viscosity fluids. Later, the sensor data were used to train several ML models to facilitate the estimation of the fluid viscosity from the piezoelectric sensor's output. The present study obtained an \(R^{2}\) value of 0.99 with the use of the regression ML model, which is higher than that of the existing devices reported in the literature. The accuracy and effectiveness of the proposed system were validated by comparing several common fluids' viscosity values as determined using the proposed method and a standard Ostwald viscometer, where the proposed method used an MLR model for the estimation of the viscosity values. The present methodology with the compliant mechanism, the micro-actuator, and the piezoelectric sensor can be used to measure density and thickening effects and detect the presence of solid particles in liquid.  
Conceptualization, N.V.S., P.M., A.M.B., K.G.K., K.M.U., G.D.K., J.V.T., J.I. and K.K.; methodology, N.V.S., P.M., A.M.B., K.G.K., K.M.U., G.D.K., J.V.T., J.I. and K.K.; software, P.M., A.M.B. and K.M.U.; validation, N.V.S., P.M., A.M.B., K.G.K., J.V.T. and J.I.; formal analysis, N.V.S., P.M., A.M.B. and G.D.K.; investigation, N.V.S., P.M., A.M.B., K.G.K. and K.M.U.; resources,  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Fluid** & **MLR Viscosity (cP)** & **Ostwald Viscometer Viscosity (cP)** \\ \hline Vegetable oil & 50.00 & 50.01 \\ White vinegar & 20.00 & 20.50 \\ Sugar and water syrup & 40.00 & 40.20 \\ Lemon juice & 10.00 & 10.01 \\ Chocolate syrup & 50.00 & 49.60 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Comparison of viscosity measurements using MLR model and Ostwald viscometer.  
P.M., A.M.B. and G.D.K.; data curation, P.M., A.M.B. and K.G.K.; writing--original draft preparation, N.V.S., P.M. and K.G.K.; writing--review and editing, J.I. and K.K.K.; visualization, P.M., K.M.U. and J.V.T.; supervision, N.V.S., J.I. and K.K.K.; project administration, J.I. and N.V.S.; funding acquisition, J.I. and K.K.K. All authors have read and agreed to the published version of the manuscript.  
The article processing charge (APC) was paid by the AGH University of Krakow, Poland, as its own contribution to the INNOGLOBO/InnoIndie project \"System for monitoring the conditions of transport of sensitive materials, including food and hazardous materials\" (INNOGLOBO/I/132/InnoIndie/2022).  
Not applicable.  
The data will be made available upon reasonable request.  
The authors would like to thank the National Centre for Research and Development (NCBR) for its financial support of this research, carried out within the framework of the INNOGLOBO/InnoIndie project \"System for monitoring the conditions of transport of sensitive materials, including food and hazardous materials\" (INNOGLOBO/I/132/InnoIndie/2022).  
The authors declare no conflicts of interest.