## 2 Materials and Methods
### Conversion of a bioreactor into an IoT-Enabled System
#### 2.4.2 Sensor Monitoring System of pH, REDOX, Temperature, and Ammonium  
The system was developed using an ESP32 microcontroller, connected to various sensors for the online measurement of pH, REDOX potential, temperature, and ammonium of the anaerobic bioreactor (Figure S1). It featured a 2\({}^{\prime\prime}\) display to show current measurements. Specifically, pH, REDOX potential, temperature, and ammonium were measured in real time, with data updates displayed every 15 s (Figure S1). All the components mentioned below were integrated into a circuit (Figure S6) with the ESP32 as its core and a software flowchart is provided as Supplementary Materials (Figure S8). The pH value was monitored using the GE 117-BNC electrode combined with GPHU 014 MP-BNC transducer to convert the signal to a 4-20 mA output (Greisinger GmbH, Regenstauf, Germany). The REDOX potential was monitored using the GE 175-BNC electrode while the GRMU 2000 MP-BNC transducer also provided a 4-20 mA signal, both manufactured by Greisinger GmbH (Regenstauf, Germany). Both electrodes were suitable for measuring pH and REDOX of a biogas bioreactor and were installed through specific ports on the bioreactor to ensure constant contact with the liquid substrate. Two Gravity: I2C Digital Wattmeter converters (Zhiwei Robotics Corp, Shanghai, China) were used to read the output signals from the GPHU 014 MP-BNC and GRMU 2000 MP-BNC transducers. These converters can receive current signals in mA and convert them into digital signals via the Inter-Integrated Circuit (I\({}^{2}\)C) communication protocol, allowing the ESP32 to process and store data over an internet connection. The pH and REDOX devices were factory calibrated. Measurements were taken with different standard solutions to create equations that allowed ESP32 to accurately calculate sensor values (Figure S2). The temperature was measured by DS18B220 sensor (Texas Instruments, Dallas, TX, USA) with waterproof protection for immersion in liquids. This sensor was connected directly to the ESP32 using a Dallas 1-Wire digital output and was housed in a stainless-steel thermowell that was immersed in the liquid within the bioreactor. The sensor has a temperature range of \(-55\,^{\circ}\)C to \(+125\,^{\circ}\)C, a resolution of 9-12 bits, and an accuracy of \(\pm 0.5\,^{\circ}\)C.  
Ammonium was monitored using the Ammonium 3051 Combination Ion Selective Electrode (ISE) (Sentek, Braintree, UK). It was connected via a pH/OPR Adapter 1130 manufactured by Phidgets Inc. (Calgary, AB, Canada) which provided analog voltage output. This adapter was connected to ADS115 16-Bit ADC over I\({}^{2}\)C which is a four-channel programmable gain amplifier (Adafruit Industries, New York, NY, USA) and can be interfaced by an ESP32. The equation (Figure S3) for calculating the ammonium concentration was created with solutions made in the laboratory by using distilled water and the addition of ammonium chloride (NH\({}_{4}\)Cl) in varying concentrations that corresponded to specific voltage outputs, except of the ammonium solutions 100 ppm and 1000 ppm (Chem-Lab, Zedelgem, Belgium). The ammonium electrode could not be installed directly in the reactor for continuous measurements, as the membrane at the tip of the electrode could become clogged by suspended particles or damaged by prolonged exposure to the reactor environment [25; 26]. When the electrode was not in use, the manufacturer recommended that the electrode tip be immersed in a 100 ppm ammonium standard solution. To address this, an external measurement cell (Figures 2 and S1) was constructed from acrylic material. The setup had two positions for electrodes of similar dimensions, allowing for measurements to be taken outside the bioreactor using fresh samples of its content. The filling of the cell with new material from the bioreactor, washing it with the 100 ppm ammonium standard and emptying it, were performed by three low-cost peristaltic pumps, controlled by the ESP32 via relays (Table S1).