Aquarium water quality TDS sensor

Hello Forum,

please help me, I have problems with the following:
I anstalled a tds sensor to an esp32 board analog pin and see, that the ppm value isn’t correct shown and see that the value of the sensor isn’t 0 if the sensor is not attached to the board. Can anyone help me to fix the issue?

My esp configuration is:

sensor:
  - platform: adc
    pin: GPIO39
    name: "Aquarium tds"
    update_interval: 10s
    unit_of_measurement: "ppm"
    icon: "mdi:water-percent"
    filters:
       - lambda: return ((133.42*x*x*x - 255.86*x*x + 857.39*x)*0.5)*3.3;

Hardware:
Raspberry pi4 - 4 gb
ESP32 Wemos controller
Analog TDS Sensor - Water Conductivity Analog Tds Sensor Module Tester Waterproof Probe Liquid Detection Water Quality Monitoring For Arduino 3.3v - Sensors - AliExpress

Software:

  • Home Assistant OS
  • ESPHome

You need to add temperature compensation.

https://wiki.dfrobot.com/Gravity__Analog_TDS_Sensor___Meter_For_Arduino_SKU__SEN0244#target_3

### TDS 01
# Raw TDS Reading
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 6.144
    name: "TDS 01 Raw"
    ads1115_id: ads1
    id: tds01_raw
    update_interval: 10s
    unit_of_measurement: "v"
    accuracy_decimals: 3
    internal: true

# Temperature Compensated Voltage
  - platform: template
    name: "TDS 01 TCV"
    id: temp01_comp_v
    unit_of_measurement: 'v'
    accuracy_decimals: 3
    lambda: 'return ((id(tds01_raw).state) / (1 + (0.02 * ((id(probe01).state) - 25.0))));'
    update_interval: 10s
    internal: true

# Temperature Compensated TDS
  - platform: template
    name: "55G TDS 01"
    id: tds01_55g
    icon: "hass:water-opacity"
    unit_of_measurement: 'PPM'
    accuracy_decimals: 0    
    lambda: return (133.42*(id(temp01_comp_v).state)*(id(temp01_comp_v).state)*(id(temp01_comp_v).state) - 255.86*(id(temp01_comp_v).state)*(id(temp01_comp_v).state) + 857.39*(id(temp01_comp_v).state))*0.5;

# Temperature In °C
  - platform: dallas
    address: 0x6f01205fd42aa428
    name: "Probe 01"
    id: probe01
    unit_of_measurement: "°C"
    internal: true

# Temperature In °F
  - platform: template
    name: "55G TEMP 01"
    id: temp01_55g
    lambda: |-
      return id(probe01).state * (9.0/5.0) + 32.0;
    unit_of_measurement: "°F"

image

I become an error massage, that I need to configure I2c also.

Sorry, you don’t need to use my fist sensor, just use yours.

I am using a multiplexer because I have 4 TDS sensors.