GSM & SMS Enabled AI-driven (TinyML) Water Pollution Monitor
In this project, I focused on developing an AI-driven budget-friendly device to collect water quality data from various water resources in the field and forecast water pollution levels based on oxidation-reduction potential (ORP), pH, total dissolved solids (TDS), and turbidity measurements.
📌 Why is water pollution a global issue?
Since we incessantly pollute our limited water resources, which are already drowning in chemicals, waste, plastic, and other contaminants, it is crucial to eschew water pollution before it is too late for relieving the plight of people lacking safe drinking water. Although there are international efforts and campaigns to plummet water contaminants, it is yet a pressing issue to track water pollution levels locally to get prescient warnings regarding possible health and environmental risks.
In addition to threatening terrestrial animals, plants, and marine life, water pollution is jeopardizing our health. Unsafe water kills more people each year than war and all other forms of violence combined. Meanwhile, our drinkable water sources are meager: Less than 1 percent of the Earth's clean (fresh) water is actually accessible to us. Without action, the challenges will only increase by 2050, when global demand for freshwater is inferred to be one-third greater than it is now. We may even have less time than expected since water is uniquely susceptible to pollution. Water is widely described as the universal solvent since it can dissolve more substances than any other liquid on the Earth. Hence, harmful and toxic substances, mostly chemicals or microorganisms, can effortlessly contaminate a stream, river, lake, ocean, aquifer, or other body of water, degrading water quality and rendering it toxic to humans or the environment.
📌 Water quality measurements to detect water pollution
After perusing recent research papers on water pollution, I decided to utilize oxidation-reduction potential (ORP), pH, total dissolved solids (TDS), and turbidity measurements denoting water pollution (contamination) so as to create a budget-friendly device to forecast water pollution levels locally in the hope of obviating the need for expensive equipment to detect contamination and forfend perilous pollution effects.
Oxidation-reduction potential (ORP) is a measurement of ion exchange: Chemical substances with a negative ORP value can donate extra ions, but positive ORP values lead to ion absorption. When the ORP value is high in the water, bacteria decompose dead tissue and contaminants more efficiently. In general, the higher the ORP value, the healthier the body of water is. However, ORP values decrease closer to the bottom sediments, even in clean water resources, since many bacteria are working hard in the lower sediments to decompose dead tissue. Therefore, they use up most of the available oxygen. Since oxygen disappears quickly in the bottom mud (often within a centimeter or two), ORP values decrease quickly.
The pH is of importance in determining the corrosivity of water, but the relationship with several other parameters is complex. Natural waters contain gases, colloidal matter, and a variety of electrolyte and non-electrolyte material, and these, together with pH, determine the extent of corrosion in a system. However, in general, the lower the pH, the higher the potential level of corrosion. The pH of most drinking water lies within the range of 6.5–8.5. Natural waters can be of lower pH, for example, as a result of acid rain or higher pH in limestone areas.
Total dissolved solids (TDS) is the term used to describe the inorganic salts and small amounts of organic matter present in solution in water. The principal constituents are usually calcium, magnesium, sodium, and potassium cations and carbonate, hydrogencarbonate (bicarbonate), chloride, sulfate, and nitrate anions. TDS in water supplies originates from natural sources, sewage, urban and agricultural run-off, and industrial wastewater. Salts used for road de-icing can also contribute to the TDS loading of water supplies.
Turbidity in water is caused by suspended particles or colloidal matter that obstruct light transmission through the water. It may be caused by inorganic or organic matter or a combination of the two. Microorganisms (bacteria, viruses, and protozoa) are typically attached to particulates, and removal of turbidity by filtration will significantly reduce microbial contamination in treated water. Turbidity is measured by nephelometric turbidity units (NTU) and can be initially noticed by the naked eye above approximately 4.0 NTU. However, to ensure the efficacy of disinfection, the turbidity should be no more than 1 NTU and preferably much lower.
📌 Why did I need to build a neural network model to forecast water pollution?
Although ORP, pH, TDS, and turbidity measurements provide insight into detecting water pollution, it is not possible to extrapolate and interpret water pollution levels accurately by merely employing limited data without applying complex algorithms since water pollution levels fluctuate according to various phenomena. Therefore, I decided to build and train an artificial neural network model by utilizing the experimentally assigned pollution classes to predict water pollution levels based on ORP, pH, TDS, and turbidity measurements.
📌 Why did I design my device based on the Arduino MKR GSM 1400?
Since I needed to collect data from water resources in the field to create a valid data set, I decided to employ an Arduino MKR GSM 1400 compatible with GPRS. To obtain ORP, pH, TDS, and turbidity measurements, I connected DFRobot water quality sensors and a DS18B20 waterproof temperature sensor to the MKR GSM 1400. Then, I added an SH1106 OLED display to monitor the collected data in the field.
After transmitting data over GPRS successfully, I developed a web application in PHP to log the transferred data in a CSV file before building and training my neural network model. Then, I tested my web application on an Apache server hosted on my Raspberry Pi 4.
📌 Training data and neural network creation
Since the MKR GSM 1400 is not widely preferred to run neural network models, most platforms and official TinyML libraries do not support it. Notwithstanding the foregoing, Neuton supports almost every available microcontroller on the market to run TinyML models effortlessly, thanks to its unique model structure. Therefore, after completing my data set, I built my artificial neural network model (ANN) with Neuton to make predictions on water pollution levels (classes) based on ORP, pH, TDS, and turbidity measurements. As labels, I employed the experimentally assigned water pollution classes for each data record while collecting data in the field:
After training and testing my neural network model, I uploaded and executed the model on the MKR GSM 1400. Therefore, the device is capable of detecting precise water pollution levels (classes) by running the model independently. Also, after running the model successfully, I employed the MKR GSM 1400 to transmit the prediction (detection) result via SMS to a given mobile number.
Lastly, to make the device as sturdy and robust as possible while enduring harsh conditions in the field, I designed a Squirtle-themed case with a sliding cover (3D printable).
So, this is my project in a nutshell 😃