## 2 Materials and Methods
### Conversion of a bioreactor into an IoT-Enabled System
#### 2.4.1 Gas Monitoring System  
The liquid displacement method was used to measure biogas volume production and its CH\({}_{4}\) content (Figure 1). Each setup (for biogas and CH\({}_{4}\) content) consisted of two cylinders of different diameters; the smaller (inner) cylinder, which was also taller, was placed inside the larger (outer) cylinder. Holes were made near the base of the inner cylinder to allow the displacement of liquid into the outer cylinder. A non-contact capacitive sensor was installed at a specific height on the outer cylinder and connected to an ESP32 microcontroller. The gas produced passed through a triode valve into the inner cylinder, causing the liquid to displace into the outer cylinder. Once the liquid reached the sensor, the valve was activated via a relay by the ESP32 stopping further gas entry and \begin{table}
\begin{tabular}{c c c c c} \hline \hline  & & & **Substrates** & \\ \cline{3-5} Period (Day) & **Organic Loading Rate g VS \({}^{\dagger}\)** & & **Glucose** & **Gelatin** & **Oleic Acid** \\  & **L\({}_{\mathrm{R}}\)\({}^{-1}\) d\({}^{-1}\) (value \(\pm\) SD \({}^{\ast}\))** & **g VS d\({}^{-1}\)** & **g VS d\({}^{-1}\)** & **g VS d\({}^{-1}\)** \\ \hline
1–4 & 1.00 \(\pm\) 0.05 & 30 & 4.3 & 2.2 \\
5–9 & 1.25 \(\pm\) 0.07 & 40 & 8.6 & 4.4 \\
10–14 & 1.65 \(\pm\) 0.08 & 50 & 13.1 & 6.6 \\
15–48 & 2.00 \(\pm\) 0.09 & 60 & 17.2 & 8.8 \\ \hline \hline \end{tabular} \({}^{\ast}\)SD: Standard Deviation, \({}^{\dagger}\) VS: Volatile Solids.  
\end{table} 
Table 2: Daily substrate input Organic Loading Rates for the operation period of the IoT bioreactor. releasing the measured gas. Measured gas volume calibration was performed using air, which was inserted with a syringe of similar capacity to the volume being measured. There were two main differences between the biogas volume and the CH\({}_{4}\) content measuring devices. The biogas volume device was filled with a solution of tap water and the addition of ortho-H\({}_{3}\)PO\({}_{4}\) (87% purity) to adjust the pH to approximately 3, preventing CO\({}_{2}\) absorption. For CH\({}_{4}\) content measurement, the device was filled with tap water, and a CO\({}_{2}\) scrubber filled with NaOH was used to remove CO\({}_{2}\) from the biogas, enabling accurate CH\({}_{4}\) measurements. The CO\({}_{2}\) scrubber device consisted of two 250 mL volumetric cylinders filled with packing materials. Rubber stoppers were used to close the cylinders' top to prevent biogas leakage, and they were filled with a sodium hydroxide (NaOH) solution of a 2 M concentration. The two packed cylinders were connected in a series by tubes and the CH\({}_{4}\) gas flowing from them was measured by the liquid displacement device described above. Biogas taken directly by the bioreactor was introduced to the first packed cylinder by a small peristaltic pump activated by a relay through the ESP32. The peristaltic pump was activated for a specific period (3 min), introducing the same volume (180 mL) of biogas each time. Two DC-powered mini valves, controlled by the ESP32, were installed: one between the final CO\({}_{2}\) scrubber and the CH\({}_{4}\) volumetric device, and another between the biogas injection pump and the first CO\({}_{2}\) scrubber. These valves were activated 5 min after each measurement to release any residual trapped biogas, preparing the system for the next measurement. Methane content of biogas was measured twice a day at specific times, calculated using Equation (1):  
\[M_{b}=100\frac{YV_{m}}{V_{p}} \tag{1}\]  
where the symbols of the equation correspond to the following:  
\(M_{b}\) = Daily methane content of biogas (%);  
\(Y\) = number of sensor activations in 24 h;  
\(V_{m}\) = standard methane volume measured each time the sensor was activated (mL);  
\(V_{p}\) = standard volume of biogas introduced during the specific period when the peristaltic pump was activated (mL).