Turn on the Smart Water Board and reads the pH sensor extracting the value from the calibration values and temperature compensation
Required Materials
1 x Waspmote
1 x Battery
1 x Smart Water Sensor Board
1 x pH Sensor
1 x pH Calibration Kit (for those sensors which require calibration)
1 x PT1000 temperature sensor (for temperature compensation)
Notes
- The calibration values selected in the code are an example for a specific sensor, each unit will require its own calibration parameters.
- If the sensor has been kept stored for long it may take longer to reach a steady output.
- In case calibration or temperature compensation are considered unnecessary function pHConversion can be called without them. Take a look at section “API” of the Smart Water Technical Guide for more information.
- This example is valid for Waspmote v12 and Waspmote v15
Code
/* ------ [SW_01] - pH sensor Reading for Smart Water-------- Explanation: Turn on the Smart Water Board and reads the pH sensor extracting the value from the calibration values and temperature compensation Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L. http://www.libelium.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Version: 3.0 Design: David Gascón Implementation: Ahmad Saad*/#include<WaspSensorSW.h>float pHVol;float temp;float pHValue;// Calibration values#definecal_point_101.985#definecal_point_72.070#definecal_point_42.227// Temperature at which calibration was carried out#definecal_temp23.7pHClass pHSensor;pt1000Class temperatureSensor;voidsetup(){USB.ON();USB.println(F("pH example for Smart Water..."));// Store the calibration values pHSensor.setCalibrationPoints(cal_point_10, cal_point_7, cal_point_4, cal_temp); ///////////////////////////////////////////// 1. Turn ON the Smart Water sensor board /////////////////////////////////////////// Water.ON(); }voidloop(){ ///////////////////////////////////////////// 2. read the sensors /////////////////////////////////////////// // Read the ph sensor (voltage value) pHVol =pHSensor.readpH();// Read the temperature sensor temp =temperatureSensor.readTemperature();// Convert the value read with the information obtained in calibration pHValue =pHSensor.pHConversion(pHVol, temp); ///////////////////////////////////////////// 3. Print the output values ///////////////////////////////////////////USB.print(F("pH value: "));USB.print(pHVol);USB.print(F("volts | "));USB.print(F(" Temperature: "));USB.print(temp);USB.print(F("degrees | ")); USB.print(F(" pH Estimated: "));USB.println(pHValue);}