mlauhalu/esphome-phsensor

tds meter?

Closed this issue · 4 comments

hi, not a bug, but do you think you solution would work with a tds meter as well?

i just bought parts for the PH sensor and looking forward to tinkering :)

there are these tds probes incl daughter board and I would if I could replicate the whole system just with a different probe?

cheers

Hi,

I don't know if you could solve it or not, but I created the pH sensor with TDS and temp sensor. For temp sensor you can use the dallas DS18B20, it is needed because the TDS has different values on different temperatures. The TDS sensor's signal wire should go to the A0 as well. It needs 3.3V and a ground. The dallas temp sensor can be go to any free GPIO, I used the D5 on my wemos, it needs 3.3V also and a ground. I used WAGOs for the easy connection.
Anyway I added a webserver as well to the code so I can reach and check the logs easily.

Here is the code:

esphome:
  name: hydroponic
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: YOUR_SSID
  password: YOUR_PASSWORD

  # Enable fallback hotspot (captive portal) in case wifi connection fails

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

# Example configuration entry
web_server:
  port: 80

ota:

  # Temp sensor

dallas:
  - pin: D5

# PH & Temp Sensor
sensor:
  # https://esphome.io/components/sensor/adc.html
  - platform: adc
    pin: A0
    id: ph
    name: "pH Sensor"
    update_interval: 1s
    unit_of_measurement: pH
    # https://esphome.io/components/sensor/index.html#sensor-filters
    filters:
      - median:
          window_size: 7
          send_every: 4
          send_first_at: 3
      # Measured voltage -> Actual pH (buffer solution)
      - calibrate_linear:
          - 0.59 -> 7.0
          - 0.71 -> 4.0
  - platform: adc
    pin: A0
    name: "TDS 01 Raw"
    id: tds01_raw
    update_interval: 10s
    unit_of_measurement: "v"
    accuracy_decimals: 3
    internal: true
    filters:
      - multiply: 3.3

# Temperature In °C

  - platform: dallas
    address: 0x623ce10457495f28
    name: "Temp Sensor"
    id: temp
    accuracy_decimals: 1
    unit_of_measurement: "°C"

    
# 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(temp).state) - 25.0))));'
    update_interval: 10s
    internal: true

# Temperature Compensated TDS
  - platform: template
    name: "TDS Sensor"
    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;



# Individual sensors



# Display
i2c:
  sda: D2
  scl: D1
  scan: true
  
display:
  - platform: lcd_pcf8574
    dimensions: 16x2
    address: 0x27
    lambda: |-
      it.printf(0, 0, "PH");
      it.printf(6, 0, "Temp");
      it.printf(12, 0, "TDS");
      it.printf(0, 1, "%.2f", id(ph).state);
      it.printf(6, 1, "%.1f", id(temp).state);
      it.printf(12, 1,"%.0f", id(tds01_55g).state);

IMG_9725

I hope it helps!

Hi, thanks for the response. I havent made progress on the tds meter because im still stuck on PH.

but its very good to see the line:

# Measured voltage -> Actual pH (buffer solution)
      - calibrate_linear:
          - 0.59 -> 7.0
          - 0.71 -> 4.0

Because I was pulling my hair out about the fact that higher voltage means lower PH. All other tutorials showed a positive correlation between input voltage and PH.
Ill give it another shot trying to calibrate my PH sensor, so I can go about and make the TDS meter.

You can see how to calibrate your pH sensor here:

#2

Sorry for not responding to the initial question.

Thanks @Tamas92 for sharing your example. It should provide enough information so I can close this issue.