Hello,
I have a brand new TDS sensor from DFRobot, and I plugged it into my Arduino Mega as follows:
TDS - to GND
TDS + to 3V3
TDS A to A1
The DFRobot board lights up and the probe is attached properly. When I run the following code straight from DFRobot examples, I get a constant reading of 619ppm no matter what (probe in open air, tap water, and salt water).
#include "GravityTDS.h"
#include <EEPROM.h>
#define TdsSensorPin A1
GravityTDS gravityTds;
float temperature = 25,tdsValue = 0;
void setup()
{
Serial.begin(115200);
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(3.3); //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()
{
//temperature = readTemperature(); //add your temperature sensor and read it
gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation
gravityTds.update(); //sample and calculate
tdsValue = gravityTds.getTdsValue(); // then get the value
Serial.print(tdsValue,0);
Serial.println("ppm");
delay(1000);
}
I also ran this code and verified that a simple analog read isn't changing either. When I run this, I get a constant analog read of 489 no matter what.
#define TdsSensorPin A1
void setup() {
Serial.begin(115200);
pinMode(TdsSensorPin, INPUT);
}
void loop() {
int sensorValue = analogRead(TdsSensorPin);
Serial.println(sensorValue);
delay(1000);
}
Does anyone know what the issue might be? I'm tempted to say I received a faulty sensor!