By Topic

• Abstract

SECTION I

## INTRODUCTION

Clean water is one of the most important resources required to sustain life and the quality of drinking water plays a very important role in the well-being and health of human beings [1]. Water supply to taps at urban homes and water sources available in more rural areas, is however, not necessarily safe for consumption [2], [3]. Even though it is the government’s responsibility to ensure that clean water is delivered to its citizens, ever aging infrastructure, which is poorly maintained, and continual increase in population puts a strain on the supply of clean water [4], [5].

It is thus paramount to monitor the quality of water which will be used for consumption. In [6] monitoring is defined as the collection of information at set locations and at regular intervals in order to provide data which may be used to define current conditions, establish trends, etc. Traditional water quality monitoring methods involve sampling and laboratory techniques [7], [8]. These methods are however time consuming (leading to delayed detection of and response to contaminants) and not very cost effective. There is thus a need for more extensive and efficient monitoring methods.

Water quality monitoring can be achieved through microbial measurements as well as physiochemical measurements [9]. Physiochemical parameters include electrical conductivity, pH, oxidation reduction potential (ORP), turbidity, temperature, chlorine content and flow. These parameters can be analysed quickly and at less cost than the microbial parameters and can also be measured with on-line instrumentation. Studies conducted by the United States Environmental Protection Agency (USEPA) [10] have shown that water parameters are affected by contaminants in specific ways and can be detected and monitored using appropriate water quality sensors. Commercially available products capable of monitoring such parameters are usually bulky and quite expensive. Monitoring with sensor technology [11] is still not very effective [12], as they do not always meet the practical needs of specific utilities; although cheaper than traditional equipment, cost, reliability and maintenance issues still exist; and data handling and management can also be improved.

In this paper the development of a a low-cost, wireless, multi-sensor network for measuring the physicochemical water parameters; enabling real-time monitoring, is presented. The system implements flow, temperature, conductivity and pH sensors from first principles. All the data from the sensors are processed and analysed, and transmitted wirelessly to a notification node. Algorithms are developed to detect possible contaminations. The notification node informs the user as to whether the water quality parameters are normal or abnormal.

The rest of this paper is organised as follows. Section II reviews the related works that were investigated and considered important to this project. Section III describes the factors that were taken into consideration when designing the system. Section IV provides a brief overview of the modules of the system. Section V describes the design and implementation of the system. In section VI the simulation results are presented. The observations and results are discussed in Section VII, and finally the paper concludes with Section VIII.

SECTION II

## RELATED WORK

Various studies involving the implementation of water quality monitoring systems using wireless sensor network (WSN) technology can be found in literature.

In [13] a distributed system for measuring water quality is designed and implemented.Temperature, conductivity, pH and turbidity sensors are connected to a field point, wherefrom data is sent using a GSM (global system for mobile communications) network to a land based station. The focus of this study is however on the processing of the sensor data using Kohenen maps (auto-associative neural networks).

A WSN-based water environment system which senses and monitors video data of key areas and water parameters such as temperature, turbidity, pH, dissolved oxygen and conductivity is presented in [14]. Data is sent from the data monitoring nodes and data video base station to a remote monitoring center using ZigBee and CDMA (code division multiple access) technology.

The water monitoring system implemented in [15] analyses and processes water quality parameters (pH, conductivity, dissolved oxygen and temperature), and also sounds an alarm when there is a water contamination, or change in water quality. The parameters are measured with off-the shelf sensors and data is sent to a base station via GPRS (general packet radio service).

In [16] a ZigBee based WSN water quality monitoring and measurement system is presented. The system enables remote probing and real-time monitoring of the water quality parameters and also enables observation of current and historical water quality status.

A river basin scale WSN for agriculture and water monitoring, called SoilWeather is implemented in [17]. The network uses GSM and GPRS technology for transmission of sensor data.

A turbidity system is proposed in [18], which is low-powered [19], small-sized, easy-to-use and inexpensive.

In [20], the DEPLOY project is introduced to monitor the spatial and temporal distribution of water quality and environmental parameters of a river catchment. It is intended to demonstrate that an autonomous network of sensors can be deployed over a wide area and the system measures parameters such as pH, temperature, depth, conductivity, turbidity and dissolved oxygen.

A microcontroller-based WSN system is proposed in [21] to measure pH, chlorine concentration and temperature in a pool. Data is transmitted using GSM and in sleep mode the sensor nodes are shown to consume $27~\mu \text{A}$.

In [22] a WSN system is used to measure the water quality of fresh water and uses solar daylight harvesting for optimised power management. The data collected from the various sensor nodes are sent to a sub-base node and from there to a monitoring station using a GSM network.

A low-cost, real-time, in-pipe sensor node with a sensor array for measuring flow, pH, conductivity, ORP and turbidity, is designed and developed in [8]. Contamination event detection algorithms are also developed to enable sensor nodes to make decisions and trigger alarms when contaminants are detected.

In [23] a WSN based on ISO/IEC/IEEE 21451 standard for monitoring of surface water bodies is presented, to capture possible severe events and collect extended periods of data.

As can be observed from the literature study, most water quality monitoring systems have sensing nodes, are able to perform wireless communication and process the data from the sensors [24] to achieve meaningful results.

SECTION III

## METHOD

To design the proposed water quality monitoring system, various water quality sensor design principles (since the sensors are designed from first principles), wireless communication systems and water quality parameters were investigated.

### A. Instrumentation and Water Quality Parameters

The first step was to determine which water quality parameters would be monitored for the assessment of the drinking water quality, to accurately determine whether the water quality is within the specified regulations of the World Health Organization (WHO) [1]. It was determined from [8] that water parameters such as nitrate levels, free chlorine concentration and dissolved oxygen are too expensive to monitor and/or require frequent maintenance and calibration to sustain accurate readings over long periods of time. This would not be feasible for a long-term, real-time water quality monitoring system.

The water parameters which are the focus of this project are pH, temperature, conductivity, flow, and ORP. These physicochemical parameters can be used to detect certain water contaminations. Conductivity gives an indication of the amount of impurities in the water, the cleaner the water, the less conductive it is. In many cases, conductivity is also directly associated with the total dissolved solids (TDS). The pH of the water is one of the most important factors when investigating water quality, as it measures how basic or acidic the water is. Water with a pH of 11 or higher can cause irritation to the eyes, skin and mucous membrane. Acidic water (pH 4 and below) can also cause irritation due to its corrosive effect. ORP is a measure of the tendency of a solution to either gain or lose electrons. A positive ORP reading indicates that water is an oxidizing agent, and a negative reading indicates a reducing agent (or antioxidant). Normal tap water has an ORP value of between 200-400 mV. ORP is a non-standardized water quality indicator, but WHO recommends that the ORP of drinking water should not exceed 60 mV. Both the pH and ORP parameters are difficult to measure accurately as reference electrodes are required. These reference electrodes typically hold a solution with a known pH or ORP value and require recalibration when used over long periods of time. The flow and temperature measurements of the water are required for compensation, as these parameters can have an effect on other parameters. The required and/or recommended ranges for human consumption of each water parameter have already been determined by the WHO guidelines [1] and the study conducted in [8]. The specified ranges are layed out in Table 1.

Table 1 Parameters to be Monitored as Adapted From [8]

### B. Sensor Design Alternatives

Various sensor designs [25] were investigated to enable accurate measurements of the water quality parameters mentioned above.

#### 1) The Flow Sensor

The flow of water in a pipe is usually measured by litres per minute (l/min) or litres per hour (l/hour). There are numerous flow sensor designs that are in use: rota-meter, magnetic-flow meter, turbine flow meter and a Venturi-tube flow meter.

In this study the turbine flow meter Figure 1 is considered as it is able to make digital readings, is readily available and cheaper than the Venturi-tube flow meter. The turbine flow meter [26] translates the mechanical action of a rotating turbine inside the pipe into readable measurements with a magnetic pickup that is used to produce the output signal.

Figure 1. The turbine flow meter as in [26].

#### 2) Temperature Sensor

A temperature sensor is used to measure the temperature of the water. There are various temperature sensor types: a thermocouple, thermistor or a solid state temperature sensor.

A thermistor temperature sensor is considered in this study as there is better design control and designing such a sensor from first principles is easier. Thermistors are generally used for applications below 300 °C and would therefore be sufficient for a system that operates at ambient temperatures. A thermistor is essentially a resistor with a temperature dependent resistance. Due to its resistive nature, an excitation source is required to read the voltage across the terminals. The measured voltage is proportional to the temperature with either a negative temperature coefficient (NTC) or a positive temperature coefficient (PTC). This correlation is not linear, especially for large temperature regions, but can be compensated for with the Steinhart-Hart equation. Thermistors are inexpensive and widely used for many types of applications due to the small size and reasonable accuracy.

#### 3) Conductivity Sensor

The conductivity of water is an indication of the amount of ions and/or free flowing electrons that are present for the conduction of electricity. This is usually measured in Siemens per meter (S/m) or micro-Siemens per centimeter ($\mu \text{S}$/cm).

The conductivity sensor is designed using the two- or four-electrode method is based on Ohms law. With a known resistor, voltage and current the resistance of the water solution can be calculated accordingly. This calculation also requires the cell constants which are the length and area of the water sample [27].

The resistance of the water is measured by using two or four electrodes with a known cell constant. Cell constants usually range from about 0.1 cm $^{-1}$ to 10 cm $^{-1}$, where higher cell constants work more effectively for higher conductivity solutions. To determine the resistance between the electrodes, a voltage is applied across the electrodes.

The two-electrode method is considered in this study as it is easier to maintain and more economical [28].

#### 4) pH Sensor Alternatives

The pH of water is an important parameter to monitor because high and low pH levels can have dangerous effects on human health. The pH of a solution can range from 1 to 14. One method of measuring pH is through the use of a conventional glass electrode with a reference electrode setup, the other is using an Ion-Selective-Field-Effect-Transistor (ISFET).

For this study the pH sensor will consist of a conventional glass electrode as these electrodes are more reliable and economical for long term monitoring. The glass membrane at the bottom, Figure 2, is doped to be ion-selective and is only sensitive to a specific ion (in most cases the hydrogen ion). The pH electrode acts like a single cell battery and there is a direct correlation between the voltage output of the electrode and the pH of the measured water.

Figure 2. The pH electrode sensor used to carry out measurements.

#### 5) Oxidation Reduction Potential

The ORP is measured in millivolts (mV). ORP electrodes are quite similar to pH electrodes and are thus sometimes combined into a combination sensor. The ORP electrode uses a different reference solution and electrode than the pH sensor, typically KCL Ag/Ag-Cl. This sensor is purchased off-the-shelf as an additional sensor to the system. It did however require signal conditioning to interface with the microcontroller.

### C. Wireless Communication

Information from the sensors is relayed wirelessly to a notification node. For this project, a wireless transmitter and receiver module is purchased off-the-shelf. Some wireless communication protocols which are generally used include UWB (ultra wideband), Wi-Fi, Bluetooth and ZigBee [29]. UWB is suitable for low-power, very short-range communication with high speed data rates (typically 10 m). Wi-Fi is based on the IEEE 802.11 specification and has a high data rate with long range capabilities (up to 100 m), but has higher power consumption. ZigBee is based on the IEEE 802.15.4 standard and can reach 250 kbps data rate with a distance of 10 m 70 m. The data rate, although less than the possible 11 Mbps data rate of Wi-Fi, is adequate for this project. The biggest advantages of the ZigBee specification modules are the low power consumption and little to no infrastructure requirements. Two standalone ZigBee specification modules can be used for wireless communication, one being used as a transmitter, whilst the other is used as a receiver.

SECTION IV

## SYSTEM OVERVIEW

The system consists of two modules, as shown in Figures 3 and 4.

Figure 3. Module 1: the measurement and sensing node setup.
Figure 4. Module 2: the notification node setup.

In Figure 5 each sensor produces a signal that requires signal conditioning in order to interface with the microcontroller. The microcontroller is chosen so that multiple analogue signals can be read and processed. The signal is converted to fit within the allowable ADC (analog-to-digital converter) voltage range of 0 to 3.2 V. In the case of the flow sensor a pulsed signal is conditioned to interface with the microcontroller’s interrupt pin. Once the various signals have been read by the microcontroller the applicable equations can be used to process the raw data into usable measurements. The microcontroller then converts the measured values in float variables to char variables. The char values can then be transmitted across the wireless modules through serial communication.

Figure 5. Module 1: the measurement and sensing module block diagram.

To inform the user of the current state of the water, a notification node was required as a user interface. In Figure 6 the transmitted data from the measurement node is received via the wireless receiver module. These char values are then reconstructed back into to float values. The user interface requires both a visual and audible element. The visual element is for relaying information on each water parameter and the audible element is for warnings. These values are then displayed on the LCD (liquid crystal display) with their respective name and units. The microcontroller also checks if the water parameters are within safe limits, if they are not, the buzzer is activated for a short period of time when the applicable parameter is displayed.

Figure 6. Module 2: the notification module block diagram.
SECTION V

## SYSTEM DESIGN

The system, as shown in Figure 7 is split into four sub-systems; the sensing node; the measurement node; the wireless node; and the notification node. The sensing node contains all the water quality sensors, as well as the signal conditioning circuits required to interface with the measurement node. The measurement node consists of a microcontroller that processes the raw sensor data and then transmits the data to the wireless transmitter module. The wireless transmitter and receiver modules are part of the wireless node and are used to relay the data to the notification node. The notification node receives data from the wireless receiver module and then notifies the user in real-time of the water quality.

Figure 7. The system layout.

### A. Temperature Sensor

The main concern of a thermistor is the non-linear relationship between the temperature and the resistance. For this project a temperature range of 0 °C to 40 °C is considered. Thermistors are useful up to temperatures of 300 °C, thus the smaller operating range assists in counteracting the non-linearity. The resistance can however be scaled using the general form of the Steinhart-Hart thermistor third order approximation:TeX Source$$\frac {1}{T}=A+B\cdot \ln (R)+C\cdot (\ln (R))^{3}$$

Where $T$ is the temperature in Kelvin and $R$ the measured resistance in Ohm. $A$, $B$ and $C$ are constants that are manufacturer specific.

The layout of the thermistor circuit consists of a constant known input voltage and a series resistor (with a known value set up as a voltage divider with a specifically chosen thermistor). The voltage read across the thermistor is then fed into an operational amplifier (op-amp) to adjust the gain and offset. This conditions the voltage measurement for analogue-to-digital conversion at the microcontroller. Figure 8 below represents the circuit design. From Figure 8, the initial unity gain buffer is used for its high input impedance. This restricts the circuit from disturbing the original circuit.

Figure 8. The temperature sensor circuit design.

The goal of this sensor circuit is to read the potential difference of the thermistor and condition the signal to a 0 to 3.2 V ADC compatible voltage range. 3.2 V is chosen as the maximum $V_{ADCMAX}$, as the microcontroller is limited to 3.3 V on its input pins.

The voltage divider, created with $R1$ and the thermistor is used to measure the voltage across the thermistor. The thermistor that was chosen is a NTH300XW203J01 with a 20 $\text{k}\Omega$ resistance at 25 °C. The nominal $\beta$ for this thermistor is typically 3950 to 3999. For the calculations a $\beta$ of 3950 is used. The resistance to temperature characteristics are given as follows:TeX Source$$R_{T}=R_{0}\cdot e^{\beta \cdot \left({\frac {1}{T}-\frac {1}{T_{0}}}\right)}$$

Where $R_{T}$ is the thermistor resistance at $T$, which is the temperature in Kelvin. $T_{0}$ is 298.15 Kelvin (or 25 °C) and $beta$ is taken from the manufacturers datasheet. Equation 2 is also used in the following form.TeX Source$$T=\frac {\beta }{\ln \left({\frac {R}{r_{\infty }}}\right)}$$

Where TeX Source$$r_{\infty }=R_{0} \cdot e^{-\beta /T_{0}}$$

With these equations one can calculate what resistances to expect over the desired temperature range. The temperature range that is considered for monitoring is 0 to 40 °C. Using equation 3 and 4 the following parameters were calculated, as shown in Table 2.

Table 2 Thermistor Parameters

For maximum linearity, the rate of change of voltage versus temperature ($T$) must be equal for both the maximum and minimum desired temperatures, as described with the following equation.TeX Source$$\frac {dV_{0}}{dT}=\frac {dV_{0}}{dR_{T}}\cdot \frac {dR_{T}}{dT}$$

Where $V_{0}$ is the voltage across the thermistor, $R_{T}$ is the thermistor resistance and $T$ the temperature in Kelvin.

The resistance of the ideal series resistor $RS$, $R1$ can be calculated for maximum linearization with the following second order equation, which is an expansion from equation 5.TeX Source\begin{align}&\hspace {-2pc}\left[{\frac {dR_{TMIN}}{dT_{TMIN}} -\frac {dR_{TMAX}}{dT_{TMAX}}}\right] \cdot R_{S}^{2}\notag \\&+\, 2\cdot \left[{R_{TMAX} \cdot \frac {dR_{TMIN}}{dT_{TMIN}} - R_{TMIN}\frac {dR_{TMAX}}{dT_{TMAX}}}\right]\cdot R_{S} \notag \\&+\, R_{TMAX}^{2} \cdot \frac {dR_{TMIN}}{dT_{TMIN}} - R_{TMIN}^{2} \cdot \frac {dR_{TMAX}}{dT_{TMAX}} = 0 \end{align}

Where $T_{TMIN}$ is the lowest operational temperature and $T_{TMAX}$ is the highest operational temperature. $R_{TMIN}$ is the thermistor resistance at $T_{TMIN}$ and $R_{TMAX}$ is the thermistor resistance at $T_{TMAX}$. $R_{S}$ is the series resistance.

A simpler (yet still very accurate) method is to choose $R_{S} = R_{T0}$, where $R_{T0}$ is the thermistor resistance at the middle of the desired operational temperature range. Thus $R_{S}$ is chosen as 25 $\text{k}\Omega$.

For this desired range the maximum and minimum voltages of $V_{ADC}$ are calculated using the following voltage division equations:TeX Source\begin{align} V_{OUTMAX}=&V_{IN} \cdot \frac {R_{TMIN}}{R_{TMIN}+R_{S}}\notag \\ V_{OUTMAX}=&3.3 \cdot \frac {67241}{67241+25000}\notag \\ V_{OUTMAX}=&2.406 V \\ V_{OUTMIN}=&V_{IN} \cdot \frac {R_{TMAX}}{R_{TMAX}+R_{S}} \notag \\ V_{OUTMIN}=&3.3 \cdot \frac {10602}{10602+25000}\notag \\ V_{OUTMIN}=&0.983 V \end{align}

Where $R_{T}$ is the thermistor resistance and $R_{S}$ is the series resistance.

The gain required from the op-amp is calculated with the following equation.TeX Source\begin{align} G=&\frac {V_{ADCMAX}}{V_{OUTMAX}-V_{OUTMIN}}\notag \\ G=&\frac {3.2}{2.406 - 0.983}\notag \\ G=&2.25 \approx 2 \end{align}

Where $G$ is the gain and $V_{ADCMAX}$ is the maximum voltage allowable to enter the ADC. Note that a gain of 2 is chosen to be safe. The new $V_{ADCMAX}$ is then 2.85 V.

The offset is calculated with the following equation.TeX Source\begin{align} V_{OFFSET}=&-G \cdot V_{OUTMIN}\notag \\ V_{OFFSET}=&-(2)\cdot (0.983)\notag \\ V_{OFFSET}=&-1.966 \end{align}

The output voltage $V_{ADC}$ of the op-amp is calculated with the following equation.TeX Source$$V_{ADC} = V_{0} \cdot G\cdot \frac {R_{T}}{R_{T}+R_{S}} + V_{OFFSET}$$

Where $V_{0}$ is the voltage across the thermistor and $G$ is the gain of the op-amp. $V_{OFFSET}$ is the required voltage to cancel out the $V_{ADC}$ offset. In other words, the voltage divider created by $R3$ and $R4$ should equal the offset. The op-amp configuration allows the voltage produced by the voltage divider to cancel out the offset on the output voltage, giving a potential 0 to 3.2 V output.

### B. The Conductivity Senor

The Figure 9 block diagram for the design of the conductivity sensor.

Figure 9. The conductivity sensor block diagram.

The AC source is constructed from a 555-timer to produce a low frequency (1 to 2 kHz) square wave. The square waves amplitude is specified as 5 V and has an offset of 0 V. The 555-timer is powered with the positive and negative 5 V rails supplied by the respective linear voltage regulators. The problem with this setup is that the common 555-timer does not produce a rail-to-rail output. The output would be roughly −5 V to +4 V. To compensate for this the 555-timer can be powered with the positive 9V rail instead of the positive 5V rail. The output will have a voltage swing of roughly −5 V to +8 V. This signal is then limited to a 5 V amplitude by means of a Zener diode setup to allow a square wave to pass through, as shown in Figure 10.

Figure 10. AC voltage clipping with Zener diodes.

However an easier way to produce the required AC signal was to use a CMOS based 555-timer. These use less current but also have a lower maximum output current. Even though the output current is more limited, it is still sufficient for this design. The reason for using the CMOS based 555-timer is for the rail-to-rail output.

It should be noted that 555-timers have the tendency to create noise spikes in the power source rails. The CMOS based timer reduces this effect but can still be problematic. De-coupling capacitors are used where necessary.

The 555-timer is configured as an Astable Multivibrator, which means that there are no stable output states as it switches between high and low continually. The following equations are used to calculate the resistor and capacitor values for a 2 kHz square wave with a 50 % duty cycle.TeX Source\begin{align} Duty~Cycle=&\frac {R_{A} + R_{B}}{R_{A} + 2 \cdot R_{B}} \\ f=&\frac {1.44}{(R_{A}+2 \cdot R{B})\cdot C_{1}} \end{align}

From equation 12 and 13, by choosing $R_{A} = 10~\text{k}\Omega$, $R_{B} = 100~\text{k}\Omega$ and $C_{1} = 3.3$ nF, a duty cycle of 52.4 % is achieved with a frequency ($f$) of 2.08 kHz.

The 555-timer setup with the calculated values is given in Figure 11.

Figure 11. The 555-timer circuit design.

The produced AC signal travels through the voltage divider containing the conductivity electrodes (which are seen as a variable resistor). The series resistors resistance is calculated accordingly. First the expected resistance range from the conductivity cell is calculated. Typical drinking water has a conductivity of around 50 to $500~\mu \text{S}$/cm. Using Ohms law the resistance is calculated. The resistivity is then calculated by dividing the resistance with the cell constant. The cell constant, is the distance between the sampling electrodes divided by the area of said electrodes. The conductivity is then simply the inverse of the resistivity. The following equation is used to calculate the conductivity.TeX Source$$\sigma = \frac {l}{A\cdot R_{C}}$$

Where $\sigma$ is the conductivity in $\mu \text{S}$/cm, $l$ is the distance between the electrodes, $A$ is the area of the electrodes and $R_{C}$ is the measured resistance of the electrodes.

Important parameters for this sensor are shown in Table 3.

Table 3 Conductivity Sensor Parameters

The cell constant is chosen as 2.4 ($l = 0.6$ cm; $A = 0.5$ cm $\times \,\, 0.5$ cm). With this value the maximum and minimum expected resistances is calculated as follows:TeX Source\begin{align} R_{\sigma MIN}=&\frac {l}{A} \cdot \frac {1}{\sigma MAX}\notag \\ R_{\sigma MIN}=&2.4 \cdot \frac {1}{50\times 10^{-6}} = 48 k\Omega \end{align}

Where $R_{\sigma MIN}$ is the resistance expected at the lowest conductivity measuring point $(\sigma MIN)$.TeX Source\begin{align} R_{\sigma MAX}=&\frac {l}{A} \cdot \frac {1}{\sigma MAX}\notag \\ R_{\sigma MIN}=&2.4 \cdot \frac {1}{2000\times 10^{-6}} = 1.2 k\Omega \end{align}

Where $R_{\sigma MAX}$ is the resistance expected at the highest conductivity measuring point $(\sigma MAX)$.

The voltage read from the voltage divider between the series resistor and the conductivity cell does not have a linear relationship with the conductivity cell resistance. Thus the series resistance is chosen so that the relationship can be approximated using a second order polynomial trend line. With the use of a Microsoft Excel spreadsheet and the voltage division calculation, a suitable series resistance was chosen ($R_{S} = 65~\text{k}\Omega$). The voltage division equation is given below.TeX Source$$V_{C}(\sim ) = \frac {R_{C}}{R_{C}+R_{S}}V_{AC}(\sim )$$

Where $R_{C}$ is the conductivity cell resistance, $V_{AC}$ is the root mean square (RMS) value of the AC voltage produced by the 555-timer circuit and $V_{C}$ is the RMS voltage read across the conductivity cell.

Figure 12 below displays the gathered data in graph form.

Figure 12. The conductivity cell resistance versus ADC voltage.

The second order polynomial approximation is given as:TeX Source\begin{align} V_{ADC} = -4.861\! \times \!10^{-10} \cdot R_{C}^{2} + 6.53 \times 10^{-5} \cdot R_{C} \!+\! 0.0418\!\!\!\!\!\notag \\ {}\end{align}

Where $R_{C}$ is the resistance conductivity in the cell.

When the voltage is read using the MCUs ADC module, the resistance is calculated using the inverse of equation 15 which is given below.TeX Source$$R_{C}= 67200 \pm 1434.27 \sqrt {2237 - 1000 V_{ADC}}$$

For $V_{OUT}$ in Figure 13 to be readable by the microcontrollers ADC module, the signal is first converted to a DC signal. The following active full wave rectifier setup, given in Figure 14, was chosen for the AC to DC conversion.

Figure 13. The conductivity cell voltage divider circuit.
Figure 14. The full wave rectifier circuit.

An active setup with op-amps was chosen as real diodes have a forward diode drop and small reverse current. Op-amps can be used with diodes to create better properties and limit unwanted influences on the signal. $C1$ in Figure 14 may be needed to prevent oscillation.

The signal then passes through a low pass filter to complete the AC to DC conversion. The low pass filter is given in Figure 15.

Figure 15. The low pass filter ($f_{c} = 15.9$ Hz).

The cut-off frequency is calculated using the first order low pass equation.TeX Source$$f_{c} = \frac {1}{2\pi RC} = \frac {1}{2\pi (1000)(10 \times 10^{-6})} = 15.9 Hz$$

Where $R$ is the resistance, $C$ is the capacitance and $f_{c}$ is the cut-off frequency.

The produced DC signal is then fed into the MCUs ADC module after it has been limited to a maximum of 3.3 V. This was possible by using a Zener diode based voltage limiter circuit. The Zener diode voltage limiting circuit is given in Figure 16. The reason for the voltage limiting circuit is because as the conductivity reaches $0~\mu$ S/cm, the resistance goes to infinity and the measured voltage can approach 4 V.

Figure 16. The zener diode voltage limiting circuit.

Conductivity is temperature dependent and is compensated for in the software by using the reading from the temperature sensor. For most water applications the temperature can be compensated for with a linear 2%/°C adjustment, where the specific centre point is chosen as 25 °C.

### C. The Flow Sensor

This design utilises a small turbine that is rotated by the water flow. A magnetic Hall Effect sensor outputs a voltage pulse every time a blade passes over the sensor. Typical turbine flow meters require a voltage source of 5 to 12 V. Thus the output pulses produced by the attached Hall Effect sensor are typically the same voltage as that of the source provided. This voltage is limited to 3.3 V so that it can interface with the microcontroller. A unity gain buffer with a 3.3 V Zener diode is used to limit the voltage as shown in Figure 17.

Figure 17. The flow sensor signal conditioning circuit.

In the figure above R1 is chosen as a relatively low resistor to ensure that the Zener diode receives sufficient current to stay in reverse breakdown. The smaller the resistance the closer the Zener diode voltage comes to reaching the specified breakdown voltage. Thus even if R1 is chosen a slight bit too high the output voltage will only be slightly lower than 3.3 V, which isnt an issue for this design. The current required by the Zener diode is specified in the manufacturers datasheet and is typically between 1 to 5 mA.

### D. The pH Sensor

The pH electrode can be seen as a single cell battery with a very high resistance which outputs a voltage linearly proportional to the pH of the water sample. The typical voltage output ranges from −430 mV to +430 mV. Each pH unit change represents roughly a 60 mV change in the output voltage.

The ideal pH electrode can be described as in Table 4.

Table 4 The Voltage and pH Indicators

It should be noted that pH is temperature dependent. By using the temperature measurement from the temperature sensor, the following compensation equation can be applied.TeX Source$$pH_{C} = pH-((T-T_{0})\cdot (pH_{0}-pH)\cdot 0.003)$$

Where $pH_{C}$ is the compensated pH value, pH is the measured pH value and $pH_{0}$ is the centre pH value of 7. T is the temperature in °C and $T_{0}$ is the centre temperature value of 25°C. The 0.003 value is the correction factor in pH/ °C /pH.

The 430 mV output voltage from the electrode is converted to range of 0 to 3.2 V so that it can interface with the microcontrollers ADC module. To achieve this result the output voltage is amplified and an offset is applied. Figure 18 shows the design circuit used.

Figure 18. The pH sensor signal conditioning circuit.

In the figure 18, U1 represents the op-amp responsible for amplifying the signal and U2 represents the op-amp responsible for the offset. U2 is set up as a differential amplifier with a gain of 2, thus the required offset produced by the voltage divider between R5 and R6 is divided by two beforehand.

The pH electrode output range of 860 mV is amplified to 3.2 V with the following gain. A standard non-inverting configuration was used.TeX Source\begin{align} G=&\frac {3.2 V}{0.86 V}= 3.72 \\ G=&3.72=1+\frac {R1}{R2} \end{align}

Thus, TeX Source$$\frac {R1}{R2}=2.72$$

Where $G$ is the gain, $R2$ and $R1$ are the respective resistors from Figure 18. $R2$ is chosen as 27 k and $R1$ as 10 k.

The offset is logically chosen as 1.6 V therefore the voltage divider between $R5$ and $R6$ should produce a voltage of 0.8 V. $R5$ was chosen as 126 k and $R6$ was chosen as 24 k. $R7$ is included as a simple current limiting resistor for the microcontroller.

Capacitors $C1$ and $C2$ are used to attenuate any high frequency noise.

### E. The Oxidation Reduction Potential Sensor

The implementation of this design is very similar to that of the pH design. This is due to the fact that the ORP electrode can also be seen as a single cell battery with a very high resistance which outputs a voltage (which is also linearly proportional to the ORP of the water sample). The typical voltage output ranges from −2000 mV to +2000 mV. The difference with the ORP electrode is that the output voltage is equal to the ORP value of the water. The 4V range presents a problem as it is too high for the microcontroller. Therefore the amplitude is reduced and a similar offset to that of the pH electrode (1.6 V) is applied.

Due to the requirement of a gain lower than 1, an inverting configuration is used with a unity buffer for the ORP electrode voltage output. Figure. 19 shows the design circuit used.

Figure 19. The ORP sensor signal conditioning circuit.

In the figure 19, $U1$ represents the op-amp responsible for reducing the signal amplitude and $U2$ represents the op-amp responsible for the offset. $U2$ is set up as a differential amplifier with a gain of 2, thus the required offset produced by the voltage divider between $R5$ and $R6$ is divided by two beforehand (similar to the pH offset setup).

The ORP electrode output range of 4 V is reduced to 3.2 V with the following gain. A standard inverting configuration was used as discussed.TeX Source\begin{align} G=&\frac {3.2 V}{4 V}=0.8 \\ G=&0.8=\frac {R1}{R2} \end{align}

Thus, TeX Source$$\frac {R1}{R2}=0.8$$

Where $G$ is the gain, $R2$ and $R1$ are the respective resistors from Figure. 19 $R2$ is chosen as 16 $\text{k}\Omega$ and $R1$ as 20 $\text{k}\Omega$.

The offset is logically chosen as 1.6 V therefore the voltage divider between $R5$ and $R6$ should produce a voltage of 0.8 V. $R5$ was chosen as 126 $\text{k}\Omega$ and $R6$ was chosen as 24 $\text{k}\Omega$. $R7$ is included as a simple current limiting resistor for the microcontroller.

### F. The Measurement Module

The measurement node consists of a PIC32MX220F032B microcontroller unit (MCU). This node comprises mostly of software based data conversion, analysis and transmission.

Figure 20 shows the minimum required connections to operate the microcontroller as described by the datasheet.

Figure 20. The minimum required connections for the microcontroller operation.

The functional flow chart of the measurment node is given in Figure 21.

Figure 21. Flow chart of the measurement node.

### G. The Wireless Module

The universal asynchronous receiver/transmitter (UART) communication module is used for serial communication between the microcontrollers and the XBee modules. This means that communication will be in the form of 8 bit characters sent at a typical baud rate of 4800 or 9600. The XBee modules are set up as shown in Figure 22.

Figure 22. The XBee wireless module.

The notification node consists of the same microcontroller as that of the measurement node; a PIC32MX220F032B microcontroller. This node is mostly implemented in the software. The LCD display and buzzer forms part of this node as well.

A flowchart of the notification module is given in Figure 23.

Figure 23. The functional flowchart for the notification node.

A magnetic 9 V buzzer is used as an audible alert when a water quality parameter reaches an unsafe level. A trimmer potentiometer is used to control the volume of the buzzer. An n-channel metal-oxide-semiconductor field-effect transistor (MOSFET) was used as a switch. The MOSFET transistor is activated by applying a voltage to the gate pin which is larger than the gate threshold voltage (typically 0.7 V). This allows the microcontroller to control the buzzer.

SECTION VI

## SIMULATION RESULTS

After the design of the various subsystems, their functions were first simulated (with LTSpice ) before the final designs were implemented.

### A. The Temperature Sensor

The simlutions for the temperature sensor are shown in Figure 24.

Figure 24. The temperature sensor simulations.

In the figure, $V1$ represents the voltage across the thermistor. A voltage sweep is performed with $V1$ from the minimum to the maximum calculated voltage (0.983 V to 2.406 V). The expected output from the op-amp $U1$ should read from 0 to 2.85 V as specified in the design. Figure 24 below shows the resultant output.

It can be observed that the output voltage range is indeed approximately 0 to 2.85 V. For a higher voltage resolution the gain can be increased from 2 to 2.25.

### B. The Conductivity Sensor

The voltage across the conductivity cell (which is seen as a variable resistor)is represented by $V1$. V1 outputs a square wave which is rectified by the full wave rectifier. The signal then passes through the low pass filter which effectively smoothes the produced DC signal.

In Figure 25 a high voltage AC signal is converted to a DC signal. The AC input and DC output is superimposed on the same figure. In Figure 26 a low voltage AC signal is converted to a DC signal.

Figure 25. The conductivity circuit simulation 1.
Figure 26. The conductivity circuit simulation 2.

### C. The PH Sensor

The voltage output from the pH electrode which ranges from −430 mV to 430 mV, is represented by $V1$. The expected output from $U2$ is 3.2 V to 0 V. The simulations are as shown in Figure 27.

Figure 27. The pH sensor simulation.

As can be seen in the Figure 27, the result was a success. For a precise offset and gain in the practical implementation, trimmer potentiometers can be used for adjustment and calibration.

### D. The ORP Sensor

In the Figure 28, $V_{out}$ represents the voltage output from the ORP electrode which ranges from -2000 mV to 2000 mV. The expected output of U2 is 0 V to 3.2 V. The result can be observed in Figure 28.

Figure 28. The ORP sensor simulation.

As can be observed from the Figure 28 the result was a success. As discussed with the pH circuit design, trimmer potentiometers can be added for fine tuning of the offset and gain in the practical circuit.

SECTION VII

## EXPERIMENTAL RESULTS

Various experimental setups were executed to determine how well the system functioned and the equipment typically used for testing are: a bench power supply and oscilloscope, a computer with MPLAB X installed, a PICkit 3 debugger and various circuits to simulate the sensor responses.

### A. Qualification Test 1: Temperature Sensor

The temperature sensor was expected to have an accuracy of ±2 °C. The sensor was tested for a temperature range of 0 °C to 40 °C.

Two qualification tests were conducted to determine the accuracy of the designed temperature sensor. First the accuracy of the signal conditioning circuit was tested along with the calculated values on the microcontroller. Secondly, the sensor as a whole was tested, with the thermistor in place, against a purchased thermometer.

The signal conditioning results are shown in Figure 29. The theoretically simulated temperature in the signal conditioning circuit versus the calculated temperature measurement on the microcontroller. The small Zener diode bypass line shows the calculated temperature measurement without the Zener diode voltage limiting circuit. The following were observed: the average difference between the theoretically simulated temperature and measured temperature was 0.66 °C, the maximum difference was 2.5 °C, and 1 out of the 19 data points in the tested range was outside of the required accuracy of 2 °C.

Figure 29. Temperature signal conditioning results.

The results of the temperature sensor versus thermometer shown in Figure 30, indicate the standard thermometer temperature measurement versus the built temperature sensor. The following were observed: the average difference between the temperature measured by the thermometer and temperature sensor was 0.071 °C, and the maximum difference was 1 °C.

Figure 30. Temperature sensor results.

The signal conditioning test result indicated that the accuracy requirement of 2°C transgressed at one data point in the lower edge of the temperature range (approaching 0°C), whilst in the higher temperature range (approaching 40°C) the accuracy was mostly within 0.1°C. It can also be observed that the Zener diode protection circuit does indeed affect the measurement as the voltage approaches 3 V.

The temperature sensor test results indicate that the accuracy for the test range was well within 2 °C. It can also be observed that the range between 0 °C and 5 °C was not tested and could potentially yield inaccurate results due to the Zener diode voltage limiting affect noticed in the signal conditioning test results.

### B. Qualification Test 2: Conductivity Test

The conductivity sensor was built based on a 2-electrode method design. The sensor was expected to have an accuracy of at least 15%.

The test was conducted to observe the accuracy of the signal conditioning circuit, along with the calculated values on the microcontroller.

The signal conditioning test results are given in Figure 31 and shows the theoretically simulated conductivity in the signal conditioning circuit versus the calculated conductivity measurement on the microcontroller. The effect of the Zener diode voltage limiting circuit on the measurement is not shown on the figure as it would not be visible on the scale. However, bypassing the Zener diode resulted in an average accuracy improvement of 5% in the lower conductivity ranges.The results are as follows: the average difference between the theoretically simulated conductivity and measured was 2.91%, and less than 4% difference at the critical value of $780~\mu \text{S}$/cm.

Figure 31. Conductivity signal conditioning results.

The signal conditioning test results showed that the accuracy requirement of 15% transgressed at one data point. However this point is outside of the maximum conductivity range of $2000~\mu \text{S}$/cm. Thus when excluding the out of range data point, the next biggest error is equal to 14.74% which is inside the 15% accuracy requirement.

### C. Qualification Test 3: Flow Sensor

The flow sensor was constructed based on the turbine flow meter design. The signal conditioning circuit and software implementation was done from first principles. The signal conditioning circuit mostly limited the amplitude of the voltage pulses. A qualification test was conducted to observe the accuracy of the software implementation. The flow meter hardware was already verified by the manufacturer to be 2.25 ml per pulse. Thus the microcontroller software implementation was tested to see whether the pulse counts and calculations were correct and within the specified accuracy. An additional simple test was conducted by installing the flow sensor on a faucet to confirm that the flow sensor did indeed measure water flow.

The signal conditioning test results are shown in Figure 32, show the theoretically simulated flow in the signal conditioning circuit versus the calculated flow measurement on the microcontroller. The flow was simulated using a function generator. The results were as follows: the average difference between the theoretically simulated flow and measured flow was 0.28%, and the maximum difference was 6.28%.

Figure 32. Flow signal conditioning resuts.

For the actual flow test, the maximum flow that was available from the faucet was measured as 9.3 litres per minute. The flow range covered on the microcontroller is 50 litres per minute.

The accuracy declines as the flow decreases. The maximum error of 6.28% is well within the required 25% accuracy.

### D. Qualification Test 4: pH Sensor

The pH sensor was built based on the glass electrode with reference electrode design. The sensor has an accuracy of at least 0.4 pH units.

Two qualification tests were conducted to observe the accuracy of the constructed pH sensor. First the accuracy of the signal conditioning circuit was tested along with the calculated values on the microcontroller. Secondly the sensor as a whole was calibrated using two pH buffer solutions (pH = 4 and pH = 7). The electrode operates as a single cell battery with a variable DC voltage of −430 to +430 mV.

The signal conditioning test results are given in Figure 33 and show the theoretically simulated pH in the signal conditioning circuit versus the calculated pH measurement on the microcontroller. The pH was simulated using a trimmer potentiometer setup as a voltage divider.The results obtained were as follows: the average difference between the theoretically simulated pH and measured pH was 0.016, the maximum difference was 0.51, and 1 out of the 24 data points in the tested range was outside of the required accuracy of 0.4.

Figure 33. pH Sensor conditioning results.

The buffer solution test showed that the uncalibrated pH sensor measurements was within 0.2 accuracy. The trimmer potentiometer was then used to alter the gain of the signal which resulted in a measurement of 3.9 when testing the 4.0 solution. For the pH buffer solution calibration test: the 7.0 pH solution was measured as 6.9 and the 4.0 pH solution was measured as 3.8.

From the signal conditioning test result it can be observed that the accuracy requirement of ±0.4 was transgressed at one data point with an error of 0.51. This error was produced at the highest edge of the pH range (approaching a pH of 14). The test using the buffer solutions showed that the uncalibrated sensor was within the required accuracy of ±0.4.

### E. Qualification Test 5: ORP Sensor

The ORP sensor was built based on the glass electrode with reference electrode design. The sensor has an accuracy of at least ±25 mV.

The accuracy of the signal conditioning circuit was tested along with the calculated values on the microcontroller. The electrode operates as a single cell battery with a variable DC voltage of −2000 mV to +2000 mV which is equal to the actual ORP value of the water.

The conditioning test results are given in Figure 34 and show the theoretically simulated ORP in the signal conditioning circuit versus the calculated ORP measurement on the microcontroller. The ORP was simulated using a trimmer potentiometer set up as a voltage divider. The following results were obtained: the average difference between the theoretically simulated ORP and measured ORP was 3.98 mV, and the maximum difference was 24.14 mV at the edge of the positive range

Figure 34. ORP signal conditioning results.

From the signal conditioning test result it can be seen that the accuracy requirement of ±25 mV was not transgressed. The maximum error was produced at the highest edge of the ORP range (approaching 2000 mV).

### F. Qualification Test 6: Measurement Node

The measurement node consists of a PIC32MX220F032B microcontroller and is responsible for converting raw sensor data into usable values.

The qualification test for this microcontroller forms part of the above qualification tests 1 to 5. These five qualification tests not only test the sensors but also the software implementation. Thus to confirm that the measurement node was functioning properly the software implementation tests in Sections 2 to 6 needed to have been successful.

For the calculated values of the different sensors by means of the microcontroller refer to Figures 2934 in the previous experiments. The graphs indicate that the simulated and or actual input values were calculated and compared to the input values.

From results, it is proven that the calculated values reflect that of the input values. This confirms that the software implementation was a success.

### G. Qualification Test 7: Wireless Range

For the wireless communication two XBee series-1 modules were used. One module was used as a wireless transmitter for the measurement node and the other module was used as a wireless receiver for the notification node. The minimum required range for wireless communication was specified as 10m. The XBee modules are specified to achieve 10 to 70m range (depending on line of sight).

A qualification test was run to observe if the minimum range could be achieved.

The results obtained were the maximum line-of-sight range: 20 m, and the maximum non-line-of-sight range (2 double layer brick walls): 13 m.

For the line-of-sight test, the data transmitted started to corrupt at about 20 m from the measurement node. For the non-line-of-sight propagation, the connection was initiated through four layers of brick wall then moved away from the measurement node until the connection was lost at roughly 13 m. The requirement of a minimum 10 m range was accomplished.

### H. Qualification Test 8: Notification Node

The notification node consists of a PIC32MX220F032B microcontroller, buzzer and 16-character LCD. The microcontroller is responsible for receiving sensor data values and displaying said values on an LCD as well as alerting the user with a buzzer when a water quality parameter reaches an unsafe level.

A qualification test was run to observe the correct function of the notification node. This was done by testing the entire system and observing the outputs on the LCD as well as listening for the audible alert when a parameter was at an unsafe level.

The LCD displayed all five water parameters with each respective unit value in sequence with sufficient delay for easy reading. The buzzer successfully activated whenever a parameter transgressed a safety level and the volume was adjustable with the trimmer potentiometer.

The notification node successfully displayed the water parameters on the LCD and activated the buzzer whenever a parameter was at an unsafe level.

SECTION VIII

## CONCLUSION

A sensor node with a temperature, conductivity, pH, ORP and flow sensors was designed and constructed on a Vero-board, which also included the respective signal conditioning circuits. The temperature sensor was completed using a thermistor based design. The conductivity sensor design was based on a two-electrode method. The signal conditioning circuit yielded acceptable results. The conductivity cell/electrodes were however not verified. The pH sensor made use of a glass electrode and yielded acceptable results. The flow sensor design made use of a turbine flow meter and yielded good results.The ORP sensor signal conditioning as a whole was a success and had acceptable accuracy. The ORP electrode itself was not calibrated. A measurement node consisting of a microcontroller was implemented to process the raw sensor data into usable measurement values. The microcontroller then transmitted the measurements wirelessly to the notification node via the wireless XBee modules. A wireless node was implemented using two XBee modules configured for peer-to-peer communication. A notification node consisting of a microcontroller, LCD and buzzer was implemented as a user interface to display the different water quality parameters. The buzzer was used as an audible alert when a specific parameter was at an unsafe level. The accuracies of the different sensors and other findings are as follows. Temperature sensor: 2.5°C. Conductivity sensor: 14.71% (unverified). Flow sensor: 6.28%. pH sensor: ±0.51. ORP sensor: ±24.14 mV (uncalibrated). The raw sensor data was processed successfully. Wireless communication between the measurement and notification nodes with a maximum non-line-of-sight wireless range of 13 m was achieved. The water parameters were displayed clearly on the LCD and audible warnings were heard from the buzzer when parameter is at an unsafe level. Future work could include the design and implementation of a turbidity sensor, as this a also an important quality monitoring parameter. The current design is able to display the parameters in real-time, however a history of the readings is not available, thus data logging of the sensor measurements could also be condsidered.

### Acknowledgment

The authors would also like to thank Council for Scientific and Industrial Research (CSIR), South Africa for some advice during the course of this project.

## Footnotes

This work was supported in part by the National Research Foundation through the Tertiary Education Support Programme, ESKOM, South Africa, under Grant IFR160118156967, the Research Development Programme, University of Pretoria, under Grant AOX220, and the Council for Scientific and Industrial Research, South Africa.

Corresponding author: R. Malekian

## References

No Data Available

## Cited By

No Data Available

None

## Multimedia

No Data Available
This paper appears in:
No Data Available
Issue Date:
No Data Available
On page(s):
No Data Available
ISSN:
None
INSPEC Accession Number:
None
Digital Object Identifier:
None
Date of Current Version:
No Data Available
Date of Original Publication:
No Data Available

Comment Policy