Hi, i bought a water quality probe : Analog TDS Sensor Water Conductivity Sensor Tester Liquid Detection ,Arduino BSG | eBay
The manufacturer says it needs no calibration but the readouts are incorrect.
I tried some code for the DFRobot probe (which looks exactly the same) and readings are still off though they do go up and down in response to alkali/acid.
Has anyone got one of these working correctly ?
No worries, was a temperature-compensation issue, all good now.
// #include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 12 // Digitalpin where Temp sensor is connected
#define TdsSensorPin A0 // Where Analog pin of TDS sensor is connected to arduino
OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;
DallasTemperature sensors(&oneWire);
float tdsValue = 0;
float ecValue = 0;
void setup()
{
Serial.begin(115200);
sensors.begin();
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
}
void loop()
{
sensors.requestTemperatures();
gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation
gravityTds.update(); //calculation done here from gravity library
tdsValue = gravityTds.getTdsValue(); // then get the TDS value
ecValue = (tdsValue * 2)/1000.0;
Serial.print("TDS value is:");
Serial.print(tdsValue,0);
Serial.println("ppm");
Serial.print("EC value is:");
Serial.println(ecValue);
Serial.print("Temperature is: ");
Serial.println(sensors.getTempCByIndex(0));
delay(1500);
}