INTRODUCTION
Water is the single most important element for our health and environment.
What can we do to preserve it? Monitoring its quality is a good start. Be it in a swimming pool, an agricultural crop, a municipal water facility or a remote well in Africa, preserving clean water can help both reduce unnecessary waste and benefit our health.
THE CHALLENGE
Water quality measurement can be expensive and time-consuming. This is because its parameters are not only physical, but also chemical and biological, requiring some of them to be sampled and analyzed at laboratories.
Even though there are more than 30 parameters in water, our challenge was to develop an online monitoring system under these premises:
-
Simple: Can be build by a non-technical user
-
Stable: Can be left unattended and charge itself through solar energy
-
Low-cost (under $200 USD): We integrate commercial hardware and software tools to measure a basic set of parameters that, analyzed in context, can give a sense of the water quality, namely: pH, ORP (Oxidation-Reduction Potential) and Temperature.
You could easily be able to extend this project to measure other parameters like Conductivity or Dissolved Oxygen, just purchase the respective probes and connect them to the analog inputs of the Seeeduino Board.
After completing this project, you should have all of your variables in a nice-looking dashboard like this, an even be able to create your own triggers to receive an SMS or Email when a variable is outside a threshold.
SETUP YOUR UBIDOTS ACCOUNT
First of all, we'll use the Ubidots service to store and analyze the sensor data, so let's start by creating a Ubidots account here.
Log in to your account, create a datasource called "Pool Monitor" and add 4 new variables called "Temperature", "Battery", "PH" and "ORP":
Please take note that each variable has an ID. We'll need these ID's later for our device code.
Also, you'll need to create a token under "My profile" tab. A token is like a password for your device to authenticate to the Ubidots API and send data to it. Take note of this value as we'll also need it the device code.
WIRING
Lots of cables here so it's important to pay close attention to the connections!
Make sure that the Adafruit Fona module has an antenna, otherwise the code might return communication errors. You should also check that each pH/ORP Adapter has the switch in the right position; they should be set to pH and ORP respectively.
After wiring things up, put all of the elements in a Tight Box as organized as possible. This is how our unit looked like (not too messy I hope!):
CODING
Because our project involves different types of peripherals, we will test each one separately. If you want to get the complete code, you can find it at the end of this section.
Reading temperature data
We used the DS18B20 sensor because of its simplicity. The following code will read the temperature from Pin #2 and display it in the serial monitor. You'll need include the following libraries before using it:
Reading pH/ORP raw data
Before sensing pH or ORP data, it is a good idea to test your Phidgets with the following Arduino code. It basically reads the analog inputs and displays them in the serial monitor. Usually, a formula is required to convert these readings into a meaningful pH/ORP value, but we'll do these calculations later using Ubidots' math engine.
Reading the battery level
This test code will read the voltage of the battery, which will help you get familiar with its charge and discharge curves of the solar circuit.
Final code
This code integrates the sensor readings and the FONA functions to send data to Ubidots:
pH/ORP CALIBRATION
To get the right measurements of pH, it is necessary to user a "buffer solution". This is a liquid with known pH values that serve as reference.
We can approximate the pH measurements to a linear curve, so we'll record the sensor readings for a pH of 4 and a pH of 7, at 25°C.
Let's build our linear equation in the form "y = mx + b", where:
m = (y2-y1) / (x2-x1)
and
b = (y1) - m*(x1)
where y1 and y2 are pH 4 and pH 7, while x1 and x2 are the raw analog sensor values obtained in the buffer solution for pH 4 and pH 7 respectively.
In our case, the analog value associated with pH 4 was "595", and "744" for pH 7. The conversion factor is calculated then:
m = ((7-4)/(744 - 595)) = 0.020134;
Finally, we compute the constant value "b" to get the final equation:
b = 4 - 0.020134*595
The final equation:
pH (calibrated) = 0.02013(RawPHvalue) - 7.9798
As for the ORP calibration, the manufacturer already provides a formula in their website:
ORP (calibrated) = (2.5 - (RawORPvalue/200))/1.37
A cool thing about Ubidots is that you don't have to code these formulas in your device; you can do it in the cloud. Just create a "derived variable" inside the data source and enter the respective math expression:
SOLAR CHARGING CONSIDERATIONS
This system attempts to be as autonomous as possible.
Since sending values through GPRS is the main source of consumption, we'll only send data every 10 minutes and turn off the FONA after this is done. This will give the battery enough time to charge through solar energy and make sure it doesn't discharge during the nights.
To determine how long could the FONA operate at night, we charged a full battery, disconnected the solar charger, and fired as many values as possible to Ubidots. We were able to send 1378 values which means that, at a 10-minute separation, the device could send data for 230 hours, or 9.5 days! That's enough time to charge the battery.
Another test was to see the how much does the battery take to charge at full sun light. We observed that the charge increased 12 units in 20 minutes, in a scale between 530 and 650 (values obtained from the analog conversion). Therefore, it requires 200 minutes, or 3 hours and 15 minutes, to charge at 100% through the solar panel.
By sending data every 10 minutes, we can be sure we're giving it enough time to charge, even in winter time!
With these considerations, we established 10 minutes period, although it should be able to support a shorter update period.
CONCLUSIONS
This project allows you to setup an autonomous water monitoring system to use in pools or other settings were the water quality is important. After this data is in Ubidots, you can create text message or Email alerts, or even activate a remote actuator like a opening a valve or a turning on a water pump.
Comments