Water quality probe (TDS, pH, turbidity, DO, EC)

The analog water-quality probes and their signal boards: TDS, pH, turbidity, dissolved oxygen or conductivity as a voltage, by model.

A probe in the water on a lead, and a board with three pins that turns what the probe sees into a voltage. One part, five probes, chosen with model. Aliases: TDS meter, pH sensor, PH-4502C, turbidity sensor, dissolved oxygen sensor, EC sensor, conductivity meter, DFRobot Gravity SEN0244, SEN0189, SEN0237, DFR0300, Keyestudio TDS.

Pins

Pin What it does
GND Ground. The Gravity boards' -, the PH-4502C's G.
VCC Supply. The Gravity boards' +, the PH-4502C's V+.
OUT The analog output. The Gravity boards' A, the PH-4502C's Po.

The PH-4502C's header also has To (a temperature output) and Do (a comparator output set by a trimmer). They are not modeled, so the part leaves them off. The TDS, DO and EC boards run on 3.3 to 5 V (here from 3.0 V). The pH and turbidity boards are 5 V boards and stop below 4.5 V.

Properties

model picks the probe:

Model The real board Slider
TDS (SEN0244) DFRobot Gravity Analog TDS Sensor (Keyestudio's TDS board is the same circuit) 0 to 1000 ppm
pH (PH-4502C) The blue PH-4502C board with an E201 glass electrode pH 0 to 14
turbidity (SEN0189) DFRobot Gravity Analog Turbidity Sensor, its switch on A 0 to 3000 NTU
dissolved oxygen (SEN0237) DFRobot Gravity Analog Dissolved Oxygen Sensor, a galvanic probe 0 to 20 mg/L
EC (DFR0300) DFRobot Gravity Analog EC Sensor V2, K = 1 0 to 20 mS/cm

temperature is the water's temperature, 0 to 40 C, 25 by default. It is used exactly as each maker's own code compensates for it (see below).

Drag the slider to change the water. Its label and range follow the model.

What the model gets right

Each output is the maker's own published formula, the one their sample code turns the voltage into the quantity with, run backwards. A sketch that uses that formula reads back the slider's value, to one converter step.

TDS. DFRobot's code: EC = 133.42 V³ - 255.86 V² + 857.39 V (µS/cm), compensated EC25 = EC / (1 + 0.02 (T - 25)), and TDS = EC25 / 2 ppm. 300 ppm reads 0.81 V, 1000 ppm 2.16 V; the board tops out at 2.3 V. The slider is the 25 C figure, the one DFRobot's GravityTDS library reports.

pH. The PH-4502C has no maker's datasheet. Its electrode gives the Nernst slope, 59.16 mV a pH at 25 C, and the board amplifies it; the slope every tutorial uses is 0.18 V a pH (a gain of about 3), with the offset trimmer set so pH 7 reads 2.5 V: pH = 7 + (2.5 - V) / 0.18. Acid reads higher: pH 4 is 3.04 V, pH 10 is 1.96 V. The slope follows the absolute temperature, as the Nernst equation says: at 0 C it is 8% smaller.

Turbidity. DFRobot's chart of voltage against turbidity, at 5 V, is the curve NTU = -1120.4 V² + 5742.3 V - 4352.9: 4.2 V in clear water, 3.9 V at 1000 NTU, 2.63 V at 3000. Murkier reads lower. The wiki says clear water reads 4.1 V give or take 0.3 V from 10 to 50 C, so temperature does nothing to this model.

Dissolved oxygen. DFRobot's single-point calibration: the voltage is in proportion to the oxygen, and saturated water (8.25 mg/L at 25 C) reads the calibration voltage, 1600 mV in their sample, which moves 35 mV a degree: DO = mV x saturation(T) / (1600 + 35 (T - 25)), with the saturation table from their code. 8 mg/L at 25 C is 1.55 V. The board's output stops at 3.0 V, which is 15.5 mg/L at 25 C.

EC. The board's gain is documented: 820 ohms of feedback and about 200 mV of excitation, so DFRobot_EC reads EC = mV / 820 / 200 x 1000 mS/cm (K = 1, before calibration), compensated by 1 + 0.0185 (T - 25). That is 164 mV per mS/cm: the 1413 µS/cm buffer reads 232 mV and the 12.88 mS/cm buffer 2.11 V.

Not ratiometric. These boards put out their own voltage whatever the supply, so a sketch that reads the converter against a 4.8 V USB supply but assumes 5 V reads a little high.

What it does not model

Calibration. Every real probe is a little different, which is why each maker has a calibration procedure. The model is the maker's typical curve: an ideal probe that has just been calibrated. Calibration drift and electrode aging (the pH and EC electrodes, the DO probe's membrane and filling solution, which DFRobot says to change every month or few) are not modeled.

The PH-4502C's trimmers. Here the offset is always exactly 2.5 V at pH 7 and the slope exactly 0.18 V a pH at 25 C. The To and Do pins, and the turbidity board's digital mode and its threshold, are not modeled either.

Response time. The output follows the slider at once. A real DO probe takes up to 90 seconds to reach 98% (DFRobot's figure), the turbidity board up to half a second.

The TDS and EC boards' AC excitation. The real boards drive the probe with an alternating signal, so the electrodes do not polarize, and smooth the result to a DC output. Only that DC output is modeled, along with no polarization at high conductivity, no noise, and none of the probes' stated accuracy (TDS ±10% of full scale, EC ±5%).

Common mistakes

Using a probe without calibrating it. On the bench, the sample sketches' default numbers can be well off; in the simulator they are exact, which is the difference between the two.

Forgetting temperature compensation. Water conducts about 2% more per degree, so a TDS or EC sketch that assumes 25 C reads warm water high. Set temperature and watch the reading move.

Running the pH or turbidity board on 3.3 V. Both are 5 V boards, and below 4.5 V the model leaves OUT floating.

Reading the pH board's Do pin. That is a threshold output, not the pH. Po is the pH.

See it in action

Aquarium water monitor reads all five probes on one Uno and prints ppm, pH, NTU, mg/L and mS/cm. Open it at /templates.