Three-Dimensionally Printed Sensors with Piezo-Actuators and Deep Learning for Biofuel Density and Viscosity Estimation
Víctor Corsino, Víctor Ruiz-Díez, Andrei Braic, José Luis Sánchez-Rojas

TL;DR
A new 3D-printed sensor system with AI is developed to accurately measure biofuel density and viscosity, offering a compact and precise solution for industrial use.
Contribution
Integration of 3D-printed sensors, piezo-actuators, and deep learning for precise biofuel property estimation.
Findings
The system achieves low calibration and resolution errors for viscosity and density measurements.
Algorithmic methods improve sensor lifespan and reduce data acquisition time.
The device is compact, precise, and suitable for various industrial liquids.
Abstract
What are the main findings? A novel device integrating 3D-printed sensors with convolutional neural networks for biofuel characterization.Development of sensor optimization strategies and spectral data processing techniques. A novel device integrating 3D-printed sensors with convolutional neural networks for biofuel characterization. Development of sensor optimization strategies and spectral data processing techniques. What are the implications of the main findings? Successful integration of multiple technologies into a compact, lightweight and highly precise instrument.Providing solutions to typical sensor limitations such as resolution, sensitivity and drift. Successful integration of multiple technologies into a compact, lightweight and highly precise instrument. Providing solutions to typical sensor limitations such as resolution, sensitivity and drift. Biofuels have emerged…
Click any figure to enlarge with its caption.
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11- —Universidad de Castilla-La Mancha
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Sensor and Energy Harvesting Materials · Advanced Chemical Sensor Technologies · 3D Printing in Biomedical Research
1. Introduction
The development of sensor devices for controlling the viscosity and density of biofuels has gained considerable importance due to the increasing demand for fuels, their diverse applications and the need to reduce emissions. Although biofuels are generally environmentally favorable, they can lead to elevated emissions or suboptimal engine performance if their viscosity and density are not properly controlled [1,2,3,4]. Numerous studies have explored sensor technologies for monitoring the physical properties of fuels, biofuels and engine oils [3,4,5,6,7,8,9,10,11,12]. More recently, artificial intelligence has become a powerful complement to microsensor technologies, enabling advanced compositional analysis of fuel–lubricant and biofuel mixtures [13,14,15,16]. Nevertheless, many of these approaches rely on expensive instrumentation and complex electronic architectures, which restricts their practical deployment.
To address this limitation, our recent work [17] presented a compact, integrated sensing device. While effective, this design (like other approaches reported previously [4,5,6,7]) relies on conventional fabrication techniques such as lithography and thin-film deposition for sensor production. In contrast, three-dimensional (3D) printing offers a cost-effective and highly precise alternative, positioning it as a promising method for sensor manufacturing. In this context, numerous studies have explored the application of 3D printing technologies in the fabrication of piezoelectric sensors. For instance, in [18,19,20,21,22], the authors employed polyvinylidene fluoride (PVDF) polymers and their copolymers to develop piezoelectric devices for various sensing applications. These include pressure and force sensors tested under controlled laboratory conditions [18,20], acoustic receivers [21], flow sensors for deionized water, mimicking blood flow [19], and tactile sensors embedded in prosthetic hands capable of identifying object hardness [22]. In [23,24], the authors designed micromachined piezoelectric ultrasonic transducers (PMUTs) using PZT sheets mounted on titanium substrates. These were integrated with Helmholtz resonators, featuring 3D-printed cavities of controllable volume to monitor human respiratory patterns. Additional approaches include the use of photopolymer resins mixed with PZT particles to fabricate ultrasonic wave sensors [25], as well as the development of piezoresistive MEMS accelerometers via 3D printing for controlled experimental use [26].
A particularly active area of research involves 3D-printed sensors for liquid analysis, addressed in various studies [27,28,29,30,31]. These works leverage additive manufacturing to produce complete sensor assemblies, fluidic cavities or microfluidic channels. Sensor modalities include substrate-integrated waveguide (SIW)-based designs [27,32,33], microwave resonators [28,30,31,34,35], parallel plate configurations [29], optical interferometers [36], and electromagnetic bandgap (EBG) microstrip sensors [37]. These systems enable the differentiation of liquid compositions by measuring dielectric permittivity or transmission spectra. Applications span petroleum monitoring [35]; aqueous mixtures with water–ethanol blends [27,28,29,30,31] and solutions containing isopropanol [32], glucose [36] or potassium chloride [29]; toluene–methanol mixtures [37]; and various pure chemicals [30,31,33,34,37]. All the aforementioned studies used laboratory instrumentation in their measurement process.
Recent advancements have also integrated machine learning techniques with 3D-printed sensor systems. For example, in [38], the authors developed a deformation-sensitive sensor composed of graphene nanoparticles and carbon nanotubes, employing support vector machines (SVMs) to classify human motion and monitor exhalation; the researchers in [39] applied neural networks to optimize the design of a 3D-printed accelerometer for human movement tracking, while in [40], they fabricated three-axis force sensors and trained a support vector regression (SVR) model on simulated data to quantify forces in medical contexts; and finally, the work in [41] combined multi-sensor 3D printing with machine learning algorithms to predict behavioral impairment following alcohol consumption.
In previous studies such as [42,43], we introduced a 3D-printed sensing cell incorporating piezoelectric actuators, designed to vibrate at a specific resonance, and artificial intelligence (AI) techniques to characterize the physical properties of aqueous glycerin solutions. In the present work, we propose an enhanced version of this type of sensor, designed to broaden its operational bandwidth and improve calibration and resolution results. Furthermore, we integrate the sensor into a microcontroller-based system equipped with convolutional neural networks (CNNs), targeting the application of biofuel characterization.
This article is structured as follows: The Section 2 details the sensor design, geometric parameters, simulation procedures, structural optimization criteria, complete device schematics, experimental methodology, data processing techniques and machine learning algorithms studied. The Section 3 presents optimal sensor geometries identified in real-world applications, experimental data captured with our system from biofuel solutions and the architecture of the most effective AI models, as well as their precision obtained in calibration and from drift experiments, using dimensionality reduction, compared to reference values. In the Section 4, we contextualize our findings within the existing literature and outline potential future research directions. Finally, we conclude with the key contributions and implications of this work.
2. Materials and Methods
2.1. Comparative Analysis of Sensor Structure and Actuator Layouts
The fundamental architecture of the developed sensor is illustrated in Figure 1. The device comprises two integrated components, forming a unified system. The first part consists of a semi-cylindrical container cell designed to hold the target liquid. This cell features a vibrating membrane at its base and lateral connectors to facilitate fluid circulation. It was fabricated via stereolithography (SLA) 3D printing technology [44] using a Form3 printer (Formlabs Inc., Somerville, MA, USA) [44] and Rigid10K resin (Formlabs Inc., Somerville, MA, USA) [45], a material validated in previous studies [42,43] for its mechanical robustness (Young’s modulus = 10 GPa). According to manufacturer specifications [45], this resin also demonstrates good chemical resistance against fuel exposure, exhibiting only a 0.1% weight increase after 24 h when a sample structure is immersed in diesel. Key printing parameters, including dimensional tolerance, resolution, printing speed and ultraviolet (UV) light exposure duration, were controlled throughout the manufacturing process. The printed cell was then subjected to an oxygen plasma treatment to improve surface wettability. This process was conducted for 2 min at 50 W plasma power and 0.2 mBar oxygen pressure within a vacuum chamber equipped with a radiofrequency plasma generator (Diener electronic GmbH + Co. KG, Ebhausen, Germany) [46].
The second component comprised the piezoelectric actuators. Commercially available PZT sheets (PIC255, type 5A modified lead zirconate titanate, PI Ceramic GmbH, Lederhose, Germany [47]), 100 microns thick, with top and bottom CuNi metallization and a stiffness of 63 GPa, were manually sectioned and placed on the external surface of the cell membrane using a cyanoacrylate-based contact adhesive Loctite^®^ 401 (Henkel, Düsseldorf, Germany) [48]. This configuration ensured isolation of the piezoelectric ceramics from the diesel medium, preventing potential chemical degradation. The adhesive selection was validated by previous comparative studies, which revealed negligible performance variation across different cyanoacrylate formulations, attributed to the minimal adhesive layer thickness employed and its relatively low stiffness compared to the other structural components of the sensor.
We assessed the fabrication quality and surface morphology by measuring the roughness of both the 3D-printed part and the PZT films using a Wyko NT1100 optical profiler (VEECO, Plainview, NY, USA) [49]. The results are presented in Figure 2. The gap between the PZT and resin was filled with adhesive, forming an ideally uniform and elastic multilayer. Regarding the resin surface in contact with the liquid, its roughness may affect resonance behavior depending on its relative magnitude compared to the acoustic boundary layer thickness, as discussed in [50]. For diesel fuel, the acoustic boundary layer thickness across the relevant resonance range (10–600 kHz) varies from approximately 10 μm to 1 μm. Although the resin surface can be considered relatively smooth compared to this scale, minor effects were expected and considered part of the sensing capability of the devices.
To establish electrical connectivity, 100 μm Cu wires were soldered to each end of the piezoelectric patches. The opposite ends of the wires were connected to pins embedded in elastomeric plastic tubing for mechanical isolation. The integrity of the solder joints was verified by analyzing the impedance spectrum of the patches across a frequency range up to 1 MHz using an Agilent^®^ 4294A impedance analyzer (Keysight, Santa Rosa, CA, USA) [51]. These elastomer-coated pins were subsequently inserted into the cell’s side connector protrusions, yielding a compact assembly and minimizing the influence of unwanted variable mechanical coupling caused by the introduction of the cell into a ZIF socket interface for electronic connection. While fabrication tolerances may influence the final electromechanical response, each device was individually characterized and calibrated.
The sensors manufactured following the described procedure operate as follows: Excitation of the actuation piezoelectric plates by a periodic signal induces structural vibrations. These perturbations are modulated by the physical properties of the surrounding fluid [52,53], as density contributes to added mass while viscosity increases damping. Consequently, the spectra read at the detection ports exhibit shifts in their resonant frequencies depending on the density variations between different liquids. Moreover, changes in viscosity modify the quality factor of the peaks, and therefore their amplitude and bandwidth. By applying machine learning techniques, correlations between these vibrational responses and the fluid properties can be systematically established.
An additional key consideration is the structural optimization aimed at achieving multimodal responses. This process was divided into two primary components: the piezoelectric plates and the fluidic cell. The optimization of patch configurations was assisted by finite element simulations in COMSOL^®^ Multiphysics 6.3 [54], enabling a comparative analysis of different actuator layouts based on their spectral response. In contrast, the design of the fluidic cell geometry was addressed experimentally due to the complexity of incorporating full three-dimensional fluid–structure interaction in the model. Multiple prototypes were fabricated and tested under controlled conditions, applying a performance metric focused on resonance amplitude, repeatability and sensitivity to fluid changes to identify the most suitable architectures.
The geometry and quantity of piezoelectric films play a critical role in sensor design, as these components, being the most rigid elements, exert a dominant influence on the device’s response. Although simultaneous optimization of the host structure and patch geometry could be addressed as described in [55], this work focuses on a simpler approach: a computational evaluation comparing various actuator configurations to identify the optimal designs. To facilitate this analysis, a simplified cell model was developed using COMSOL. Mechanical and electrical boundary conditions were accurately defined, while non-essential geometric features such as side connectors were excluded due to their lesser impact on the sensor’s dynamic behavior. A mesh-convergence study was performed to ensure that the finite element results were independent of mesh density while maintaining computational efficiency. Additionally, fluid–structure interactions were omitted to streamline the simulation within a three-dimensional framework. Figure 3 illustrates the piezoelectric patch configurations analyzed using this approach. Performance assessment was based on the voltage amplitude spectrum within the frequency range of 1 kHz to 1 MHz. The optimization criterion aimed to maximize both the number and amplitude of resonance peaks in the spectra as these serve as sources of sensor data related to the target liquid [56]. The simulation results indicated that geometries 1 and 6–8 yielded suboptimal spectral profiles. Complementing this analysis, we conducted natural frequency simulations of the standard cell model either with a single piezoelectric sheet on its membrane or with two patches aligned along the vertical axis. In-plane stress values were averaged across all modal shapes to identify regions of maximum and minimum mechanical deformation, thereby revealing zones of enhanced piezoelectric coupling efficiency and enabling the strategic placement of structural elements to support multiple modal responses. The resulting distribution, shown in Figure 4, demonstrates that the superposition of modes within the studied frequency range generated low-stress regions at the mid-width and mid-length of the structures, while concentrating effective actuation and sensing areas in the quadrants. This observation justifies the placement of patches according to the proposed arrangement (configurations 3, 9 and 10), further reinforcing previous conclusions. Based on the combined outcomes of both studies, fabrication efforts were focused on configurations 2–4 and 9–10, which are also depicted in the sensor schematic in Figure 1, with the possible cutouts of actuators highlighted by a black mesh in the plan view.
The other key component is the fluidic cell. As previously outlined, one objective of this study was to develop a sensor capable of producing spectra characterized by a high number of resonances with high amplitude in a certain frequency range. However, these spectral features must also exhibit sensitivity to fluid changes, maintain repeatability across measurements to attain good resolution and demonstrate recovery upon reintroduction of the reference fluid. To achieve this, we experimented with the geometric parameters depicted in Figure 1. Sensors were fabricated using parameter combinations within the ranges specified in Table 1. Iterative adjustments were made based on comparative performance, with superior parameter values informing the design of subsequent prototypes. This approach enabled progressive refinement of sensor architecture.
The method for optimizing the cell structure consisted of the following experimental procedure. A sensor fabricated with a given set of geometric parameters was subjected to two fluids via a peristaltic pump: one comprising pure diesel fuel, and the other consisting of a 90:10 volumetric mixture of diesel and commercial sunflower oil. Starting with pure diesel, spectral data were acquired using an Analog Discovery 2 instrument (Digilent co NI, Austin, TX, USA) [57] across a frequency range of 1 kHz to 1 MHz, discretized into 800 points. A sinusoidal input signal of 3.3 V was applied, preceded by a brief stabilization period to ensure fluid equilibrium. For each frequency point, measurements were performed over at least 10 signal periods and were averaged to improve data robustness. Two spectra were recorded with a time interval of 5 min between successive acquisitions. Subsequently, the pure diesel was replaced with the adulterated mixture, using no further cleaning other than the entrainment effect of the new solution. The same measurement protocol was repeated, and finally, the system was flushed with pure diesel once more, and the measurement cycle was repeated. All measurements were conducted under static fluid conditions at room temperature (22 ± 1 °C).
This experimental framework enables the evaluation of three key performance metrics: sensitivity, reproducibility and recovery. These were quantified as absolute differences between spectra of different solutions ( ); spectra of different consecutive measurements corresponding to the same solution ( ); and spectra of the same fluid measured before and after exposure to a different fluid ( ). The expression denotes the spectrum corresponding to measurement i of liquid j (either pure diesel or the adulterated mixture). In our case, the index i was restricted to , as only two resolution measurements were conducted at each step, thereby conditioning the mathematical definition of the three key metrics. Nevertheless, additional measurements could be incorporated with the same definitions applied iteratively and considering either the maximum or the average across operations. Furthermore, the inclusion of the absolute value in the metric expressions ensures insensitivity to the order in which the two liquids are compared. A higher sensitivity is desirable, indicating strong differentiation between fluid types, whereas elevated differentiation in resolution or recovery is undesirable, as it reflects inconsistency in repeated measurements of the same fluid.
Based on these definitions, to determine whether greater sensitivity ‘compensates’ for poorer resolution and recovery at each spectral point i, we propose the following equation. The following formulation also serves as a dimensionality reduction strategy for subsequent analysis:
where “max” denotes the greatest difference, corresponding to the worst result between resolution and recovery. To quantify the relative performance of each cell, two metrics are proposed: the first uses Equation (1) to compute m over all points of the spectrum and , while the second uses only the points where sensitivity compensates for resolution/recovery ( ) and . Then, in both cases, the mean value across all spectral points is calculated and sensors with higher values of m are considered the best.
2.2. System Description and Calibration–Drift Experiments
Here we present the architecture of the measurement system designed to operate the sensors optimized using the method described in the preceding subsection, together with the experimental protocol implemented for calibration and drift assessment.
The highest-performing sensors were integrated into a measurement system analogous to that depicted in Figure 5, previously introduced in [56] for MEMS-based detection of adulterants in olive oil. In addition to the sensor element, the system comprised electronic interfacing circuits designed to operate with an ESP32-S3-DevKitC-1-N32R8V microcontroller (Espressif Systems Co., Ltd., Shanghai, China) [58]. Fluid samples were introduced into the sensor at their maximum flow rate using a Minipuls 3 peristaltic pump (Gilson Inc., Middleton, WI, USA) [59]. A transistor-based circuit was employed to amplify the Pulse Width Modulation (PWM) signal generated by the microcontroller, which served to excite the sensor’s input actuator patch(es). The PWM frequency was swept from 0.05 to 1 MHz, yielding 530 discrete frequency spectra. A variable frequency step was used to account for the microcontroller’s limited frequency resolution. The sensor’s output signal was further amplified via a bipolar junction transistor (BJT) biasing circuit incorporating emitter and collector feedback to improve DC stability at the operating point. This amplified signal was processed by an envelope detector, also implemented using a discrete transistor circuit, and captured via the microcontroller’s analog-to-digital converter (ADC). For each excitation frequency, 1000 output samples were acquired, each comprising 10 response periods. Averaging across these samples improved data robustness. All electronic components were powered using the 5 V supply provided by the microcontroller.
The measurement procedure was repeated for each of the biodiesel solutions listed in Table 2. These solutions were prepared by blending commercial diesel fuel with sunflower oil in proportions consistent with those reported in the literature and compliant with European regulatory standards [2]. This table contains the physical properties of the fluids, determined by averaging three measurements obtained using a commercial DMA4100M densitometer equipped with a Lovis module (Anton Paar GmbH, Graz, Austria) [60], maintained at 40 °C. We can observe that both viscosity and density increase nearly monotonically with oil content, although with distinct slopes, thereby supporting their treatment as independent variables in AI models. Even minor compositional changes in certain mixtures lead to measurable variations in viscosity and/or density, influenced by factors such as mixture tolerances, temperature effects and the non-linear scaling of these properties with oil percentage at low adulteration levels.
Samples were introduced into the system in ascending order of viscosity. For each fluid, measurements were conducted under static conditions following a stabilization period of 5–15 min, and subsequently, 33 spectra were collected over approximately 10 min. When changing the fluid, the sensor was flushed with the incoming fluid for 3 min without any additional cleaning protocol. All measurements were performed without active temperature control of the resonator; the ambient temperature during the experiments was maintained at 23 ± 1 °C. The measurement system operated in real time and did not require opening of the fluidic circuit. We experimented by acquiring measurements under both continuous-flow and static conditions and examining the evolution of the spectral response across consecutive acquisitions, which exhibited reduced variability when the fluid was at rest. Furthermore, the experiment was repeated using solutions , , and over a period of four days to assess whether spectral variations arising from short-term temporal drift could be mitigated through data processing and AI techniques.
2.3. Deep Learning Algorithm Optimization
Following the acquisition of spectral data from all the prepared solutions, machine learning models were constructed to establish predictive relationships between the spectra and the corresponding physical properties of the fluids. As demonstrated in our previous studies [17,43,56], convolutional neural networks exhibited strong performance in the analysis and interpretation of spectral signals. The procedures employed to identify network architectures best suited to our data, together with the spectral drift compensation and dimensionality reduction strategies implemented, are detailed below.
The first step involved defining the data sets and applying appropriate scaling. Mixtures labeled were designated as the training set, whereas mixtures labeled were reserved exclusively for testing and were not used during parameter optimization. Prior to training, the data were preprocessed using a scaling method based on the standard deviation. Following this process, optimization of the neural network architecture was undertaken. To identify the best network configurations that improve predictive accuracy, we applied a hyperparameter fine-tuning strategy analogous to that used in [17,56]. Specifically, we varied the number of convolutional layers (up to five), the number of filters, their size and their stride. The tested parameter values are illustrated in Table 3, which summarizes the general architecture of the evaluated models. The filters and their associated parameters define distinct mechanisms for spectral feature extraction. The ReLU activation function was employed to facilitate gradient-based optimization via the Adam algorithm [61], which was proven effective in CNN training. Learning rates ranging from 0.01 to 0.001 were explored to minimize the mean squared error loss function. To control model complexity, we incorporated either high stride values or max-pooling layers, which performed local subsampling by selecting the maximum value within a defined neighborhood. Following the final convolutional block, an average pooling layer was applied to reduce dimensionality, thereby removing the need for a flattening operation and fully connected layers. This design choice was critical, as the latter approach introduces additional parameters and computational overhead, which are incompatible with the constraints of microcontroller deployment. The network ended with a single output neuron using a linear activation function to predict the target physical properties, such as viscosity and density. To identify the most effective model architecture, a comparative evaluation was conducted by quantifying the prediction error. This error was computed as the arithmetic mean of the absolute differences between the model-predicted values of viscosity or density and the corresponding reference values obtained from the commercial laboratory-grade viscometer. This approach enabled the selection of the network configuration that yielded the highest predictive accuracy. All models were implemented and trained using TensorFlow 2.17 [62].
The models were subsequently evaluated using data obtained from drift experiments. To simulate realistic operating conditions, liquid was selected as the reference fluid for measurements on different days. We employed this liquid as a reference because it constitutes a representative solution of the problem under study, namely biodiesels derived from mixtures of conventional diesel and sunflower oil, and it exhibits a comparatively low viscosity relative to other biofuels in our dataset, thereby enabling more efficient removal during the circulation of subsequent liquids to be measured. Following the measurement protocol described earlier, the mean spectrum was calculated from repeated measurements. The ratio between the average spectrum of the reference solution on the initial day (day 0) and that obtained on day n was then determined. This ratio defines a spectral factor , which encodes the relative variations in sensor response between day 0 and day n across all spectral components, each of which may evolve differently over time. The factor was then employed to adjust the spectra of subsequent solutions. Specifically, the adjustment consisted of multiplying the measured spectrum of a given solution by , thereby approximating a transformation of the data from day n to day 0. The corrected spectrum was then reintroduced as input to the trained machine learning models, yielding more accurate predictions of viscosity and density compared to unprocessed spectra. In this way, the operational lifespan of both the sensor and the overall system can be extended simply by using one single unique calibration solution as reference.
In addition, a dimensionality reduction study was conducted as follows. Using Equation (1) as a basis, the number of spectral points was progressively reduced, thereby decreasing measurement time while simultaneously evaluating the impact on neural network training and performance in both calibration and drift experiments.
It is important to note that the models were trained externally and subsequently deployed on the microcontroller via the TensorFlow Lite library, enabling a fully autonomous viscosity and density estimation system. This machine learning framework not only enhanced system autonomy but also simplified the electronic requirements for signal processing because any spurious effect originating from the parasitic elements of the resonator or the electronics remained constant across all measurements, so they could be learned and disregarded by the machine learning models.
3. Results
This section applies the previously defined performance metric to evaluate and compare 64 sensor geometries fabricated during the design refinement process. It presents representative examples illustrating how the criterion guided structural selection, summarizes the final geometric parameters and discusses the influence of piezoelectric patch distribution and fluidic cell features on overall sensor performance.
In addition, we describe the outcomes of the calibration and drift experiments performed with the optimized sensor integrated into the microcontroller-based system. These results include spectral measurements for all prepared solutions, the predictive performance of the CNN models for viscosity and density estimation, and their comparison with laboratory references. This section also examines the correction of temporal drift and explores dimensionality reduction as a means to accelerate measurements while preserving accuracy and enabling efficient deployment on resource-constrained hardware.
3.1. Optimization of the Sensor Structure
As described in Section 2, we employed a systematic approach to refine the geometry of the liquid-containing cell, guided by Equation (1) and the measurement protocol described in the corresponding subsection. According to this equation, spectral points yielding values greater than 1 are considered positive, as they indicate that the sensor’s sensitivity exceeds its limitations in resolution or recovery. Conversely, values below 1 are regarded as negative, since insufficient resolution or recovery cannot be distinguished from spectral variations induced by changes in the liquid. In total, 64 combinations of geometric parameters were designed, fabricated and tested. Figure 6 illustrates the application of the optimization method to two representative geometries: one of larger dimensions without fins (left), and another of a smaller scale incorporating membrane extensions (right). In the following figure, green lines indicate cases where , while red lines correspond to , enabling refinement of the cell structure based on this criterion.
Figure 7 presents the normalized results for sensitivity, resolution, recovery and the two measurements based on the m metric ( : computed using all spectral points with ; and : computed using only the points for which sensitivity compensates for resolution/recovery, i.e., , with ) for the different sensor geometries evaluated. Higher sensitivity and m values, together with lower resolution and recovery errors, indicate superior performance. The five best-performing geometries for each metric are highlighted in blue in Figure 7, and Table 4 summarizes the geometric parameter ranges associated with these top-ranked designs. From these results, the following conclusions can be drawn:
In general, miniaturization of the cell and its patches yielded improved resolution and recovery, resulting in higher m metric values.When the cell membrane was fully covered by piezoelectric actuators, the addition of fins produced inferior results compared to an empty configuration. Conversely, when the actuators were reduced in size such that half of the membrane remained uncovered, the presence of fins substantially enhanced the m metrics relative to a hollow cell.A comparable improvement was observed when the membrane thickness was reduced. However, combining fin addition with reduced membrane thickness led to overall poorer performance, as each factor independently increased variability in the printing process, and their simultaneous application amplified this variability. Accordingly, a thicker membrane proved more suitable when fins were incorporated, providing leverage between peak amplitude and manufacturing resolution.The optimal fin configuration consisted of one fin per quadrant of the cell (i.e., a 2 × 2 array). Increasing the number of cilia along either axis degraded performance.A reduced arrangement (1 × 2) produced comparable results only when the cilia were positioned within quadrants.Theoretically, a greater height of the fins increases fluid–structure interaction but maintains a free end so they can move more freely.While complete coverage of the membrane with four piezoelectric patches increases sensitivity, it simultaneously degrades resolution and recovery, significantly worsening the m metric values, likely due to multiplied defects introduced during fabrication and gluing of the patches.
It should be emphasized that these conclusions are constrained by inherent imperfections in the sensor’s fabrication. Manufacturing processes introduce additional sources of variability, including cell curing, resin evacuation, patch cutting and non-uniform adhesion. Therefore, the findings presented here should be regarded as design guidelines rather than definitive optimization criteria.
Figure 8 and Table 4, “best” present the outcomes of these structural refinement techniques. Regarding patch components, both vertical and horizontal divisions were observed, as described earlier. For the fluidic cell, a compact design incorporating four internal fins, one per rectangular quadrant, proved sufficient to achieve good results across the three defined metrics while minimizing material requirements. Notably, alternative models based on this geometry, such as those with a 0.2 mm membrane or without fins, also performed well experimentally. These designs also expanded the range of significant frequencies relative to our previous works [42,43] and increased the freedom of vibration, resulting in a more informative spectral response.
3.2. Calibration and Drift Experiments
The sensor depicted in Figure 8 was integrated into the microcontroller system illustrated in Figure 5. Subsequently, experiments were conducted to measure the solutions listed in Table 2, following the protocol described in Section 2.2. A total of 363 spectra were acquired, as shown in Figure 9a. The spectra exhibit several resonance peaks that are sensitive to variations in fluid properties. As discussed earlier, progressive increases in viscosity and density alter the damping and added mass, respectively, leading to gradual modifications in both the amplitude and shape of these resonances and thereby improving spectral separability between solutions. The zoomed-out view on the left of the figure illustrates how one of these peaks changes for two liquids with markedly different viscosities. Notably, viscosity and density perturb each peak in distinct ways, resulting in complex spectral behavior that conventional analytical methods cannot adequately capture. In contrast, CNNs statistically integrate all these coupled physical effects by leveraging the full multimodal spectrum, enabling a more comprehensive and robust interpretation of the sensor response.
Based on these data, convolutional neural networks were trained to predict viscosity and density using the optimization procedure explained in Section 2.3. The solutions labeled N in Table 2 served as training data, while the remaining fluid measurements were reserved for testing, thereby assessing the model’s generalization performance. The optimal network architectures identified for both viscosity and density estimation follows the configuration shown in Figure 9b. This architecture comprises three convolutional layers with 8, 16 and 32 filters, respectively, each with a kernel size of 5 and a stride of 5, without intermediate max-pooling layers. The network concludes with a global average pooling layer and a dense output layer containing a single neuron, and training was performed with a batch size of 55 over 200 epochs. The models occupied 500 kB, using 41% of the microcontroller’s program storage space. The measurement time for a complete spectrum was 16 s, but once taken, the estimation of the physical properties models was completed in milliseconds.
Figure 10a,b present the results obtained with our predictive models in comparison with the laboratory instrument. In Figure 10a, the red boxes denote viscosity predictions for the training solutions (N), the blue boxes correspond to the test solutions (T) and the green dots indicate the reference values measured with the commercial viscometer. Similarly, Figure 10b shows the density predictions, where the green boxes represent the training set, the orange boxes the test set and the blue dots the reference measurements. For viscosity, the system successfully distinguished between pure diesel and a mixture containing 1% sunflower oil; however, minor adulterations remained undetectable, as evidenced by the overlap of boxplot extremes. The density predictions were also very accurate.
To further evaluate system robustness, we repeated the measurement procedure described in Section 2.2 for fluids , , and over four consecutive days. This experiment enabled the development of an algorithmic approach to extend sensor lifespan. Specifically, the previously trained models were combined with the drift correction method explained in Section 2.3, yielding the results shown in Figure 10c,d. These figures compare predictions obtained from spectra recorded on day 0, corresponding to the initial measurement of the 11 solutions, with those derived from spectra collected on subsequent days. Spectral variations attributable to temporal drift were observed, underscoring the need for correction. Although prediction accuracy decreased over time, the integration of the models with the spectral transformation method still allowed differentiation among most solutions. This demonstrates that simple algorithmic strategies can effectively mitigate drift effects and extend the operational lifetime of the sensing system, achieving accuracies sufficient for certain practical applications.
Table 5 and Table 6 report the mean errors associated with the viscosity and density models during the calibration experiment, whereas Table 7 and Table 8 present the corresponding results for the drift experiment. Consistent with previous studies [56], several metrics were employed to evaluate model performance: the absolute difference between the predicted and reference values (e (mPa·s) and e (g/mL)); the ratio between the mean error and the operating range (full-scale error, e (%FS)); the relative deviation, defined as the mean difference normalized by the reference values (e (%RD)); and the resolution error, quantified as the standard deviation across repeated measurements of the same solution ( ). These metrics effectively implement a minimum detectable change in density and viscosity. The tabulated results corroborate the conclusions observed in the graphics: both calibration and resolution errors are minimal, and when comparing the drift experiment outcomes with those obtained on day 0, the errors increase slightly but remain within acceptable limits.
Finally, a dimensionality reduction analysis was performed using metric Equation (1) and the new definition of resolution as the standard deviation, with the objective of reducing data acquisition time and thereby accelerating the estimation of fluid physical properties. To this end, progressively fewer spectral points were selected according to Equation (1), and new convolutional neural networks were trained following the protocol described in Section 2.3. The trained models were applied both to the calibration experiment and to the drift experiment. Table 9, Table 10, Table 11 and Table 12 summarize the errors obtained. The results indicate that performance remains comparable whether 530 or 103 spectral points are used, demonstrating that measurement time can be reduced with a minimal impact on accuracy. Moreover, reducing the input dimensionality to 103 points lowered computational demands; that is, the optimal neural networks contained fewer parameters, improving their suitability for implementation in the limited memory of the microcontrollers. Figure 11 presents the graphical results obtained with models trained on spectra of 103 points, confirming their strong overall performance when compared with models trained on spectra of 530 points (Figure 10).
4. Discussion
Using the error values reported in the previous section, the performance of the proposed device can be compared with other viscosity and density measurement systems described in the literature [5,6,7,9,10,17,42,43]. The results of this comparison are presented in Table 13 and Table 14. For the viscosity measurements, the proposed system achieves the second-best performance in the e (mPa·s) and e (%FS) metrics, ranking only behind [17], while in the e (%RD) metric, it occupies the third position (after [7,17]). In terms of density, the accuracy of our system consistently ranks third across the e (g/mL), e (%FS) and e (%RD) metrics. With respect to resolution, the device ranks close to fourth, corresponding to the results reported in [17]. It should be emphasized that the studies compiled here are not restricted to fuels; they also encompass other types of liquids, whose interactions with the sensor material may yield either improved or diminished performance. A particularly relevant comparison can be observed in the column corresponding to [17]. In their case, the reported errors were obtained using a similar system configuration and a comparable set of biofuels but employing a MEMS sensor. The results were nearly identical, although in their study, it was possible to detect a 0.5% admixture of sunflower oil in their diesel. These findings highlight that a sufficiently precise system can be realized using low-cost technologies, especially when combined with artificial intelligence, thereby achieving performance comparable to sensors fabricated with more expensive technologies.
In this work, we introduced optimization strategies for multiresonance analysis, integrated 3D-printed sensors into a microcontroller-based platform and addressed previously unexplored challenges related to dimensionality reduction and drift correction. Building on our earlier contributions, we demonstrated that 3D-printed sensors can achieve performance comparable to MEMS-based devices for biofuel property detection when combined with artificial intelligence. Despite these advances, several avenues for further development and system optimization remain.
First, although the PZT elements employed in this study were encapsulated and isolated from the fluid, being bonded to the external surface of the membrane inside the fluidic chamber, future designs would benefit from the use of lead-free piezoelectric materials. Lead-free ceramics such as (K,Na)NbO_3_ (KNN) [63] and Bi_0.5_Na_0.5_TiO_3_ (BNT) [64] have emerged as promising alternatives to conventional PZT due to environmental and regulatory constraints associated with lead, and recent material improvements further support their suitability as replacements.
Second, enhancements to the fabrication process are needed. Two potential strategies include the following: (i) laser-cutting the piezoelectric patches to improve sample-to-sample reproducibility, followed by bonding using the printing resin, or (ii) incorporating piezoelectric particles directly into the polymer resins, thereby producing a fluidic cell with spatially uniform sensitivity. Although both approaches could improve manufacturing consistency, the intrinsic resolution limits of the 3D-printing process would remain a constraint.
The experiments conducted here relied on discrete, pre-prepared mixtures under controlled laboratory conditions, which may limit direct applicability to continuous online industrial monitoring. Future improvements could therefore involve the use of materials with reduced chemical reactivity toward fuels, enabling greater long-term stability and allowing the system to exploit its potential capability for continuous operation (an aspect not used in the present study, where measurements were performed with the liquid at rest). Additional target liquids could also be explored. Since sunflower oil was considered exclusively as a biofuel additive, it would be valuable to assess the system’s robustness against common interferences such as water contamination, oxidation products or dissolved gases, particularly when these factors induce density or viscosity variations beyond the resolution limits of the sensor. Another promising direction involves evaluating temperature effects and implementing compensation strategies, either electronically or by incorporating temperature as an additional input during neural network training.
The proposed system relies on deep learning to map multiresonance spectral features to physical fluid properties. This approach exploits the fact that changes in viscosity or density alter the added mass and damping of the resonator, producing measurable variations in the spectral response, including shifts in resonance amplitude and frequency. Machine learning captures these relationships through statistical modeling; however, even studies employing physical models ultimately rely on mathematical approximations of the hydrodynamic function [52,53]. However, in our study, robustness relies on controlled measurement conditions and the proposed drift correction; explicit disentanglement of confounders (e.g., bubbles, mounting stress, aging) is not yet addressed and will be investigated in future work (e.g., additional sensing inputs or physics-informed models).
From a computational perspective, COMSOL simulations could be extended to higher frequencies to account for the evaluation performed without liquid interaction. Moreover, Equation (1) could be refined by incorporating the drift experiment results into the denominator, thereby optimizing another key aspect of sensor performance. Although short-term drift has been characterized, long-term stability studies spanning multiple weeks and multiple devices represent an important next step toward practical deployment. Additional preprocessing and correction techniques may also further improve data quality.
Finally, successful commercialization will require complementing these technical developments with a comprehensive business strategy. Such a strategy should include detailed market analysis, evaluation of regulatory requirements and brand development to ensure the competitiveness and long-term viability of the proposed technology.
5. Conclusions
In this work, we introduced a system that integrates 3D-printed fluidic cells and piezoelectric actuators with machine learning algorithms for the monitoring of liquids of industrial and environmental relevance. The transducer was structurally optimized using a novel metric that accounts for the multi-peak characteristics of the electromechanical response, as well as sensitivity, resolution and regeneration capacity. Convolutional neural networks were employed and fine-tuned through hyperparameter optimization to improve accuracy in estimating fluid physical properties from spectral measurements. Both the sensor and the trained networks were implemented within a microcontroller-based platform with simple conditioning electronics. Calibration and resolution errors in viscosity and density estimation were small in comparison with reported values, reaching 0.99% and mPa·s for viscosity, and 0.0485% and g/mL for density. These precision levels enabled the detection of variations in biodiesel composition of less than 1% based on viscosity and density measurements. Additional experiments addressing sensor temporal drift and dimensionality reduction further extended device lifespan and accelerated measurement speed. These results were benchmarked against comparable studies in the literature, demonstrating similar or superior performance in certain cases. While further improvements are possible, particularly through the automation of sensor fabrication, the present work provides effective solutions to challenges related to drift correction, geometric optimization and data dimensionality reduction. The outcome is a low-cost, compact, portable and precise sensing device capable of supporting biofuel quality assessment and adaptable to other industrial applications.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Razzaq L. Farooq M. Mujtaba M. Sher F. Farhan M. Hassan M.T. Soudagar M.E.M. Atabani A. Kalam M.A. Imran M. Modeling viscosity and density of ethanol-diesel-biodiesel ternary blends for sustainable environment Sustainability 202012518610.3390/su 12125186 · doi ↗
- 2Estevez R. Aguado-Deblas L. Posadillo A. Hurtado B. Bautista F.M. Hidalgo J.M. Luna C. Calero J. Romero A.A. Luna D. Performance and emission quality assessment in a diesel engine of straight castor and sunflower vegetable oils, in diesel/gasoline/oil triple blends Energies 201912218110.3390/en 12112181 · doi ↗
- 3Sun H. Liu Y. Tan J. Research on testing method of oil characteristic based on quartz tuning fork sensor Appl. Sci.202111564210.3390/app 11125642 · doi ↗
- 4Voglhuber-Brunnmaier T. Niedermayer A.O. Feichtinger F. Jakoby B. Fluid sensing using quartz tuning forks—Measurement technology and applications Sensors 201919233610.3390/s 1910233631117176 PMC 6566906 · doi ↗ · pubmed ↗
- 5Toledo J. Manzaneque T. Hernando-García J. Vázquez J. Ababneh A. Seidel H. Lapuerta M. Sánchez-Rojas J.L. Application of quartz tuning forks and extensional microresonators for viscosity and density measurements in oil/fuel mixtures Microsyst. Technol.20142094595310.1007/s 00542-014-2095-x · doi ↗
- 6Toledo J. Ruiz-Díez V. Pfusterschmied G. Schmid U. Sánchez-Rojas J. Characterization of oscillator circuits for monitoring the density-viscosity of liquids by means of piezoelectric MEMS microresonators Proceedings of the Smart Sensors, Actuators, and MEMS VIII Barcelona, Spain 8–10 May 2017 SPIE Bellingham, WA, USA 2017 Volume 1024638039010.1117/12.2266497 · doi ↗
- 7Toledo J. Manzaneque T. Ruiz-Díez V. Jiménez-Márquez F. Kucera M. Pfusterschmied G. Wistrela E. Schmid U. Sánchez-Rojas J.L. Comparison of in-plane and out-of-plane piezoelectric microresonators for real-time monitoring of engine oil contamination with diesel Microsyst. Technol.2016221781179010.1007/s 00542-016-2833-3 · doi ↗
- 8Goel S. Venkateswaran P. Prajesh R. Agarwal A. Rapid and automated measurement of biofuel blending using a microfluidic viscometer Fuel 201513921321910.1016/j.fuel.2014.08.053 · doi ↗
