# An Ultra-Low-Cost RCL-Meter

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

^{®}micro-controller hardware itself and high-level routines. The models and pseudo-routines required to measure admittance parameters are described, and a benchmark between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers was performed to validate the resistance and capacitance measurements. Both ATmega328P and ATmega32U4 micro-controllers could measure isolated resistances from 0.5 Ω to 80 MΩ and capacitances from 100 fF to 4.7 mF. Inductance measurements are estimated at between 0.2 mH to 1.5 H. The accuracy and range of the measurements of series and parallel RC networks are demonstrated. The relative accuracy (a

_{r}) and relative precision (p

_{r}) of the measurements were quantified. For the resistance measurements, typically a

_{r}, p

_{r}< 10% in the interval 100 Ω–100 MΩ. For the capacitance, measured in one of the modes (fast mode), a

_{r}< 20% and p

_{r}< 5% in the range 100 fF–10 nF, while for the other mode (transient mode), typically a

_{r}< 20% in the range 10 nF–10 mF and p

_{r}< 5% for 100 pF–10 mF. a

_{r}falls below 5% in some sub-ranges. The combination of the two capacitance modes allows for measurements in the range 100 fF–10 mF (11 orders of magnitude) with a

_{r}< 20%. Possible applications include the sensing of impedimetric sensor arrays targeted for wearable and in-body bioelectronics, smart agriculture, and smart cities, while complying with small form factor and low cost.

## 1. Introduction

^{®}micro-controller series commonly used in the Arduino

^{®}platform. The accuracy and precision of the measurements are discussed based on the relative parameters of measurement uncertainty (u

_{r}), accuracy (a

_{r}) and precision (p

_{r}). All the C++ codes for Arduino and the MATLAB scripts used in this manuscript are available in the Supplementary Materials.

## 2. Materials and Methods

#### 2.1. AVR^{®} Micro-Controllers Based RCL-Meter

^{®}, namely the Uno and Leonardo boards, were used to develop the ultra-low-cost RCL-meter. The Arduino

^{®}Uno board makes use of an ATmega328P micro-controller, and the Arduino

^{®}Leonardo uses an ATmega32U4. Figure 1e shows the block diagram of the proposed measurement system based exclusively on the internal circuitry of the AVR

^{®}micro-controller. Both ATmega328P [26] and ATmega32U4 [27] are low-power AVR

^{®}8-bit micro-controllers that share similar features, namely equal clock frequency up to 16 MHz, operational voltage range between 2.7 to 5.5 V, 32 kB of flash memory (enough to store the firmware and processing code), 2 kB (ATmega328P)/2.5 kB (ATmega32U4) of static random-access memory (SRAM) (to store the main variables and acquisition samples) and an analog-to-digital unit (ADC) with 10-bit resolution, the core of the system. Both the Uno and Leonardo boards were supplied through the local-PC connection via USB interface, and the default settings were used, meaning the reference voltage (V

_{REF}) is the internal voltage source of 5 V.

#### 2.2. Analog I/O Operation Modes

^{®}micro-controller family provides access to several digital and analog ports with input and output (I/O) functionalities. Both digital and analog I/O ports share a common control unit design, often called “General Digital I/O” [26,27]. In this work, the digital I/O ports (PDN) are labeled by an alpha-numerical code, denoted by the letter “D” proceeded by the port bit number “N”, while the analog I/O ports (PAN) are represented by the letter “A”. The analog ports have exclusive access to the alternate functions, featuring an I/O source-measuring unit (SMU) and an analog-to-digital converter (ADC) unit. By default, P

_{AN}ports can be configured into four distinct operation modes: (mode 1) floating input; (mode 2) pull-up input; (mode 3) low voltage output; (mode 4) high voltage output. Each operation mode shares the same basic electrical structure, consisting of the supply voltage source (V

_{S}), common ground (GND), a stray capacitance (C

_{pin}) and location of the I/O port (P

_{An}) for the SMU and ADC unit. By default, vs. is equal to the reference voltage (V

_{REF}). Figure 1 shows the equivalent circuit that describes each analog I/O port operation mode and was adapted from references [26,27]. Operation modes 1 and 2, shown in Figure 1a,b, respectively, share the same internal circuitry components to form a high-impedance input port due to the presence of the analog input resistance (R

_{AIN}). C

_{pin}is also included in parallel with R

_{AIN}to account for the stray capacitance. The unique difference between operation mode 1 and 2 is the state of the internal pull-up resistance (R

_{pu}), which is connected to an internal bias voltage. In the case of operating mode 1, the R

_{pu}is inactive, leading to a floating input configuration, while in the case of operation mode 2, the R

_{pu}sets a SMU configuration. This aspect will be further explored to implement the RCL-meter. Operation modes 3 and 4, shown in Figure 1c,d, relate to the “General Digital I/O” functions. Operation mode 3 consists of a floating and impedance low output configuration, and the operation mode 4 consists of a voltage source (V

_{S}), thus forcing a high output configuration. In the absence of load impedance connected to P

_{AN}, the configuration of the operation mode 4 sinks current through the parallel RC network formed by the output resistance (R

_{out}) and C

_{pin}. Table 1 shows the typical values of the internal components of the I/O ports [26,27].

_{pu}and C

_{pin}values listed in Table 1 are representative values. In case of the R

_{pu}, both micro-controller datasheets [26,27] characterize the range of R

_{pu}between 20 kΩ to 50 kΩ, and solely for the purpose of the ADC unit it refers a typical reference input resistance (R

_{REF}) value of 32 kΩ. As for the C

_{pin}, the micro-controller datasheets [26,27] do not provide a typical value; only a conceptual component is shown in the equivalent circuits of the analog input circuitry representing the overall stray capacitance (also named C

_{pin}). Therefore, the typical stray capacitance listed in Table 1 considers all capacitive sources in the internal analog input circuitry, such as: (i) the sampling and holder capacitance (C

_{S/H}), approximately equal to 14 pF and (ii) the input capacitance (C

_{i}) of each I/O pin, approximately equal to 10 pF. Both C

_{S/H}and C

_{i}are grounded; therefore, it is assumed that the parallel of both C

_{i}‖ C

_{S/H}is the minimum value of C

_{pin}and is approximately equal to C

_{pin}≅ C

_{i}‖ C

_{S/H}≅ 24 pF.

^{®}micro-controller must be configured according to the pseudo-code described in Figure 1 through a low-level instruction set, which is not a user-friendly environment. However, Arduino

^{®}has developed an integrated development environment (IDE) platform with support of high-level C++ functions such as pinMode() and digitalWrite(), an easy and user-friendly method to configure the ports. Figure 1 describes the C++ code required to properly configure each operation mode. In the following sections, it will be shown how the four different configurations for the ports may be used to build an RCL bridge. First, it is shown how to measure isolated resistors, capacitors and inductors, and then how to measure combinations of resistors and capacitors in series or parallel.

#### 2.3. Recording Circuit

_{A0}and P

_{A1}ports configured for pull-up input (mode 1) and low output (mode 3), respectively, and as described in Section 2.2. Figure 1f shows the equivalent circuit resulting from the combination of the internal circuitry of each I/O port bridged by a load impedance (Z

_{LOAD}). In the following Section 2.4, Section 2.5, Section 2.6, Section 2.7 and Section 2.8, the equivalent circuit shown in Figure 1f is detailed by replacing Z

_{LOAD}with resistance, capacitance and inductance, either isolated or in series and parallel.

#### 2.4. Measurements of an Isolated Load Resistance (R–Meter)

_{LOAD}is composed of an isolated load resistance (R

_{LOAD}), the pull-up resistor (R

_{pu}) at port P

_{A0}drives a current source that will sink through the parallel resistance path (R

_{P}) formed by the analog input resistance (R

_{AIN}) and the sum of the load and output resistances (R

_{LOAD}+ R

_{out}). Thus, for circuit analysis purposes, in Figure 2a, a reduction of the entire equivalent circuit to a voltage divider circuit is shown. In Figure 2a, the variable N

_{A0}is introduced as the digital counterpart of the analog variable V

_{A0,}where N

_{A0}= ⌊N

_{max}·(V

_{A0}/V

_{S})⌋. The stray capacitances (C

_{pin}) were neglected from the equivalent circuit, since on DC measurements, the capacitances behave as open circuit. In addition, to avoid interference of any stray capacitance, the procedure is to implement a reasonable delay time (say 1 ms) after setting the port P

_{A0}to operation mode 2 (pullup input). This procedure assures that the stray capacitances are open circuit (t ≫ τ = R

_{T}C

_{pin}). Using C

_{pin}= 25 pF and R

_{pu}= 32 kΩ, one obtains τ < 1 µs.

_{A0}is the measured voltage at port P

_{A0}and is given by:

_{P}is given by R

_{AIN}|| (R

_{LOAD}+ R

_{out}), and vs. is equal to the reference voltage source (V

_{REF}). Solving the voltage divider Equation (1), R

_{LOAD}is found as:

_{LOAD}is described in Figure 2b.

#### 2.5. Measurements of an Isolated Load Capacitance (C–Meter)

_{LOAD}charging cycle, and (ii) transient acquisition mode, based on measuring the charging time until a threshold voltage is reached. It is essential that prior to initiating measurements of C

_{LOAD}, all capacitive components are fully discharged. A typical procedure to discharge all capacitances is achieved by configuring the operation mode of the two I/O ports in use to low output (mode 3) and waiting, for example, a period of Δt ≥ 1 ms.

#### 2.5.1. Fast Acquisition Mode of an Isolated Load Capacitance

_{LOAD}) uses a different internal circuitry. Therefore, Figure 3a shows the equivalent circuit resulting from the combination of the internal circuitry of two I/O ports, P

_{A0}and P

_{A1}, bridged by a pure load capacitance (C

_{LOAD}). Essentially, the port P

_{A1}is set in high output (mode 4) and links the voltage source (V

_{S}) to the C

_{LOAD}terminal behaving as an input current source (i

_{S}), and the port P

_{A0}is set to floating input (mode 1), consisting of a measuring unit that links the input current to the ground through a high impedance resistor (R

_{AIN}). Both the P

_{A1}and P

_{A0}ports consider the leakage current path to the ground through a stray capacitance (C

_{pin}). However, the C

_{pin}located at P

_{A1}can be neglected, since the characteristic time constant (τ

_{A1}) of P

_{A1}is τ

_{A1}= R

_{out}C

_{pin}≅ 15 ns, and therefore, because the fastest clock cycle (τ

_{clk}) of the micro-controllers in use are approximately equal to τ

_{clk}≈ 5τ

_{A1}, after a single clock cycle the voltage in port P

_{A1}(V

_{A1}) is stationary.

_{T}) formed by the load (C

_{LOAD}) and stray (C

_{pin}) capacitors in series, given by C

_{T}= C

_{LOAD}C

_{pin}/(C

_{LOAD}+ C

_{pin}). This allows the reduction of the entire equivalent circuit to a voltage divider, as shown in Figure 3b, and is only valid for measuring the impulse response. Thus, V

_{A0}must be read immediately after defining P

_{A0}to floating input and P

_{A1}to high output.

_{LOAD}and C

_{pin}are in series, the charge level must be equal in both capacitances (Q

_{LOAD}= Q

_{pin}), thus allowing the expression of V

_{A0}as:

_{LOAD}= C

_{LOAD}(V

_{S}− V

_{A0}) and Q

_{pin}= C

_{pin}V

_{A0}. Rearranging (3), C

_{LOAD}is found as:

_{pin}is made available through the datasheet of the micro-controller, and is typically 25 pF, while vs. is equal to the reference voltage source (V

_{REF}), and V

_{A0}is the measured voltage at port P

_{A0}. Thus, all parameters are known, and C

_{LOAD}can be determined. Lastly, the fast acquisition mode methodology is limited by the size of the C

_{pin}, such that, if V

_{A0}→ N

_{max}, the maximum range of (4) is an asymptote with C

_{LOAD}→ ∞. Therefore, an approximation to determine the range of measurable C

_{LOAD}is:

_{A0}< N

_{max}− 1. The pseudo-code for a routine to measure C

_{LOAD}through the fast acquisition mode is described in Figure 3c.

#### 2.5.2. Transient Acquisition Mode of an Isolated Load Capacitance

_{LOAD}bridging the ports P

_{A0}and P

_{A1}in the equivalent circuit shown in Figure 1f. The stray capacitances (C

_{pin}) are not larger than some tens of pico-Farads (pF) and can therefore be neglected.

_{in}represents the impedance due to the pull-up resistance (R

_{pu}) at the input port P

_{A0}, and Z

_{out}is the output impedance formed by the parallel RC network between the analog input resistance (R

_{AIN}) and the series RC network (Z

_{LOAD}+ R

_{out}). Z

_{LOAD}is the impedance representation of the load capacitance (C

_{LOAD}). Therefore, an estimation of C

_{LOAD}is obtained using the step response of the impedance divider circuit shown in Figure 4b, which is given by:

_{T}is the total resistance path contributing for the potential difference on the capacitance terminals given by R

_{T}= R

_{AIN}|| R

_{pu}+ R

_{out}. Thus, C

_{LOAD}can be found at any time t by rearranging Equation (6) to:

_{LOAD}value, the elapsed time (Δt) must be determined, since t = 0 until a threshold voltage (V

_{th}) is reached. For instance, solving Equation (6) with t = τ allows the definition of V

_{th}= (1 − e

^{−}

^{1})V

_{S}and therefore solves Equation (7). The elegant procedure for testing V

_{th}makes use of the built-in transistor-transistor logic (TTL) unit to monitor V

_{A0}by setting the TTL unit high voltage threshold (V

_{IH}) to the V

_{th}(V

_{th}= V

_{IH}), allowing not only the avoidance of the computation of the V

_{th}, but also the enhancement of the accuracy of the measurement. In practical terms, the elapsed time (Δt) since C

_{LOAD}initiates the charging cycle (t = 0) until the TTL unit changes to the logical state high ‘1’ (V

_{A1}≥ V

_{IH}) must be measured, as well as proceeding to the reading of V

_{A0}using the ADC unit (N

_{A0}). Then, C

_{LOAD}is found by replacing V

_{A0}and t by the measured values of N

_{A0}and Δt in Equation (7). Figure 4c depicts the voltage step response of the impedance divider circuit. The highlighted region delimited between the voltage level V

_{IH}and vs. represents the operation region where the TTL logic unit changes of logic state low ‘0’ to high ‘1’. For reference, Table 1 includes the typical values of V

_{IH}for the ATmega328P and ATmega32U4 micro-controllers.

_{LOAD}increases to proportions where high temporal resolution is required to measure the N

_{A0}accurately, since N

_{A0}→ N

_{max}just before the first reading is taken, causing the ADC unit to overflow. An approximation of the ranging limits of the transient acquisition mode is given by:

_{A0}) are solved assuming 1 ≤ N

_{A0}≤ N

_{max}− 1. Using the typical values provided in Table 1, the detection limit of the interface assuming the fastest reading of the ADC unit could be achieved after one clock-cycle (Δt = 62.5 ns). Then, the minimum range of the transient acquisition method varies between 214 fF ≤ C

_{min}≤ 392 fF with 22.4 kΩ ≤ R

_{pu}≤ 41.6 kΩ. Nevertheless, the impact of the stray capacitances (C

_{pin}) was neglected, and therefore such a range is merely indicative, since C

_{pin}≫ C

_{min}. As for the maximum range of the transient acquisition method, the maximum Δt is limited by the size of the unsigned long variables given by Δt = (2

^{32}− 1) × 1 µs ≅ 4295 s. Thus, the maximum range corresponds to a battery-like storage unit rather than a capacitor, as it is some hundreds of farads. The pseudo-code of a routine to perform the measurement of C

_{LOAD}through the transient acquisition mode is described in Figure 4c.

#### 2.6. Measurements of a Serial RC Network (RC–Meter Mode)

_{LOAD}is composed by a series RC network, the strategy to extract C

_{LOAD}and R

_{LOAD}resembles the previously described techniques to measure a pure resistor in Section 2.4 and a pure capacitor through the transient acquisition mode in Section 2.5.2. However, the TTL-based technique used to determine C

_{LOAD}cannot guarantee that a TTL transition will occur in the transient response of the circuit, since the voltage V

_{A0}might start at a value above the TTL threshold (V

_{IH}). Instead, the monitoring process of the transient response must be carried out exclusively using the analog functions available on the AVR

^{®}micro-controller ports. First, the C

_{LOAD}must be completely discharged, which requires defining both ports P

_{A0}and P

_{A1}to low output configuration for a reasonable time, and then defining P

_{A0}to a high-impedance SMU, while maintaining P

_{A1}as low output. For the sake of simplicity, the stray capacitances (C

_{pin}) are neglected, which is allowed if they are not larger than some tens of pico-farads (pF).

_{LOAD}fully discharged, after setting the port P

_{A0}to a high-impedance SMU (t = 0), a voltage step is applied on the serial RC circuit. Since C

_{LOAD}is empty, it behaves as a short-circuit, which results in an equivalent circuit, as shown in Figure 2a, thus allowing the extraction of the R

_{LOAD}value through use of the technique described in Section 2.4 to measure a pure resistor (note that the port configuration is the same). The measured voltage (V

_{A0}) at the instant t = 0 defines an offset voltage (V

_{R}). For any instant t > 0, C

_{LOAD}starts to accumulate charge, and the same circuit analysis described in Section 2.5.2 applies to determine the transient dynamics of the voltage step response. For t → ∞, C

_{LOAD}is fully charged and behaves as an open circuit, thus forcing the current to flow exclusively through the analog input resistance (R

_{AIN}), as represented in Figure 1f by the current path ‘i

_{R}’. Thus, considering the influence of the charging current (i

_{L}) due to the series R

_{LOAD}, an estimation of C

_{LOAD}is obtained using the step response of the equivalent circuit shown in Figure 1f that is given by:

_{R}is the offset voltage due to the series R

_{LOAD}, V

_{REF}is the new reference voltage of the circuit given by V

_{REF}= vs. − V

_{R}, τ is the characteristic time constant of the equivalent circuit given by the τ = R

_{T}C

_{LOAD}and R

_{T}is the total resistance path contributing to the potential difference on the capacitance terminals given by R

_{T}= R

_{AIN}|| R

_{pu}+ R

_{LOAD}+ R

_{out}. Thus, C

_{LOAD}can be found at any time t by rearranging Equation (9) to:

_{R}) due to the bridge of ports P

_{A0}and P

_{A1}with the serial RC network. As for the reading capacitance voltage level (V

_{C}) it is determined when t = τ = R

_{T}C

_{LOAD}, and is given by V

_{C}= V

_{R}+ (1 − e

^{−}

^{1})(V

_{S}− V

_{R}). Therefore, all parameters in Equation (10) are known except for the time (t). To extract C

_{LOAD}, a routine to determine the elapsed time (Δt) until the measured voltage (V

_{A1}) is greater than or equal to V

_{C}(V

_{A0}≥ V

_{C}) must be implemented. Figure 5b depicts the pseudo-code of a routine to implement the measurement of a serial RC network. In practical terms, C

_{LOAD}is found by replacing in Equation (10) V

_{R}with the measured value of N

_{A0}at t = 0 (N

_{R}), vs. with the maximum resolution of the ADC unit (N

_{max}) and V

_{A0}and t with the measured value of N

_{A0}and Δt after V

_{A0}≥ V

_{C}, respectively.

#### 2.7. Measurements of a Parallel RC Network (RC–Meter Mode)

_{LOAD}is composed of a parallel RC network (C

_{LOAD}║R

_{LOAD}), the strategy to extract C

_{LOAD}and R

_{LOAD}resembles the previously described technique in Section 2.6, although it must be noted that the change of the load capacitance (C

_{LOAD}) from serial mode to parallel mode causes R

_{LOAD}to saturate at the reference voltage (V

_{F}= V

_{R}) level when t → ∞ and the voltage offset is null at t = 0. Thus, the step response of the equivalent circuit shown in Figure 1f is given by:

_{F}is given by the expression of V

_{R}that is defined in Equation (9), τ is the characteristic time constant of the equivalent circuit given by τ = R

_{T}C

_{LOAD}and R

_{T}is the total resistance path given by R

_{T}= (R

_{AIN}|| R

_{pu}) || (R

_{LOAD}+ R

_{out}). Figure 6a illustrates the transient response to a voltage step expressed by Equation (11). For t → ∞, C

_{LOAD}is fully charged and behaves as an open circuit, forcing the current (i

_{L}) represented in the equivalent circuit shown in Figure 1f to flow exclusively through the R

_{LOAD}to the ground. Therefore, the extraction of R

_{LOAD}is analytically indeterminate, unless an approximation is made, such as, considering for any period (Δt) larger than five times the characteristic time constant (τ) (Δt > 5τ), Equation (11) is approximately equal to V

_{A0}= V

_{F}(1 − e

^{−5}) ≈ V

_{F}, where the term (1 − e

^{−5}) ≈ 0.993 shows that the approximation has a maximum error of 0.7% when determining the R

_{LOAD}value. Thereby, assuming for any Δt > 5τ the plateau V

_{A0}= V

_{F}is reached, the R

_{LOAD}value is obtained using the technique described in Section 2.4 to measure a pure resistor, replacing in Equation (2) V

_{A0}by V

_{F}, where V

_{F}is the measured voltage for any instant Δt > 5τ. The next step is to determine the C

_{LOAD}value through the arrangement of Equation (11) with τ = R

_{T}C

_{LOAD}by:

_{A0}the correspondent measured voltage. The determination of V

_{F}is critical to find both C

_{LOAD}and R

_{LOAD}values. The simplest approach to find V

_{F}using the transient response to a voltage step is to define the maximum characteristic time constant (τ

_{max}) to measure. In these circumstances all parameters are known, and both C

_{LOAD}and R

_{LOAD}values can be measured using Equations (2) and (10). Figure 6b depicts the pseudo-code of a routine to implement the measurement of a parallel RC network.

#### 2.8. Measurements of an Isolated Load Inductance (L–Meter Mode)

_{LOAD}is composed of an isolated load inductance (L

_{LOAD}), and that for the sake of simplicity, the stray capacitances (C

_{pin}) are neglected, which is allowed if they are not larger than some tens of pico-farads (pF), the circuit analysis is simpler than and preferable to using the impedance analysis. Figure 7a shows the impedance representation of the equivalent circuit, where Z

_{in}represents the impedance due to the pull-up resistance (R

_{pu}) at the input port P

_{A1}, and Z

_{out}is the output impedance formed by the parallel RC network between the analog input resistance (R

_{AIN}) and the series RC network (Z

_{LOAD}+ R

_{out}). Z

_{LOAD}is the impedance representation of the load inductance (L

_{LOAD}), given by Z

_{LOAD}= jωL

_{LOAD}. Therefore, an estimation of L

_{LOAD}is obtained using the step response of the impedance divider circuit shown in Figure 7a, which is given by:

_{T}is the total resistance path contributing to the potential difference on the inductance terminals given by R

_{T}= R

_{AIN}|| R

_{pu}+ R

_{out}. Thus, L

_{LOAD}can be found at any time t by rearranging Equation (13) to:

_{th}) over L

_{LOAD}is approximately equal to V

_{th}= V

_{S}·(1 − e

^{−1}). As for the isolated capacitance measurement described in Section 2.5.2, the elegant and simpler procedure for testing V

_{th}, involves making use of the built-in transistor-transistor logic (TTL) unit to monitor V

_{A0}by setting the TTL unit low voltage threshold (V

_{IL}) the V

_{th}(V

_{th}= V

_{IL}). In practical terms, the elapsed time (Δt) since L

_{LOAD}initiates the cycle (t = 0) until the TTL unit changes to the logical state low ‘0’ (V

_{A0}≤ V

_{IL}) must be measured, proceeding afterwards to the reading of V

_{A0}using the ADC unit (N

_{A0}). Then, L

_{LOAD}is found by replacing V

_{A0}and t with the measured values of N

_{A0}and Δt in Equation (14). Figure 7b depicts the voltage step response of the impedance divider circuit. The highlighted region delimited between the voltage level V

_{IL}and vs. represents the operation region where the TTL logic unit changes of logic state high ‘1’ to low ‘0’.

_{LOAD}decreases to such proportions that accurately measuring the N

_{A0}requires high temporal resolution, since N

_{A0}→ 0 just before the first reading is taken, causing the ADC unit to overflow. An approximation of the ranging limits of the transient acquisition mode is given by:

_{A0}) are solved assuming 1 ≤ N

_{A0}≤ N

_{max}− 1. With the same values and assumptions used for the transient C-method, the range of measurement will vary between 0.2 mH ≤ L

_{LOAD}≤ 1.5 H with R

_{pu}= 22.4 kΩ, and 0.4 mH ≤ L

_{LOAD}≤ 2.7 H with R

_{pu}= 41.6 kΩ. These measurable values of L

_{LOAD}are not very useful in real life applications, and for that reason in this manuscript only the methodology is provided as proof of concept to perform measurements with AVR

^{®}micro-controllers of an isolated inductance. In spite of this, the pseudo-code is provided in Figure 7c to implement the measurements of an isolated L

_{LOAD}through the transient acquisition mode built-in AVR

^{®}micro-controllers.

#### 2.9. Data Acquisition and Analysis

^{®}IDE software was used to program and upload the scripts on the AVR

^{®}micro-controllers. All routines that were programmed to perform the measurements of the RCL-meter are based on the pseudo-codes previously described in each method. The data acquisition was carried out with the serial interface made available on the Arduino

^{®}IDE software. The collected data were handled with MATLAB

^{®}to perform the data analysis. All measurements were performed at room temperature, about 25 °C.

#### 2.10. Noise and Uncertainty of the Measurements

_{A0}and P

_{A3}, and shorten the connection cables to a minimum size.

_{n}) was 6.7 mV (with the Arduino board powered through the USB interface connected to a local-PC), comparable to the digitalization uncertainty of the ADC (5 mV) described below. This value permits an enhancement of the accuracy of the ADC unit by oversampling techniques. This shows that the digitalization dominates over thermal and 1/f noise contributions. Thus, in this analysis we only calculate the effect of digitalization uncertainty. Using the default ADC sampling time of 100 µs, the digitalization uncertainty of a 10-bit ADC unit relative to the reference voltage (V

_{REF}) of 5 V, the least significant bit (LSB) voltage is 4.9 mV. To analyze the impact of this digitalization uncertainty, the relative uncertainty (u

_{r}) associated with the analog to digital round off was determined as:

_{LOAD}, C

_{LOAD}and L

_{LOAD}values. Then, the oversampling technique allow for reducing the digitalization uncertainty (u

_{r}) by a factor of 1/N but limited by other sources of uncertainty (noise).

#### 2.11. Relative Accuracy and Precision of the Measurements

_{r}) and the relative precision (p

_{r}). The relative precision (p

_{r}) measures the dispersion of the measured impedance values (Z

_{meas}) normalized to their average ($\overline{Z}$

_{meas}) and was estimated by p

_{r}= SD(Z

_{meas})/$\overline{Z}$

_{meas}, where SD represents the standard deviation of the measured values. The relative accuracy (a

_{r}) measures the closeness of the measured Z

_{meas}to the true or reference value, Z

_{nominal}, and was estimated by a

_{r}= |$\overline{Z}$

_{meas}− Z

_{nominal}|/Z

_{nominal.}

#### 2.12. Linearization of the ADC Unit

_{LOAD}) use the same ports configuration (except for the measurements of an isolated load capacitance using the fast acquisition mode), the simplest method to optimize the linearization of the measurements is to replace Z

_{LOAD}with a pure known load resistance (R

_{LOAD}) and use different resistor sizes to test and maximize the range and accuracy of the ADC unit. Then, Equation (2) must be used as a fitting function, where the R

_{LOAD}values must be replaced by the nominal values provided by the manufacturer of the resistor, and V

_{A0}and vs. by the ADC unit values. Figure 8a shows the N

_{A0}values collected with through-hole resistors bridging two ports of the micro-controllers. All samples consist of an average of 100 consecutive measurements. The data were distributed in a logarithmic scale along the horizontal axis according to the nominal resistance value provided by the manufacturer. The red triangles represent the samples measured with the ATmega328P and the blue circles represent the ATmega32U4. Ordinary Least Squares (OLS) were used to fit the data shown in Figure 8a, but with a small twist, which consisted of applying the natural logarithm (ln) to the OLS objective fit function and to the measured N

_{A0}values. This proved able to cope better with the large range of resistance values, encompassing several orders of magnitude. Then, to extract the optimized values of R

_{AIN}, R

_{out}and R

_{pu}, the user must provide a guess estimation and use a nonlinear programming solver to find the minimum values of the OLS objective function around the estimated values, taken from the manufacturer datasheets. Table 2 shows the extracted values of R

_{AIN}, R

_{out}and R

_{pu}for both ATmega328P and ATmega32U4 AVR

^{®}micro-controllers used in the current work.

_{AIN}, R

_{out}and R

_{pu}were used in all the subsequent measurements.

_{pin}, which is required to perform measurements of an isolated load capacitance through the fast acquisition mode. In this case, through-hole capacitors of different sizes were used to bridge two I/O ports of the micro-controller, and Equation (4) was used as a fitting function for the measurements of the N

_{A0}values shown in the Figure 9a. The C

_{pin}values extracted for each micro-controller are shown in Table 2. The MATLAB scripts written to perform the OLS fitting are available in the Supplementary Materials.

## 3. Results

^{®}micro-controllers. The capacitances in the fF range were of SMD type (Kyocera AVX, Fountain Inn, SC, USA), and all capacitances above 1 μF were aluminum electrolyte capacitor type. The validations were made by comparing the measurements results with the components’ nominal values. In all cases, each data point corresponds to the average of 100 measurements performed in a continuous loop.

#### 3.1. Characterization of Isolated Resistance Measurements

_{A0}(V

_{A0}) were recorded with the ADC unit (N

_{A0}), and the measurements were inserted in Equation (2), to obtain the R

_{LOAD}values shown in Figure 8b. This figure also includes the same resistances measurements recorded with a commercial instrument, the Fluke 8840A multimeter (Fluke Corporation, Everett, WA, USA), for reference and validation. These are excellent results for a low-cost technique. However, it is important to keep in mind that each individual point is the average of 100 consecutive measurements, performed in a loop. Table 3 provides numeric detail on the data shown in Figure 8b.

_{r}) of the measurements as a function of the nominal resistance, as defined in Section 2.11. Figure 8d shows their relative precision, p

_{r}, also defined in Section 2.11 (data points), and the estimated upper limit for the relative uncertainty caused by the digitalization round-off error, u

_{r}, defined in Equation (16) and represented by the dashed line. Note that the standard deviations are calculated on samples that are already averages of 100 points, which means that u

_{r}should be divided by 10, for a correct comparison with p

_{r}. Both plots include white and grey shading regions to highlight the levels of a

_{r}and p

_{r}better than 5%, 10% and 20%. The two plots show better performance of the method in the intermediate resistance range and its degradation in the regime of very low or very high resistances. This is because the lower and upper limits for R

_{LOAD}correspond to N

_{A0}tending to the higher (N

_{max}) and lower (≈0) values of the digital output, respectively, where the roundoff errors introduced by digitalization become more important, affecting both precision and accuracy.

_{r}curve. This is because u

_{r}is merely an upper limit for the digitalization noise, which is actually lower. In any case, the plot indicates that the main uncertainty source in the determination of resistance is the digitalization roundoff.

_{r}< 5% is approximately 10 Ω–10 MΩ for the ATmega328P and 10 Ω–80 MΩ for the ATmega32U4, while the range defined by a

_{r}< 5% is 100 Ω–100 kΩ for the ATmega328P and 100 Ω–10 MΩ for the ATmega32U4.

#### 3.2. Characterization of Isolated Capacitance Measurements: Fast Acquisition Method

_{A0}(V

_{A0}) were recorded with the ADC unit (N

_{A0}) and shown in Figure 9a. Figure 9a also includes a green dashed line that represents the theoretical lines for the two micro-controllers (overlapped), obtained from Equation (3) with the fitted C

_{pin}values shown in Table 2. The measured N

_{A0}and fitted C

_{pin}values were replaced in Equation (4) to determine the load capacitance (C

_{LOAD}), shown in Figure 9b. At the end of Section 3.2, Table 4 was included, providing numeric detail on the data shown in Figure 9b. For reference and validation, this plot also includes the measurements recorded with two commercial instruments, the BK Precision 890C capacitance meter (B&K Precision Corporation, Yorba Linda, CA, USA) and the Fluke PM6304 impedance meter (Fluke Corporation, Everett, WA, USA) at the lowest frequency available (f = 50 Hz). The green dashed line is C

_{LOAD}= C

_{nominal}, showing that the C

_{LOAD}values determined by both micro-controllers match the target values within the range 100 Ff–10 nF, thus achieving a range of about 5 orders of magnitude.

_{r}, p

_{r}and u

_{r}(in the same way as in Figure 8c,d). The accuracy a

_{r}drops significantly above 10 nF because the voltage drop at the load capacitance tends towards the circuit voltage source (N

_{A0}→ N

_{max}), as predicted by Equation (5), inducing large errors in the determination of C

_{LOAD}.

_{r}curve represented (black dashed line in Figure 9d), showing the same V-shaped distribution u

_{r}, as described in Figure 8d, for the resistance measurement. The overlap between u

_{r}and p

_{r}means that the main source of variability is the digitalization noise, to which the fast C-meter adds almost no contribution.

#### 3.3. Characterization of Isolated Capacitance Measurements: Transient Acquisition Method

_{A0}(N

_{A0}), taken at the transition and the corresponding elapsed time (Δt) are shown in Figure 10a.

_{A0}as symbols. Note that by definition these N

_{A0}readings correspond to TTL parameter V

_{IH}—High-Level Input Voltage (because they are acquired at the transition). The same graph shows that the lower the capacitance, the higher the V

_{IH}of the TTL unit. This aspect is consistent with the expected operation mode of the TTL unit. In fact, the TTL unit uses the output high-level current (i

_{HL}) as a test condition, thence, as C

_{LOAD}→ C

_{pin}, the more leakage current flows through C

_{LOAD}, leading to a non-constant V

_{IH}. It should be remarked that the inconstancy of the threshold does not represent a problem for the application of Equation (7), since it only requires a given time and the associated reading V

_{A0}.

_{IH}stabilizes above 22 nF because in that range i

_{HL}remains essentially undisturbed. This allows the estimation of the “basal” V

_{IH}(ΔN

_{A0}) averaging the values of N

_{A0}at the transition for all samples above 22 nF, specifically ΔN

_{A0}≅ 536 for the ATmega328P and ΔN

_{A0}≅ 331 for the ATmega32U4, which are represented by the green dashed lines. The measured values of ΔN

_{A0}are consistent with the typical values described in Table 1.

_{T}C

_{LOAD}, where R

_{T}= R

_{AIN}|| R

_{pu}+ R

_{out}. The linearity still holds in spite of a non-constant V

_{IH}due to the role of i

_{HL}, since the leakage current is also determined by the RC constant of the circuit. The RT values differ only slightly for the two micro-controllers (R

_{T}≅ 35 kΩ for ATmega328P and R

_{T}≅ 37 kΩ for ATmega32U4), causing overlap of the corresponding time constant lines.

_{LOAD}< 1 nF), Δt tends toward a plateau (Δt

_{min}) given by 12.5 μs for both micro-controllers, because C

_{LOAD}→ C

_{pin}. Thus, the C

_{LOAD}values determined with Equation (7), and shown in Figure 10b, are affected by larger errors in the low capacitance range. This is not very apparent in this figure, where the data points seem very close to the green dashed line (C

_{LOAD}= C

_{nominal}) because of the logarithmic scale. Still, at the end of Section 3.3, Table 5 provides numeric detail on the data shown in Figure 10b.

_{r}in Figure 10c illustrate better the difficulties in the low capacitance ranges. The relative accuracy drops significantly (worse than 5%) below 70 nF for the ATmega32U4 and below 10 nF for the ATmega328P. However, both remain, at least, on a 5% accuracy level above those critical values, representing a linear response of the instrument across 6 decades.

_{r}(points) and u

_{r}(dashed lines). Contrary to the fast C-meter case, here the u

_{r}and p

_{r}lines are clearly above u

_{r}, which means that the method introduces sources of noise other than digitalization. This is probably because variations of some ADC units in the threshold level impact much more the measurement than one ADC unit only, related to the digitalization error. These variations may be caused by the internal noise of the micro-processors. The performance degradation in the low capacitance regime is also evident from this figure.

#### 3.4. Characterization of Measurements for Serial RC Networks

_{LOAD}constant and varying the C

_{LOAD}. Figure 11 compiles a total of 14 trials carried out with the two micro-controllers. The white points with red edges represent the data measured with the ATmega328P, and the blue points represent the ATmega32U4. They are mostly overlapped.

_{A0}voltage level (V

_{A0}) at t = 0 to find the offset voltage (V

_{R}) and at t = Δt ≥ τ, to find the voltage level V

_{C}(defined in Section 2.6).

_{A0}) at the instants t = 0 and t ≥ τ, respectively, with both micro-controllers. Figure 11b also includes in the bottom graph the measured elapsed time (Δt) until V

_{A1}≥ V

_{C}, together with the theoretical time constants, τ = R

_{T}C

_{LOAD}. Note that, from Equation (9), N

_{A0}(t = 0) = V

_{R}, which is independent of C

_{LOAD}. This means that all the curves in Figure 11a should be horizontal lines. However, the minimum available acquisition time (ca. 3 μs) is insufficient to capture the initial curve values for C

_{LOAD}< 1 μF. Thus, the captured N

_{A0}values at t = 0 tend to N

_{max}in the limit of very small capacitances. This explains why the (ideal) straight lines become distorted in Figure 11a, especially for lower R

_{LOAD}. Likewise, the plateau N

_{A0}(t ≥ τ) = V

_{C}is reached for any C

_{LOAD}> 100 nF, which hampers the measurements of N

_{A0}after t ≥ τ in this range and induces the same type of distortion in Figure 11b, top.

_{LOAD}and C

_{LOAD}were determined through the use of Equations (2) and (10), with the results shown in Figure 11c,d, respectively. The horizontal lines in Figure 11c represent the ideal result, R

_{measured}= R

_{LOAD}. The measured R

_{LOAD}values are unreliable within a domain in the R-C plane approximately defined by R

_{nominal}C

_{nominal}< 10

^{−4}s.

_{LOAD}. In fact, when R

_{LOAD}≪ (R

_{AIN}|| R

_{pu}) + R

_{out}, then R

_{T}= (R

_{AIN}|| R

_{pu}) + R

_{LOAD}+ R

_{out}≈ R

_{pu}+ R

_{out}, and the information about R

_{LOAD}is lost. For this reason, the higher the R

_{LOAD}, the better the accuracy. This observation is valid for both micro-controllers, except for the trials performed with a R

_{LOAD}of 10 MΩ since N

_{A0}→ N

_{max}at t = 0.

_{A0}≥ V

_{C}, shown in the bottom graph of Figure 11b, exhibit a relative shift in the vertical axis due to the different R

_{LOAD}values. Deviations from the straight line are consequence of the excess digitalization uncertainty. This aspect is evidenced after determination of the C

_{LOAD}values using Equation (10) and shown in Figure 11d, where the deviations from the black dashed line (C

_{LOAD}= C

_{nominal}) relate to the excess digitalization uncertainty.

_{LOAD}and C

_{LOAD}ranges for best accuracy. There are three extreme regimes: (case 1) R

_{LOAD}is large (>1 MΩ), irrespective of the C

_{LOAD}value: the accuracy of the measurements is good for the resistance and poor for the capacitance; (case 2) small R

_{LOAD}(<100 kΩ) and large C

_{LOAD}(>1 nF): measurements with poor accuracy for the resistance, good for the capacitance; (case 3) small R

_{LOAD}(<100 kΩ) and small C

_{LOAD}(<0.1 nF): measurements with very poor accuracy for the resistance, poor for the capacitance. Outside these extreme regimes, the accuracy is at least acceptable for R

_{LOAD}and C

_{LOAD}simultaneously.

#### 3.5. Characterization of Measurements for Parallel RC Networks

_{F}) lies below V

_{S}, and it is necessary to determine both V

_{F}and τ from the data. There are simple and computationally light algorithms allowing the identification of a stationary plateau, such as that occurring at V

_{F}. These have been tested and verified, but including here the description of such methods would increase the length of this report. Thus, the subsequent analysis assumes that τ is already known. No generality is lost with this assumption.

_{LOAD}|| C

_{LOAD}) that was measured, the time constant τ was directly assumed as R

_{T}C

_{LOAD}. The total acquisition time was set to 10τ, V

_{F}was read from V

_{A0}at t = 5τ and V

_{C}was read from V

_{A0}at t = τ.

_{LOAD}values and the right one [(b) and (d)] refers to the measurements of C

_{LOAD}values. The N

_{A0}values at the instants t = 5τ and t = τ are shown in Figure 12a,b, respectively. Figure 12c,d show the R

_{LOAD}and C

_{LOAD}values, which were obtained from Equations (2) and (12), respectively.

_{LOAD}values are generally in line with the measurements carried on with isolated resistors shown in Figure 8b, but with few deviations to linearity (at 10 Ω and any C

_{LOAD}, for the ATmega328P; at 1 MΩ and C

_{LOAD}> 1 μF, for both micro-controllers).

_{LOAD}values are in line with the measurements carried on with isolated capacitors shown in Figure 9b. However, the accuracy of the measurements is variable, for the same reasons mentioned above.

_{LOAD}and C

_{LOAD}ranges for best accuracy. There are two extreme regimes: (case 1) C

_{LOAD}is small (<1 μF), and R

_{LOAD}is large (<1 kΩ): the accuracy of the measurements is good for the resistance and poor for the capacitance; (case 2) large R

_{LOAD}(>1 MΩ) and small C

_{LOAD}(<1 μF): measurements with very poor accuracy for the capacitance, and poor for the resistance. Outside these extreme regimes, the accuracy is at least acceptable for R

_{LOAD}and C

_{LOAD}simultaneously.

## 4. Discussion and Conclusions

^{®}boards with built-in AVR

^{®}micro-controllers. This is highly remarkable considering the ultra-low cost of the hardware. The measurement method allows the extraction of the resistance (R) and capacitance (C) values of either isolated or series and parallel configuration. Furthermore, inductance (L) measurements can be also performed, yet the range of measurable values is not very useful.

^{®}micro-controllers assembled on Arduino

^{®}boards were selected, namely the ATmega328P assembled on an Arduino

^{®}Uno and the ATmega32U4 assembled on an Arduino

^{®}Leonardo. A benchmark was made to test the performance of micro-processors.

_{LOAD}= 4.7 mF) through the transient acquisition mode, the ATmega32U4 performs two times faster than the ATmega328P. In addition, when measuring both C

_{LOAD}and R

_{LOAD}values of in-series or parallel RC networks, the ATmega32U4 takes a slight advantage over the ATmega328P for larger values of R

_{LOAD}, while, conversely, the ATmega32U4 performs better for larger values of C

_{LOAD}.

^{®}boards supplied via a large power bank (Litionite Tanker 90 W/50,000 mAh) and using a data logger shield (RobotDyn

^{TM}, Zhuhai, China) to store the measurements in a local micro-SD card. This work led to the conclusion that no substantial improvements are achieved by using a low-noise and low-uncertainty voltage supply, and therefore all presented data considers the typical noise and uncertainty from a common USB interface voltage supply source. However, the voltage supply unit determines the overall measurement quality in regions close to the ADC unit threshold values (N) for N < 20 or N > 1000.

_{LOAD}and C

_{LOAD}values were made with commercial instruments and presented in the manuscript to provide insight on the overall performance of the ATmega328P and ATmega32U4 micro-controllers as a low-cost alternative to more expensive and sophisticated instruments.

^{®}micro-controllers, may possibly be extended to other microcontrollers such as the STM32 family based on ARM architecture. The latter have more or improved integrated hardware features relative to the former, such as more flash memory, higher resolution ADC drive and faster clocks. On the other hand, using more sophisticated microcontrollers brings the disadvantage of idle but power-consuming internal hardware, for example, the digital-to-analog unit (DAC), which is not required in the present work. In any case, the inherent specificities of each architecture imply different implementations, difficult to cover in a single report.

## Supplementary Materials

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Cima, M.J. Next-generation wearable electronics. Nat. Biotechnol.
**2014**, 32, 642–643. [Google Scholar] [CrossRef] [PubMed] - Stoppa, M.; Chiolerio, A. Wearable electronics and smart textiles: A critical review. Sensors
**2014**, 14, 11957–11992. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Heo, J.S.; Eom, J.; Kim, Y.-H.; Park, S.K. Recent Progress of Textile-Based Wearable Electronics: A Comprehensive Review of Materials, Devices, and Applications. Small
**2017**, 14, 1–16. [Google Scholar] [CrossRef] [PubMed] - Joo, H.; Lee, Y.; Kim, J.; Yoo, J.-S.; Yoo, S.; Kim, S.; Arya, A.K.; Kim, S.; Choi, S.H.; Lu, N.; et al. Soft implantable drug delivery device integrated wirelessly with wearable devices to treat fatal seizures. Sci. Adv.
**2021**, 7, eabd4639. [Google Scholar] [CrossRef] [PubMed] - Matsukawa, R.; Miyamoto, A.; Yokota, T.; Someya, T. Skin Impedance Measurements with Nanomesh Electrodes for Monitoring Skin Hydration. Adv. Healthc. Mater.
**2020**, 9, e2001322. [Google Scholar] [CrossRef] [PubMed] - Chung, M.; Fortunato, G.; Radacsi, N. Wearable flexible sweat sensors for healthcare monitoring: A review. J. R. Soc. Interface
**2019**, 16, 20190217. [Google Scholar] [CrossRef] [PubMed] - Boutry, C.M.; Kaizawa, Y.; Schroeder, B.C.; Chortos, A.; Legrand, A.; Wang, Z.; Chang, J.; Fox, P.; Bao, Z. A stretchable and biodegradable strain and pressure sensor for orthopaedic application. Nat. Electron.
**2018**, 1, 314–321. [Google Scholar] [CrossRef] - Oren, S.; Ceylan, H.; Schnable, P.S.; Dong, L. High-Resolution Patterning and Transferring of Graphene-Based Nanomaterials onto Tape toward Roll-to-Roll Production of Tape-Based Wearable Sensors. Adv. Mater. Technol.
**2017**, 2, 1700223. [Google Scholar] [CrossRef] - Giraldo, J.P.; Wu, H.; Newkirk, G.M.; Kruss, S. Nanobiotechnology approaches for engineering smart plant sensors. Nat. Nanotechnol.
**2019**, 14, 541–553. [Google Scholar] [CrossRef] [PubMed] - Catini, A.; Papale, L.; Capuano, R.; Pasqualetti, V.; Di Giuseppe, D.; Brizzolara, S.; Tonutti, P.; Di Natale, C. Development of a sensor node for remote monitoring of plants. Sensors
**2019**, 19, 4865. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Mizukami, Y.; Sawai, Y.; Yamaguchi, Y. Moisture content measurement of tea leaves by electrical impedance and capacitance. Biosyst. Eng.
**2006**, 93, 293–299. [Google Scholar] [CrossRef] - Li, M.Q.; Li, J.Y.; Wei, X.H.; Zhu, W.J. Early diagnosis and monitoring of nitrogen nutrition stress in tomato leaves using electrical impedance spectroscopy. Int. J. Agric. Biol. Eng.
**2017**, 10, 194–205. [Google Scholar] [CrossRef] - Diacci, C.; Abedi, T.; Lee, J.W.; Gabrielsson, E.O.; Berggren, M.; Simon, D.T.; Niittylä, T.; Stavrinidou, E. Diurnal in vivo xylem sap glucose and sucrose monitoring using implantable organic electrochemical transistor sensors. iScience
**2020**, 24, 101966. [Google Scholar] [CrossRef] [PubMed] - Lopez-Martin, A.J.; Carlosena, A. Sensor signal linearization techniques: A comparative analysis. In Proceedings of the 2013 IEEE 4th Latin American Symposium on Circuits and Systems, LASCAS 2013-Conference Proceedings, Cusco, Peru, 27 February–1 March 2013; IEEE: Piscataway, NJ, USA, 2013; pp. 1–4. [Google Scholar]
- Kraska, M. Digital linearization and display of non-linear analog (sensor) signals. In Proceedings of the IEEE Workshop on Automotive Applications of Electronics, Dearborn, MI, USA, 19 October 1988; IEEE: Piscataway, NJ, USA, 1988; pp. 45–51. [Google Scholar] [CrossRef]
- Islam, T.; Mukhopadhyay, S.C. Linearization of the sensors characteristics: A review. Int. J. Smart Sens. Intell. Syst.
**2019**, 12, 1–21. [Google Scholar] [CrossRef] [Green Version] - Alegria, F.; Moschitta, A.; Carbone, P.; Serra, A.D.C.; Petri, D. Effective ADC linearity testing using sinewaves. IEEE Trans. Circuits Syst. I Regul. Pap.
**2005**, 52, 1267–1275. [Google Scholar] [CrossRef] - Gong, Z.; Liu, Z.; Wang, Y.; Gupta, K.; da Silva, C.; Liu, T.; Zheng, Z.H.; Zhang, W.P.; van Lammeren, J.P.M.; Bergveld, H.J.; et al. IC for online EIS in automotive batteries and hybrid architecture for high-current perturbation in low-impedance cells. In Proceedings of the 2018 IEEE Applied Power Electronics Conference and Exposition (APEC), San Antonio, TX, USA, 4–8 March 2018; pp. 1922–1929. [Google Scholar] [CrossRef]
- Manfredini, G.; Ria, A.; Bruschi, P.; Gerevini, L.; Vitelli, M.; Molinara, M.; Piotto, M. An ASIC-Based Miniaturized System for Online Multi-Measurand Monitoring of Lithium-Ion Batteries. Batteries
**2021**, 7, 45. [Google Scholar] [CrossRef] - Crescentini, M.; De Angelis, A.; Ramilli, R.; De Angelis, G.; Tartagni, M.; Moschitta, A.; Traverso, P.A.; Carbone, P. Online EIS and Diagnostics on Lithium-Ion Batteries by Means of Low-Power Integrated Sensing and Parametric Modeling. IEEE Trans. Instrum. Meas.
**2020**, 70, 1–11. [Google Scholar] [CrossRef] - Monteiro, F.D.R.; Stallinga, P. Using an Off-the-Shelf Lock-In Detector for Admittance Spectroscopy in the Study of Plants. Agric. Sci.
**2020**, 11, 390–416. [Google Scholar] [CrossRef] [Green Version] - Grassini, S.; Corbellini, S.; Angelini, E.; Ferraris, F.; Parvis, M. Low-cost impedance spectroscopy system based on a logarithmic amplifier. IEEE Trans. Instrum. Meas.
**2014**, 64, 1110–1117. [Google Scholar] [CrossRef] - Grassini, S.; Corbellini, S.; Parvis, M.; Angelini, E.P.M.V.; Zucchi, F. A simple Arduino-based EIS system for in situ corrosion monitoring of metallic works of art. Measurement
**2018**, 114, 508–514. [Google Scholar] [CrossRef] - Campbell, S. How to Make and Arduino Capacitance Meter. Available online: https://www.circuitbasics.com/how-to-make-an-arduino-capacitance-meter/ (accessed on 17 March 2021).
- Viraktamath, S.V.; Kannur, K.; Kinagi, B.; Shinde, V.R. Digital LCR meter using arduino. In Proceedings of the 2017 International Conference on Computing Methodologies and Communication (ICCMC), Erode, India, 18-19 July 2017; pp. 805–808. [Google Scholar] [CrossRef]
- MICROCHIP. 8-Bit AVR Microcontroller with 32K Bytes In-System Programmable Flash, ATmega328P DATASHEET, Rev.: 7810D–AVR–01/15; Microchip Technology Inc.: Chandler, AZ, USA, 2015. [Google Scholar]
- MICROCHIP. 8-Bit Microcontroller with 16/32K Bytes of ISP Flash and USB Controller, ATmega16U4/ATmega32U4 DATASHEET, Rev.: Atmel-7766I-USB-ATmega16U4-32U4 07/2015; Microchip Technology Inc.: Chandler, AZ, USA, 2015. [Google Scholar]

**Figure 1.**Equivalent circuits for the four operation modes available to configure each analog input/output (I/O) port. (

**a**) mode 1, floating input. (

**b**) mode 2, pull-up input. (

**c**) mode 3, low output. (

**d**) mode 4, high output. Each equivalent circuit is adapted from the schematics provided in the datasheets. (

**e**) Block diagram of the proposed measurement system, including the serial communication and voltage source through USB interface to local PC, flash and SRAM memory, internal voltage source, and internal circuitry to program I/O ports to digital or alternate functionalities. (

**f**) Equivalent circuit of two analog I/O ports bridged with a load impedance (Z

_{LOAD}).

**Figure 2.**Set-up of a pure load resistance meter (R-meter). (

**a**) Reduction of the equivalent circuit to a voltage divider circuit. (

**b**) Pseudo-code used to implement the resistance meter mode.

**Figure 3.**Set-up of a pure load capacitance meter (C-meter). (

**a**) Equivalent circuit of two analog I/O ports bridged with a load capacitance (C

_{LOAD}). (

**b**) Reduction of the equivalent circuit to an impedance divider. (

**c**) Pseudo-code used to implement the fast acquisition mode.

**Figure 4.**Set-up for recording a pure load capacitance (C

_{LOAD}) through the transient acquisition mode. (

**a**) Impedance representation of the reduced equivalent circuit. (

**b**) Illustration of the step response in voltage measured at the input terminal of C

_{LOAD}. V

_{IH}is defined in Table 1. (

**c**) Pseudo-code used to implement the transient acquisition mode.

**Figure 5.**Set-up for recording a load impedance (Z

_{LOAD}) formed by a serial RC network. (

**a**) Illustration of the transient response to a voltage step at the input terminal (P

_{A0}). (

**b**) Pseudo-code used to implement the measurement of a serial RC network.

**Figure 6.**Set-up for recording a load impedance (Z

_{LOAD}) formed by a parallel RC network. (

**a**) Illustration of the transient response to a voltage step at the input terminal (P

_{A0}). (

**b**) Pseudo-code used to implement the measurement of a parallel RC network.

**Figure 7.**Set-up for recording an isolated load inductance (L

_{LOAD}) through the transient acquisition mode. (

**a**) Impedance representation of the reduced equivalent circuit. (

**b**) Illustration of the step response in voltage measured at the input terminal of L

_{LOAD}. V

_{IL}is defined in Table 1. (

**c**) Pseudo-code used to implement the inductance transient acquisition mode.

**Figure 8.**Comparison between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers configured to record an isolated load resistance (R

_{LOAD}). (

**a**) Measured ADC unit discrete values at port P

_{A0}(N

_{A0}). Each sample consists of an average of 100 consecutive measurements. (

**b**) Measured load resistance (R

_{LOAD}) values according to Equation (2). The green dashed lines represent the theoretical lines. (

**c**) Relative accuracy (a

_{r}) and (

**d**) relative precision (p

_{r}) of the measurements in function of R

_{nominal}. The black dashed line represents the relative uncertainty (u

_{r}) of the R

_{LOAD}measurements according to Equation (16). The white and grey shading areas highlight the levels of u

_{r}, a

_{r}and p

_{r}better than 5%, 10% and 20%. A legend to describe the color scheme used in all plots of Figure 8 was included.

**Figure 9.**Comparison between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers configured to record an isolated load capacitance (C

_{LOAD}) through the fast acquisition mode. (

**a**) Measured ADC values at port P

_{A0}(N

_{A0}). Each ADC sample consists of an average of 100 consecutive measurements. (

**b**) Measured load capacitance (C

_{LOAD}) given by Equation (4). The green dashed lines represent the theoretical lines. (

**c**) Relative accuracy (a

_{r}) and (

**d**) relative precision (p

_{r}) of the measurements in function of C

_{nominal}. The black dashed line represents the relative uncertainty (u

_{r}) of the C

_{LOAD}measurements according to Equation (16). The white and grey shading areas highlight the levels of u

_{r}, a

_{r}and p

_{r}better than 5%, 10% and 20%. A legend to describe the color scheme used in all plots of Figure 9 was included.

**Figure 10.**Comparison between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers configured to record an isolated load capacitance (C

_{LOAD}) through the transient acquisition mode. (

**a**) Measured ADC value and time (Δt) until the TTL unit changes to digital state high, logic ‘1’ at port P

_{A0}(N

_{A0}). Each ADC and Δt sample consist of an average of 100 consecutive measurements. (

**b**) Measured load capacitance (C

_{LOAD}) given by Equation (7). The green dashed lines represent the theoretical lines. (

**c**) Relative accuracy (a

_{r}) and (

**d**) relative precision (p

_{r}) of the measurements in function of C

_{nominal}. The black dashed line represents the relative uncertainty (u

_{r}) of the C

_{LOAD}measurements according to Equation (16). The white and grey shading areas highlight the levels of u

_{r}, a

_{r}and p

_{r}better than 5%, 10% and 20%. A legend to describe the color scheme used in all plots of Figure 10 was included.

**Figure 11.**Comparison between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers configured to measure a serial RC network. (

**a**) Measured ADC value at t = 0. (

**b**) Measured ADC value and time (Δt) until V

_{A1}≥ V

_{C}. (

**c**,

**d**) Obtained R

_{LOAD}and C

_{LOAD}values according to Equations (2) and (10), respectively. A legend to describe the color scheme used in all plots of Figure 11 was included. The black dashed lines always represent the theoretical lines.

**Figure 12.**Comparison between the ATmega328P and ATmega32U4 AVR

^{®}micro-controllers configured to measure a parallel RC network. (

**a**) Measured ADC value at t = 5τ. (

**b**) Measured ADC value at t = τ. (

**c**,

**d**) Obtained R

_{LOAD}and C

_{LOAD}values according to Equations (2) and (12), respectively. A legend to describe the color scheme used in all plots of Figure 12 was included. The black dashed lines always represent the theoretical lines.

Voltage Source | ADC Unit | Internal Circuitry Parameters | TTL Unit | |||||||
---|---|---|---|---|---|---|---|---|---|---|

ATmega328P | ATmega32U4 | |||||||||

V_{S}(V) | n | N_{max}(2 ^{n} − 1) | R_{AIN}(MΩ) | R_{out}(Ω) | R_{pu}(kΩ) | C_{pin}(pF) | V_{IL}(V) | V_{IH}(V) | V_{IL}(V) | V_{IH}(V) |

5 | 10 | 1023 | 100 | 600 | 32 | 24 | −0.5–1.5 | 3.0–5.5 | −0.5–0.9 | 1.9–5.5 |

**Table 2.**Optimized values of the R

_{AIN}, R

_{out}, R

_{pu}and C

_{pin}for both ATmega328P and ATmega32U4 AVR

^{®}micro-controllers.

ATmega328P | ATmega32U4 | ||||||
---|---|---|---|---|---|---|---|

R_{AIN}(MΩ) | R_{pu}(kΩ) | R_{out}(Ω) | C_{pin}(pF) | R_{AIN}(MΩ) | R_{pu}(kΩ) | R_{out}(Ω) | C_{pin}(pF) |

3.537 | 36.89 | 565.8 | 23.48 | 5.451 | 36.66 | 542.2 | 25.5 |

**Table 3.**Comparison of the ATmega328P, ATmega32U4 and Fluke 8840A measured load resistance (R

_{LOAD}) values ± standard deviation (SD).

R_{nominal} | ATmega328P | ATmega32U4 | Fluke 8840A | ATmega328P | ATmega32U4 | Fluke 8840A | |
---|---|---|---|---|---|---|---|

R_{LOAD} ± SD | R_{nominal} | R_{LOAD} ± SD | |||||

0.5 Ω | 0.6 ± 0.4 | 0.62 ± 0.4 | 0.548 ± 0.001 | 5.6 kΩ | 5.679 ± 0.001 | 5.7261 ± 0.0006 | 5.5390 ± 0.0002 |

1 Ω | 1.2 ± 0.2 | 0.86 ± 0.2 | 1.044 ± 0.001 | 8.2 kΩ | 8.539 ± 0.009 | 8.6078 ± 0.0009 | 8.1837 ± 0.0002 |

2.2 Ω | 1.6 ± 0.3 | 2.30 ± 0.5 | 2.247 ± 0.001 | 10 kΩ | 10.101 ± 0.002 | 10.1772 ± 0.0008 | 9.9313 ± 0.0002 |

5.6 Ω | 5.7 ± 0.4 | 5.70 ± 0.6 | 5.645 ± 0.001 | 22 kΩ | 21.9 ± 0.3 | 22.1858 ± 0.0008 | 21.846 ± 0.0000 |

8.2 Ω | 9.1 ± 0.2 | 7.72 ± 0.6 | 8.251 ± 0.001 | 56 kΩ | 55.0 ± 0.1 | 55.789 ± 0.002 | 55.8529 ± 0.0003 |

10 Ω | 10.5 ± 0.3 | 8.77 ± 0.5 | 10.031 ± 0.005 | 82 kΩ | 80.8 ± 0.1 | 81.891 ± 0.002 | 81.914 ± 0.002 |

22 Ω | 22.4 ± 0.4 | 20.1 ± 0.5 | 21.901 ± 0.002 | 100 kΩ | 97.3 ± 0.2 | 98.812 ± 0.003 | 98.622 ± 0.008 |

56 Ω | 59.7 ± 0.4 | 55.7 ± 0.5 | 56.023 ± 0.004 | 220 kΩ | 211.9 ± 0.4 | 217.55 ± 0.01 | 219.267 ± 0.007 |

82 Ω | 83.3 ± 0.3 | 83.1 ± 0.4 | 82.532 ± 0.0014 | 560 kΩ | 535 ± 5 | 549.7 ± 0.1 | 561.045 ± 0.009 |

100 Ω | 102.2 ± 0.3 | 101.9 ± 0.4 | 99.44 ± 0.02 | 820 kΩ | 777 ± 7 | 811.4 ± 0.2 | 824.71 ± 0.01 |

220 Ω | 224.3 ± 0.3 | 224.2 ± 0.4 | 220.560 ± 0.004 | 1 MΩ | 0.906 ± 0.007 | 0.9894 ± 0.0002 | 1.0140 ± 0.00004 |

560 Ω | 576.9 ± 0.4 | 573.6 ± 0.8 | 556.14 ± 0.01 | 2.2 MΩ | 2.14 ± 0.05 | 2.193 ± 0.004 | 2.2171 ± 0.0002 |

820 Ω | 835.8 ± 0.6 | 833.840 ± 0.0001 | 817.19 ± 0.03 | 6.8 MΩ | 6.3 ± 0.3 | 6.89 ± 0.01 | 6.986 ± 0.002 |

1 kΩ | 1.0348 ± 0.0006 | 1.0331 ± 0.0004 | 0.9945 ± 0.0001 | 8.2 MΩ | 8.8 ± 0.3 | 7.87 ± 0.05 | 8.2066 ± 0.0001 |

2.2 kΩ | 2.242 ± 0.001 | 2.2596 ± 0.0005 | 2.1955 ± 0.0001 | 10 MΩ | 10.3 ± 0.2 | 9.60 ± 0.03 | 10.129 ± 0.008 |

**Table 4.**Comparison of the ATmega328P, ATmega32U4 and Fluke 8840A measured load capacitance (C

_{LOAD}) values ± standard deviation (SD) through the fast acquisition mode.

C_{nominal} | ATmega-328P | ATmega-32U4 | Fluke PM6304 | BK 890C | ATmega-328P | ATmega-32U4 | Fluke PM6304 | BK 890C | |
---|---|---|---|---|---|---|---|---|---|

C_{LOAD} ± SD | C_{nominal} | C_{LOAD} ± SD | |||||||

1 pF | 1.126 ± 0.004 | 1.050 ± 0.005 | 12 ± 8 | 1.3 ± 0.6 | 560 pF | 550.0 ± 0.8 | 510.89 ± 0.05 | 526 ± 3 | 531 ± 3 |

1.5 pF | 1.640 ± 0.002 | 1.541 ± 0.003 | 16 ± 18 | 1.9 ± 0.3 | 680 pF | 644 ± 1 | 600.30 ± 0.05 | 678 ± 5 | 677 ± 7 |

2.7 pF | 2.834 ± 0.003 | 2.782 ± 0.004 | 14 ± 8 | 3.3 ± 0.6 | 1 nF | 1.012 ± 0.003 | 0.93558 ± 0.00004 | 0.999 ± 0.009 | 1.008 ± 0.004 |

3.9 pF | 4.101 ± 0.003 | 3.998 ± 0.004 | 12 ± 5 | 8 ± 1 | 1.5 nF | 1.445 ± 0.007 | 1.34302 ± 0.00003 | 1.493 ± 0.005 | 1.517 ± 0.002 |

5.8 pF | 5.860 ± 0.002 | 5.709 ± 0.003 | 17 ± 19 | 7 ± 3 | 2.2 nF | 2.08 ± 0.01 | 1.88744 ± 0.00004 | 2.185 ± 0.005 | 2.24 ± 0.01 |

8.2 pF | 8.527 ± 0.003 | 8.278 ± 0.003 | 17 ± 5 | 9.3 ± 0.4 | 3.3 nF | 3.29 ± 0.03 | 2.93701 ± 0.00003 | 3.314 ± 0.006 | 3.401 ± 0.003 |

10 pF | 10.231 ± 0.002 | 9.900 ± 0.002 | 18 ± 5 | 11.2 ± 0.3 | 6.8 nF | 7.4 ± 0.2 | 6.58318 ± 0.00003 | 7.096 ± 0.02 | 7.13 ± 0.06 |

20 pF | 20.711 ± 0.003 | 19.672 ± 0.002 | 25 ± 4 | 22.300 ± 0.000 | 7.5 nF | 9.0 ± 0.2 | 7.98201 ± 0.00004 | 7.56 ± 0.05 | 7.7540 ± 0.0004 |

47 pF | 46.934 ± 0.009 | 46.59 ± 0.04 | 49 ± 7 | 49.3 ± 0.5 | 10 nF | 12.0 ± 0.4 | 9.51585 ± 0.00003 | 10.15 ± 0.07 | 9.668 ± 0.001 |

82 pF | 80.88 ± 0.02 | 81.01 ± 0.02 | 89 ± 7 | 83.4 ± 0.5 | 15 nF | 20 ± 1 | 17.8541 ± 0.00004 | 15.44 ± 0.06 | 15.570 ± 0.0000 |

100 pF | 99.56 ± 0.04 | 100.87 ± 0.03 | 99 ± 5 | 103.183 ± 0.04 | 22 nF | 27 ± 1 | 28.6855 ± 0.00003 | 21.623 ± 0.007 | 22 ± 1 |

180 pF | 179.1 ± 0.1 | 178.6 ± 0.2 | 187 ± 1 | 185 ± 1 | 56 nF | 46 ± 5 | 70.0663 ± 0.00002 | 57.21 ± 0.04 | 57.2 ± 0.9 |

220 pF | 210.7 ± 0.2 | 208.5 ± 0.2 | 221 ± 12 | 217.6 ± 0.5 | 68 nF | 47 ± 5 | 75.7749 ± 0.00002 | 68.39 ± 0.07 | 69 ± 2 |

470 pF | 440.0 ± 0.7 | 409.77 ± 0.05 | 469 ± 6 | 449.9 ± 0.8 | 100 nF | 55 ± 5 | 96.2257 ± 0.00003 | 101.3 ± 0.02 | 101.536 ± 0.005 |

**Table 5.**Comparison of the ATmega328P, ATmega32U4 and Fluke 8840A measured load capacitance (C

_{LOAD}) values ± standard deviation (SD) through the transient acquisition mode.

C_{nominal} | ATmega-328P | ATmega-32U4 | Fluke PM6304 | BK 890C | ATmega-328P | ATmega-32U4 | Fluke PM6304 | BK 890C | |
---|---|---|---|---|---|---|---|---|---|

C_{LOAD} ± SD | C_{nominal} | C_{LOAD} ± SD | |||||||

100 pF | 111 ± 4 | 72 ± 1 | 99 ± 5 | 101.41 ± 0.04 | 2.2 μF | 2.259 ± 0.007 | 2.158 ± 0.006 | 2.2742 ± 0.0004 | 2.292 ± 0.005 |

1 nF | 0.703 ± 0.008 | 0.49 ± 0.01 | 0.999 ± 0.009 | 1.008 ± 0.004 | 4.7 μF | 4.933 ± 0.008 | 4.883 ± 0.009 | 4.24 ± 0.04 | 4.5010 ± 0.0006 |

2.2 nF | 1.591 ± 0.009 | 1.22 ± 0.01 | 2.185 ± 0.005 | 2.24 ± 0.01 | 6.8 μF | 6.92 ± 0.01 | 6.71 ± 0.02 | 7.1687 ± 0.0001 | 7.1870 ± 0.0001 |

4.7 nF | 3.99 ± 0.02 | 3.26 ± 0.02 | 4.77 ± 0.03 | 4.90 ± 0.03 | 10 μF | 10.31 ± 0.02 | 10.204 ± 0.009 | 9.76 ± 0.01 | 9.998 ± 0.02 |

6.8 nF | 6.10 ± 0.02 | 5.01 ± 0.05 | 7.10 ± 0.02 | 7.13 ± 0.06 | 22 μF | 23.01 ± 0.02 | 23.06 ± 0.04 | 20.98 ± 0.03 | 21.29 ± 0.03 |

10 nF | 9.43 ± 0.02 | 7.85 ± 0.04 | 10.15 ± 0.07 | 9.667 ± 0.001 | 47 μF | 49.10 ± 0.09 | 47.12 ± 0.09 | 42.69 ± 0.04 | 43.0 ± 0.5 |

22 nF | 22.10 ± 0.04 | 19.66 ± 0.04 | 21.623 ± 0.007 | 22 ± 1 | 68 μF | 70.6 ± 0.1 | 70.8 ± 0.2 | 66.39 ± 0.02 | 68.68 ± 0.06 |

56 nF | 56.89 ± 0.09 | 53.03 ± 0.06 | 57.21 ± 0.04 | 57.2 ± 0.9 | 100 μF | 104.2 ± 0.2 | 101.0 ± 0.3 | 98.14 ± 0.04 | 102.30 ± 0.08 |

68 nF | 67.22 ± 0.06 | 65.52 ± 0.05 | 68.39 ± 0.07 | 69 ± 2 | 220 μF | 225.6 ± 0.4 | 226.5 ± 0.8 | 200.29 ± 0.08 | 206.7 ± 2 |

100 nF | 97.2 ± 0.1 | 95.9 ± 0.2 | 101.34 ± 0.02 | 101.536 ± 0.005 | 470 μF | 491.9 ± 0.6 | 446.6 ± 0.8 | 455.7 ± 0.2 | 472.6 ± 3 |

220 nF | 228.3 ± 0.4 | 212.2 ± 0.2 | 221.79 ± 0.03 | 221.900 ± 0.000 | 1 mF | 1.006 ± 0.003 | 0.981 ± 0.004 | 0.9608 ± 0.0006 | 0.994 ± 0.006 |

470 nF | 480 ± 1 | 456 ± 1 | 468.54 ± 0.05 | 469.800 ± 0.000 | 2.2 mF | 2.240 ± 0.007 | 2.250 ± 0.007 | 2.1667 ± 0.0005 | 2.1987 ± 0.0000 |

680 nF | 692 ± 1 | 669 ± 2 | 665.67 ± 0.2 | 680.000 ± 0.000 | 3.3 mF | 3.62 ± 0.02 | 3.631 ± 0.009 | 3.1891 ± 0.0007 | 3.441 ± 0.002 |

1 μF | 1.047 ± 0.003 | 0.972 ± 0.003 | 0.983 ± 0.001 | 0.989 ± 0.007 | 4.7 mF | 4.85 ± 0.01 | 4.91 ± 0.01 | 4.6754 ± 0.0005 | 4.935 ± 0.003 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Inácio, P.M.C.; Guerra, R.; Stallinga, P.
An Ultra-Low-Cost RCL-Meter. *Sensors* **2022**, *22*, 2227.
https://doi.org/10.3390/s22062227

**AMA Style**

Inácio PMC, Guerra R, Stallinga P.
An Ultra-Low-Cost RCL-Meter. *Sensors*. 2022; 22(6):2227.
https://doi.org/10.3390/s22062227

**Chicago/Turabian Style**

Inácio, Pedro M. C., Rui Guerra, and Peter Stallinga.
2022. "An Ultra-Low-Cost RCL-Meter" *Sensors* 22, no. 6: 2227.
https://doi.org/10.3390/s22062227