INTEGRATED MICROCONTROLLER MQ SENSORS FOR MONITORING BIOGAS: ADVANCEMENTS IN METHANE AND HYDROGEN SULFIDE DETECTION

gas metana


INTRODUCTION
Fossil fuels, including oil, natural gas, and coal, currently provide most of the world's energy needs.However, increasing concerns about energy security and the environmental impacts of greenhouse gas emissions have prompted interest in renewable energy sources [1], [2].Biogas, which is comprised primarily of methane (CH 4 ) 45-75% and carbon dioxide (CO 2 ) 25-45% [3], is one such renewable fuel that can be sustainably produced through the biological conversion of organic materials in the absence of oxygen, known as anaerobic digestion (AD) [4], [5].
Compared to other renewables like solar, wind, or hydropower, biogas offers unique advantages as an energy source that is continuously available, storable, and flexible for electricity, heating, or vehicle fuel [6], [7].In addition, biogas production through anaerobic digestion provides an efficient waste management solution that helps mitigate potent greenhouse gas emissions from organic waste streams, including manure, crop residues, and food waste [8].
Cow dung is particularly suitable for biogas production because of its 55−65% methane content.The high cellulose and hemicellulose content in cow dung can be efficiently converted to methane by anaerobic digestion [9], [10].The biogas production involves mixing cow dung with water and feeding it into a sealed underground anaerobic digester tank [11], [12].
Municipal solid waste (MSW) refers to household trash and rubbish collected by local authorities from residential and commer-cial areas.MSW mainly contains biodegradable organic components such as food waste, garden waste, and paper products, which have great potential for conversion to biogas through anaerobic digestion [13].
With rapid urbanization worldwide, volumes of MSW are rising sharply, posing a challenge for environmentally sustainable disposal.Landfilling and incineration also have limitations.Anaerobic digestion provides an alternative waste treatment method that produces clean energy as an end-product and digestate that can be used as fertilizer [14].
The anaerobic digestion process involves four phases: hydrolysis, acidogenesis, acetogenesis, and methanogenesis.In hydrolysis, extracellular enzymes released by hydrolytic bacteria convert complex insoluble organic polymers such as carbohydrates, proteins, and lipids into soluble monomeric units like sugars, amino acids, and fatty acids [15], [16].
Subsequently, in the acidogenesis phase, acidogenic bacteria ferment these monomers into intermediate products, including volatile fatty acids (VFAs), alcohols, hydrogen, and carbon dioxide.These intermediates are then converted into acetic acid, carbon dioxide, and hydrogen by acetogenic bacteria during acetogenesis [17].The last phase is methanogenesis; methanogens utilize acetic acid, carbon dioxide, and hydrogen to generate methane gas [18].
Measurement of methane is imperative given its dual significance as a potent greenhouse gas and combustible biofuel.The methane concentration determines the calorific value of gases generated from renewable feedstocks, including biogas and landfill gas [19].Conventional methane gas measurement has many disadvantages, such as relatively expensive costs and low measurement efficiency.
Additionally, the measurement results cannot be delivered in real time.The measurement of hydrogen sulfide (H 2 S) present in biogas is imperative, as hydrogen sulfide is considered an impurity.Hydrogen sulfide is highly corrosive and can induce rapid cor-rosion in metallic materials.This occurs because hydrogen sulfide gas dissociates into hydrogen (H+) and bisulfide (HS-) ions when dissolved in water [20], [21].Therefore, measuring both gases CH 4 and H 2 S is essential to determine the characteristics of biogas.
Laboratory analysis of methane composition usually employs gas chromatography with thermal conductivity detection.Alternative methane measurement instrumentation such as infrared Draeger 6811960 and GEM2000/5000 (Geotech et al.) sensors have been applied for in situ biogas and sewer line gas monitoring [22].However, limitations exist with these analytical techniques, including high capital costs and the requirement for substantial sample volumes.The MQ-4 is an affordable semiconductor-based methane detector that measures CH 4 concentrations ranging from 200 to 10,000 ppm.
The sensor shows optimal functionality within an ambient temperature range of 10 to 50°C and relative humidity below 95% [23], [24].The MQ-4's sensitivity to methane combined with adjustments for temperature/humidity enables real-time monitoring of biogas methane content under typical anaerobic digester operating conditions.This sensor can be integrated with microcontroller devices such as Arduino, Raspberry, and other microcontrollers [6].
This research investigates the concentrations of methane (CH 4 ) and hydrogen sulfide (H 2 S) gases produced in small-scale anaerobic digestion biogas systems utilizing 100% cow dung and a 50:50 mixture of cow dung with municipal solid waste (MSW) as substrates.The biogas systems were integrated with microcontroller technology utilizing an ATmega 2560 microcontroller for real-time monitoring and data acquisition.
In addition to gas concentrations, the ambient and digester temperatures were observed throughout the anaerobic digestion process.The acquired real-time data on temperature profiles and biogas composition from the integrated monitoring systems may facilitate the identification of optimal temperature ranges and organic loading rates to maximize methane yields in these smallscale biogas digesters.

METHOD Materials
The material tested in this paper is biogas generated from 100% cow dung and a 50:50 mixture of cow dung with MSW (Municipal et al.).The use of 100% cow dung is considered due to its abundant availability and specific characteristics.Cow dung contains approximately 18−20% volatile solids on a dry weight basis, including carbohydrates, proteins, fats, cellulose, hemicellulose, and lignin [25], [26].
The carbon-to-nitrogen ratio in fresh cow dung averages around 20:1, which is optimal for methanogenic bacteria to carry out anaerobic digestion.Cow dung also possesses a natural population of hydrolytic, fermentative, acetogenic, and methanogenic microbes required to catalyze the four stages of anaerobic digestion.Globally, biogas derived from cow dung is composed of around 55-70% methane, 30-50% carbon dioxide, and trace amounts of other gases [27].In addition, biogas can also be produced through landfills, as shown in Table 1.
Table 1.The MSW used in this research included banana, tomato, and carrot peels.Banana peels are a promising feedstock for biogas digesters due to their high carbohydrate and nutrient content.The main components are cellulose, hemicellulose, lignin, starch, and sugars.The biogas yield from banana peels with a cow manure content of 10% at 18 and 22 g of volatile solids (gvs) per liter was 50.20 and 40.49gvs per day, respectively [28].

Landfill
The actual yield can vary based on digester conditions and retention time.Tomato peels are rich in sugars and nutrients like nitrogen.The high moisture content and soft texture make them easily degradable [29].Carrot peels also have high carbohydrate and nitrogen content.Their lignin content is lower than other vegetable wastes, making them more readily degraded by anaerobic bacteria [30].

Instrumentation Details for Experimental Setup
The anaerobic digestion process was conducted in a plastic drum digester under batch conditions, with 100% cow dung and a 50:50 mixture of cow dung with MSW as the feedstock.The biogas plant operated at mesophilic temperature, and a highly active methanogenic community was present to facilitate the AD process.The experimental schematic is shown in Figure 1.Anaerobic digestion experiments were performed using an instrumented lab-scale digester continuously monitored by methane (CH 4 ), hydrogen sulfide (H 2 S), and temperature sensors interfaced to an ATmega 2560 microcontroller system.
Methane and hydrogen sulfide gas were detected using MQ-4 and MQ-136 metal oxide semiconductor sensors in the digester headspace.The sensors operate on a resistance change principle when target gases are absorbed onto the heated sensor surface.Analog voltage signals proportional to gas concentrations are produced based on sensor resistances calculated through a Wheatstone bridge circuit with an output range of 0−5V corresponding to 0−10,000 ppm [31].Temperature profiling utilized a type K thermocouple probe with chromel and alumel conductors to generate a temperature-dependent voltage via the thermoelectric effect.The millivolt-level output spans the −270°C to 1300°C measurement range [32].The sensors were connected via jumper cables to analog inputs of the ATmega 2560, an 8-bit AVR RISC microcontroller clocked at 16MHz with 256KB flash and 8KB SRAM memory.ATmega 2560 specification can be seen in Table 2. Analog voltages from the sensors were digitized by the 10-bit analog-to-digital converter at a sampling rate of 1 kHz for high-resolution realtime data.Serial I2C communication enabled a liquid crystal display interfacing to visualize the measured parameters.An Arduino IDE programming environment facilitated custom firmware development for sensor data acquisition, processing, logging, and control.Realtime sensor measurements were transmitted over USB to a PC for 21 days.All measurement results are stored on the microSD and integrated with the microcontroller.

Setup of Microcontroller Configuration with MQ Gas Sensors
The analog input pin A0 on the ATmega 2560 microcontroller is connected to the analog output pin A0 on the MQ-4 gas sensor.
The analog input pin A1 on the ATmega 2560 is connected to the analog output pin A0 on the MQ-136 gas sensor.The VCC (power) pins on both gas sensors are connected to the 5V power rail on the ATmega 2560, while the GND (ground) pins on the sensors are wired to the ground rail on the ATmega 2560.
The positive and negative thermocouple wires from the K-type thermocouple are connected to the input terminals on the MAX6675 thermocouple amplifier, whose SCK (serial Finally, the ATmega 2560 interfaces with the PC via a USB connection, as shown in Figure 2. The actual implementation of the microcontroller system with integrated sensors can be observed in Figure 3.The programming code is shown in Figure 4.

RESULTS AND DISCUSSION Response of MQ-4 of Samples of Biogas
Figure 5 shows the response of the MQ-4 gas sensor to biogas over three trial repetitions, each spanning 2 minutes, with measurements recorded every second.The MQ-4 sensor being utilized in this experiment is designed to detect and measure methane concentration levels in biogas mixtures.The biogas sample analyzed contains an approximate methane concentration of 3000 ppm.
As evident in Figure 5, the sensor measurements demonstrate the presence of small-scale random fluctuations and variability throughout the sampling duration.
Based on the three trials, this measured response exhibits a mean methane concentration of 3578 ppm.To quantify the variability, the standard deviation was 55.1 ppm, corresponding to 1.540% of the mean value.This relatively low standard deviation expresses little dispersion around the mean.In other words, the replicated trials aligned well, without substantial deviations between them under consistent test conditions.

Monitoring Methane and Hydrogen Sulfide Concentration in Anaerobic Digester (AD)
Figure 7 shows the variation in methane concentration between 100% cow dung and a 50:50 mixture of cow dung with MSW.There was no significant difference.Both samples were similar after six days of investigation.Methane concentration increased sharply in 100% cow dung, reaching 1224 ppm at approximately 12 days of incubation under mesophilic conditions at 35°C.This correlates to the exponential CH 4 production phase as methanogenic archaea generate biogas from intermediates like volatile fatty acids formed during initial hydrolysis and acetogenesis steps [23].
In contrast, the 50:50 mixture of cow dung with MSW co-digestion feedstock showed lower CH 4 , reaching just 562 ppm by day 12.The delayed and reduced CH 4 production is likely due to the increased proportion of complex particulate organics in MSW, requiring longer hydrolysis than readily biodegradable cow dung [3].Moreover, at 18 days, the methane concentration in 100% cow dung increased to 3046 ppm, while it reached 1284 ppm for the 50:50 mixture of cow dung with MSW.
The significantly higher CH 4 levels in mono-digestion of cow dung can be attributed to the fiber-rich composition, which provides ideal substrates for acetoclastic methanogenesis [33].Cow dung contains a significant amount of methane produced during the normal digestive process.
Figure 7 also shows that the methane concentration in both samples increases as the investigation time increases.In addition, the highest methane concentration was observed in 100% cow dung at 3488 ppm, while it was 1624 ppm for the 50:50 mixture of cow dung with MSW.As expected, cow dung's high cellulosic and hemicellulosic content promotes maximal methane generation by the endogenous gut archaea.In contrast, slowly biodegradable and inert fractions in MSW diluted the CH 4 -producing potential in the co-digestion.Cow dung contains sulfur-bearing organic compounds which serve as precursors for H 2 S production.These include proteins like keratin and enzymes, amino acids such as methionine and cysteine, and other sulfur organics excreted in the manure [34].The sulfur compounds get converted to H 2 S gas during the anaerobic digestion process.Moreover, at around 15 days, both samples The hydrogen sulfide concentration in the 50:50 mixture of cow dung with MSW tends to be lower than 100% cow dung.This is due to MSW containing lower sulfur content than cow dung [35].MSW provides more balanced nutrition for methane-forming archaea, reducing H 2 S formation.The maximum hydrogen sulfide observed in 100% cow dung was 195 ppm at 21 days of investigation.Inside a digester, anaerobic bacteria convert and ferment the organic matter in cow dung into biogas.
Sulfur compounds are metabolized into hydrogen sulfide and other sulfur byproducts like carbonyl sulfide.Factors including pH, temperature, and organic loading rate impact H 2 S production.More free hydrogen ions can react with sulfur species at a neutral pH level to form H 2 S. Higher temperatures speed up reaction kinetics.Overloading digesters can inhibit methane-forming archaea, leading to increased H2S formation.Longer retention times also allow more sulfate reduction to H 2 S [36].

Monitoring Environmental and Anaerobic Digester (AD) Temperatures
Figure 9 shows environmental variations and anaerobic digester (AD) temperatures.From the observation, the digester temperature is relatively higher than the sur-rounding environment temperature throughout the study period.This phenomenon can be attributed to the closed, insulated nature of anaerobic digesters, which retain the heat produced during the bacterial breakdown of organic matter.In contrast, the temperature of the surrounding environment is lower as external weather conditions influence it.At three days, the digester temperature was observed to be 43°C, while the surrounding environment was 35°C.
On the other hand, at nine days, the temperature of both samples decreased by 35°C in the digester and 28°C in the surrounding environment temperature.This temperature decline may have been caused by lower microbial activity or feedstock input rates during this period.The highest temperature observed was 44°C in the digester around 3 days of investigation.

Microcontroller Role for Anaerobic Digestion Monitoring System
Due to its technical specifications and connectivity, the ATmega 2560 microcontroller has significant potential for real-time monitoring and control applications in biogas systems.The 8-bit AVR RISC-based processor operating at 16MHz provides sufficient computational performance for anaerobic digestion process control algorithms.Substantial compiled code and sensor data can be stored with 256KB of program memory and 8KB RAM.Sixteen 10-bit ADC channels allow interfacing with analog biogas sensors to measure methane, hydrogen sulfide, and temperature quantitatively.
Digital I/O enables control of valves, pumps, and heating elements for automation.UART, I2C, and SPI buses support adding wireless modules for remote monitoring.The omega 2560's proven reliability in industrial environments, cost-effectiveness, and availability of programming libraries like Arduino make it highly adaptable for continuous sensing, logging, and real-time control in biogas plants.With proper integration of modern sensors and prudent firmware design, the ATmega 2560 has considerable scientific merit for increasing biogas yields through fine-grained monitoring of anaerobic digestion and automated system optimization.

CONCLUSION
This study demonstrates the effectiveness of microcontroller-implemented sensors for monitoring the quantification of critical process parameters in small-scale anaerobic digesters.Experimental data were collected on methane (CH 4 ), hydrogen sulfide (H 2 S), and temperature levels during a 21-day mesophilic digestion investigation utilizing substrate formulations of 100% cow dung and a 50:50 mixture of cow dung with municipal solid waste (MSW).
Results indicate higher CH 4 production for the mono-digestion of cow dung compared to co-digestion, with maximum concentrations reaching 3488 ppm at day 21.Negligible differences in H 2 S evolution were observed between the two feedstock conditions, approaching 195 ppm and 192 ppm for the cow dung and co-digestate, respectively.Operating temperatures were maintained below the mesophilic threshold throughout the investigation.The microcontroller-enabled monitoring system provided continuous, high-accuracy measurements of biogas composition, facilitating data analysis.Overall, this research validates the promise of automated on-site sensors for evaluating and optimizing small-scale biogas digesters.

Figure 1 .
Figure 1.Experimental schematic of a microcontroller-integrated biogas system Source: Researchers' analysis (2023) clock) pin is connected to digital I/O pin 12, CS (chip select) pin to digital I/O pin 11, and SO (serial data out) pin to digital I/O pin ten on the ATmega 2560.The I2C interface pins SCL (serial clock) and SDA (serial data) on the 16x2 LCD are connected to the SCL and SDA pins on the ATmega 2560 at digital I/O pins 21 and 20, respectively.Power and ground for the LCD come from the 5V and GND rails on the ATmega 2560.The SPI interface pins on the mi-croSD card -MISO (master in, an enslaved person out), MOSI (master out, an enslaved person in), SCK (serial clock), and CS (chip select) -are connected to digital I/O pins 50, 51, 52 and 53 respectively on the ATmega 2560.

Figure 6
Figure 6 shows the response of the MQ-136 sensor to biogas over three repeated trials.The MQ-136 sensor was used to monitor hydrogen sulfide concentration levels every second for two minutes during each trial repetition.The hydrogen sulfide concentration exhibited fluctuations throughout the three trials, ranging from a minimum of 171.04 ppm to a maximum of 191.36 ppm.The observed fluctuations in biogas levels during the repeated trials highlight the importance of conducting multiple measurements to adequately characterize sensor response and account for inherent variability.The three repeats' mean, and standard deviation (expressed as % of mean) were 189.297 ± 0.057%.

Figure 7 .
Figure 7. Varied methane concentrations between 100% cow dung and a 50:50 mixture of cow dung with MSW Source: Researchers' analysis (2023) Variations in hydrogen sulfide concentration between 100% cow dung and a 50:50 mixture of cow dung with MSW are shown in Figure 8. From the figure, the hydrogen sulfide concentration increased significantly in both samples.At five days, the hydrogen sulfide concentration was 117 ppm in 100% cow dung, while 102 ppm for the 50:50 mixture of cow dung with MSW.Cow dung contains sulfur-bearing organic compounds which serve as precursors for H 2 S production.These include proteins like keratin and enzymes, amino acids such as methionine and cysteine, and other sulfur organics excreted in the manure[34].The sulfur compounds get converted to H 2 S gas during the anaerobic digestion process.Moreover, at around 15 days, both samples

Figure 9 .
Figure 9. Temperature variance between the anaerobic digester (AD) and the surrounding environment Source: Researchers' analysis (2023)