Grove-TDS-Sensor

hello,

i am using this sensor with my raspberry pi; https://wiki.seeedstudio.com/Grove-TDS-Sensor/ connected via a https://www.seeedstudio.com/Grove-Base-Hat-for-Raspberry-Pi.html

i am using this code:

import math
import sys
import time
from grove.adc import ADC
 
class GroveTDS:
 
    def __init__(self, channel):
        self.channel = channel
        self.adc = ADC()
 
    @property
    def TDS(self):
        value = self.adc.read(self.channel)
        if value != 0:
            voltage = value*5/1024.0
            tdsValue = (133.42/voltage*voltage*voltage-255.86*voltage*voltage+857.39*voltage)*0.5
            return tdsValue
        else:
            return 0
 
Grove = GroveTDS
 
def main():
    if len(sys.argv) < 2:
        print('Usage: {} adc_channel'.format(sys.argv[0]))
        sys.exit(1)
 
    sensor = GroveTDS(int(sys.argv[1]))
    print('Detecting TDS...')
 
    while True:
        print('TDS Value: {0}'.format(sensor.TDS))
        time.sleep(1)
 
if __name__ == '__main__':
    main()

when i put both sensors in liquid The TDS meter says it is 198ppm and the grove tds meter measures 314 ppm.

when i put both sensors in osmosis water (0ppm) the TDS meter says its 0ppm and the grove tds says its 7ppm.

what went wrong?

Hi @ttt
There are some limits to the grove TDS sensor.

  • The Waterproof TDS probe cannot be used in water above 70°C.
  • The sensor cannot be used to measure flowing water.
  • The sensor cannot be used to measure water with high pollution concentration.
  • The Grove sensor itself is not waterproof.
    What kind of TDS meter were you used? It is normal if the value of ppm is not too different.

Hi @jiachenglu,
thanks for your reply but that doesn’t answer my question.

I am using a calibrated TDS pen. The ppm of the liquid is 200 ppm. The tds pen measures 198 ppm, the grove sensor 314ppm.

tdsValue = (133.42/voltage*voltage*voltage-255.86*voltage*voltage+857.39*voltage)*0.5

If you google on this formula everyone (vendors) is using it but no one explains it. Can someone explain the static values? What does they mean?

There is no temperature correction and no calibration in this code. Without this the sensor/hardware is useless?

I have the same issue. Looking for the meaning of this formula. It is very difficult to do any sort of calibration without understanding what this formula means.

Hi @salty99
There is a wiki to calculate the TDS for a particular liquid.
Hi @ttt
The code was wrong, “133.42/voltagevoltagevoltage” should change to “133.42voltagevoltage*voltage”.

@salty99 yea, it is quite a bit lacking in the documentation. they produce a lot of hardware but it seems that they don’t test the code very well. I.e. the PH meter has no temperature compensation either.

a few weeks ago i found this site:

read that, then look at this code from them:

if you open this file: i can use only 2 links in a post :expressionless: so see the link in the next post

you see a function: void GravityTDS::ecCalibration(byte mode)
this code explains how to calibrate and use that value in the function: void GravityTDS::update()

still no explanation about the static values but its seems that my ppm with temperature compensation is a lot closer to my ppm Pen.

just reply if you have any questions, maybe i can help

You’re replying too quickly. Please wait 18 seconds before trying again. :expressionless:

wait wait… here it is: