Water quality monitoring systems find use in aquaponics, farming, wastewater treatment, environmental monitoring, and even industrial applications for chemical processes that require ultra-pure water or an extremely specific aqueous solution needed to optimize said processes..
It turns out the water quality is kind of a big deal. How big one might ask? By some estimates, somewhere between $4-5B USD in market value on an annual basis, and growing quickly as the integration of sensors and data-drive agriculture and animal husbandry accelerates.
It also turns out measuring water quality fairly complicated. There are a wide range of chemical, biological, physical, and environmental indicators to take into account. What’s more is that most of these indicators tend to require dedicated, highly specialized sensors with an analog output that requires some signal conditioning in order to obtain accurate results.
The system detailed here provides a modular and extensible system by utilizing several low-cost PIC16F15245 microcontrollers to connect several common water quality sensing elements (pH, water-level, temperature) over an I2C bus topology. The system was tested on one of the team members fish tanks.
NOTE: no fish were harmed in the development and testing of this system.
For this project, we kept it simple by using 3 sensors common in most water quality monitoring systems: a pH sensor, a water-level sensor, and finally a thermocouple temperature sensor.
The goal here was two fold: firstly, we decided early on that the system was to be extensible, meaning that functionality should be relatively easy to add without having to reconfigure the entire system.
Secondly, we decided that to opt for a design with high degree of modularity. There are many cases where a water quality monitoring system will have multiple instances of the same sensor placed in various places in the water or fluidic system. Areas can include tanks, reservoirs, mixing chambers. and pipes - all of which comprise various sizes, compositions, and perhaps even some additional sensor needs.
Due to the desire for extensibility and modularity, we opted for a distributed system communicating over a short distance I2C communications bus to connect all the sensors using the several low-cost PIC16F15245 microcontrollers from the new PIC16F15244 family of Microcontrollers. This fulfilled the requirement for both a modular and scalable system while allowing for an extremely low-cost processing device.
The design permits additional sensors and devices can be added over time as long as it is in compliance with the I2C bus specification. Furthermore, the design permits any of the subsystems below to be easily incorporated into other designs as needed.
The Atlas Scientific Consumer Grade pH probe was chosen as it is suitable for my simple tank monitor. It works by measuring the hydrogen ion activity in a liquid. Most freshwater fish do best at a pH of 6.8-7.6, so the sensor will give me an idea of when I need to change the water. On a side note, you can imagine how a larger system like a public pool uses similar types of these sensors (albeit, industrial grade ones). That big tub of water you love to cool off in during the summer months is a carefully monitored aquatic environment. Chlorine, Hydrofluoric acid, water circulation, pool occupancy level and radiation from the sunlight all impact the cleanliness of water, and pH is just one of the metrics used here.
The DROK temperature sensor is sealed in a stainless steels sleeve so it can remain safely submerged in water for long periods of time, thereby reducing the frequency of maintenance needed.
The Gikfun Liquid Level Sensor was selecting, and basically consists of just a simple read switch comprising shaft with two metal contacts at the lower end. A hollow cylindrical float surrounds the shaft and houses a magnetic ring that pushes the two metal contacts together when the water level is low
Development:This section covers the main aspects of development, the tools used, and some issues that were encountered in the development process.
I2C and Floats
One of the challenges faced here was transmitting the 24-bit float value derived from the pH sensor over the I2C bus. The I2C bus expects arrays of bytes to be sent across the bus. To deal with this issue, a sub-routine was implemented to convert the 24-bit float to 3 bytes to be sent across the bus. These 3-bytes are then reassembled by the receiving device into the original 24-bit float. If you check out the source code you can see some redundancy was included in the routine for checking the integrity of the data to ensure there were no errors in the translation.
Using the Demo:You can set up the system or any of the associated sub-systems provided you have the hardware tools above. Further modification of the demo will certainly require the MPLAB X IDE and XC8 toolchain, for which there are links below.
Resources:TB3251 - Using the MSSP in I2C Slave Mode
TB3252 - Using the MSSP in I2C Master Mode
AN3538 - A Simple Water Monitoring System with I2C Communication
Christopher Best, Patrick Kennedy

Comments
Please log in or sign up to comment.