Professional Documents
Culture Documents
Within this manual, you will acquire knowledge on employing a TDS Sensor ESP8266 NodeMCU board.
The TDS meter gauges the aggregate of dissolved solids, such as salts, minerals, and metals, within a
solution. This metric serves as a means to assess water quality and facilitate comparisons between
water obtained from various origins. A primary application of the TDS meter is the monitoring of
aquarium water quality.
We will utilize the TDS meter from key studio and provide a straightforward illustration demonstrating
how to measure TDS in parts per million (ppm) using the Arduino IDE.
While this serves as a valuable gauge for monitoring water quality, it’s crucial to note that it doesn’t
assess contaminants in the water. Therefore, relying solely on this indicator is insufficient to determine
the suitability of water for consumption.
TDS meters find utility in various applications such as monitoring water quality in pools, aquariums, fish
tanks, hydroponic systems, water purifiers, and more.
In this tutorial, we will employ the keystudio TDS meter, which includes an interface module and an
electrode probe (as depicted in the image above).
For additional details about the TDS meter, we recommend consulting the official documentation.
TDS Probe:
Number of Needles: 2
Total Length: 60cm
Color: White
Waterproof Probe
As mentioned earlier, the sensor generates an analog signal that can be translated into TDS in parts per
million (ppm). We are utilizing the code outlined in the sensor documentation with certain adjustments.
For enhanced precision, it is advisable to calibrate your sensor against a solution with a known TDS
value. Nevertheless, calibration may not be necessary if your focus is on a qualitative assessment of TDS
rather than specific values.
int analogBuffer[SCOUNT]; // store the analog value in the array, read from ADC
int analogBufferTemp[SCOUNT];
int analogBufferIndex = 0;
int copyIndex = 0;
float averageVoltage = 0;
float tdsValue = 0;
float temperature = 23; // current temperature for compensation
void setup(){
Serial.begin(115200);
pinMode(TdsSensorPin,INPUT);
}
void loop(){
static unsigned long analogSampleTimepoint = millis();
if(millis()-analogSampleTimepoint > 40U){ //every 40 milliseconds,read the analog value from the ADC
analogSampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(TdsSensorPin); //read the analog value and store into the
buffer
analogBufferIndex++;
if(analogBufferIndex == SCOUNT){
analogBufferIndex = 0;
}
}
// read the analog value more stable by the median filtering algorithm, and convert to voltage value
averageVoltage = getMedianNum(analogBufferTemp,SCOUNT) * (float)VREF / 1024.0;
//Serial.print("voltage:");
//Serial.print(averageVoltage,2);
//Serial.print("V ");
Serial.print("TDS Value:");
Serial.print(tdsValue,0);
Serial.println("ppm");
}
}
}
Supplies
*Raspberry pi 4B
*1 X breadbord
*2 X waterflow sensor
*1 X orp sensor
*1 X pH sensor
* 1 X LCD 16x2
*1 X MCP3008
* 1 X potentiometer 10KΩ
Step 1: Building the Circuit
I use four because my project has water near it and it’s safer.
Step : Code
For our project we will use python. On our webserver we will show the orp, pH and the temperature
values. And we will also show graphs of the values in the last 10 minutes.
In our code we will also send my values to a MariaDB server hosted on the raspberry pi. We will use
threading to separate these tasks.
We will create two boxes 1 with all the sensors and electronics and one with the Ph and chloride tanks.
It’s important that the tanks are perfectly sealed because of the toxic gasses of the liquids.
In the second box is a small box with the 4 relays too control the pumps.