ESPHome water level sensor

:confused: es, i made it as [kimocal] did it, That was the diagram i used, and it says 0.01 then goes to 0.02 on my multi-meter, Not that fine or expensive versionā€¦:confused: Can absolutely be 0.01

Sounds like some folks need to start reading data sheets for their components and theyd save a whole lot of time by not running around guessing or experimenting with what voltages work or dont work with certain componentsā€¦ For most sensors, components, esp boards, etc. There isnt just 1 of them on earth and what worked for someone else doing this project, it DOES NOT mean it will work successfully for everyone.

You can unquestionably follow the advice from online strangers or you can go google your data sheet and know for a fact 100% what is correct or incorrect information and then spend less time on issues, make far fewer mistakes, waste far less money, waste far less time.

I may be mistaken too but, those little green buck converters look like the ones that you need a load on them to be able to set the output. You cant just set the output then hook up a load to it because it will be far less than you set it without a load.

Well made just the same agin now and its working, Must have been a bad INA219, tnx alot all you guys that try helping,

@Fallingaway24 why post like you did? Do you feel better of that or what did you mean was the problem?!
Hope that someone gives you the same answer when you need helpā€¦

Could you please help with wiring?

I have the following
1- 4-20ma water level sensor with 24V input and two wires (+,-),
2- TZT Current To Voltage Module 0 -20mA/4 -20mA to 0- 3.3V/0 -5V/0 -10V Voltage Transmitter Signal Converter Module
3- shelly uni plus also shelly add-on plus
4- Adjustable AC to DC Power Supply 220V to 3V-24V 3A.

but couldnā€™t make it work

In your case you only need

1, 3 (Shelly plus UNI) and 4

Operate Shelly with 24V DC and connect sensor to GND (-) and plus to 24V DC and Output to Pin3 (Analog IN)

Quelle:

Iā€™m planning a project that requires at least 6 water level sensors, 5 water temperature probes and a bunch of digital inputs/outputs (>20)

The Kincony KC868-AIO seems ideal and has 8 4-20mah analog inputs:
https://vi.aliexpress.com/item/1005005381809997.html

Not 100% how to read the datasheets, but suspect this might just be multiplexing signals and still using ESP32 ADC?

Iā€™ve ordered this 8 x 4-20ma ā†’ rs485 sensor, will post with details if I can make it work:
https://vi.aliexpress.com/item/1005005415315374.html

Not so important, because those datasheets are not 100% either. Probably much less than your reading %. :+1:

I only have a single sensor for testing, but I was able to get the Wellpro 8 x 4-20ma to RS485 adapter working with ESPHome

I havenā€™t implemented any filtering as not really necessary for my use-case, but hereā€™s the ESPHome yaml showing the required modbus/RS-485 syntax:

Iā€™m using a Kincony KC868-A6 for esphome (has built-in RS-485), available on aliexpress:

edit: happy to provide more details if this would be useful for anyone.

here is my code for esp 32 and pressure transducer. with a 0-2 meter sensor in a thousand gallon tank 1.2 meters full. using INA-219 for current sensor. 4-20 ma. i calibrated it in a 5 gallon bucket. Increments of 15 gallons.

  - platform: ina219
    i2c_id: bus_a
    address: 0x40
    shunt_resistance: 0.1 ohm
    current:
      name: "Tank Level"
      id: tank_level
      accuracy_decimals: 1
      filters:
      - multiply: 1000 #convert from Amps to mA
      - offset: -4.205 #-4 to get to zero 4-20ma this is sensor on dry land zero reading
      - lambda: return (x/0.196) * 24.99; #one inch of water is 24.99 gal .196ma = one inch in tank i got this by putting a few diff height of water  and doing math for tank size head pressure is head pressure area has no effect###
      - offset: -200.0 #useable gallons if for pump run dry safety####
      
      unit_of_measurement: "Gallons"
    power:
      name: "INA219 Power"
    bus_voltage:
      name: "INA219 Bus Voltage"
      accuracy_decimals: 4
    shunt_voltage:
      name: "INA219 Shunt Voltage"
    max_voltage: 16.0V
    max_current: 400ma
    update_interval: 5s
  - platform: wifi_signal
    name: "Tank WiFi Signal Sensor"
    update_interval: 30s
    id: tankwifi

I have a 0.5-4.5V pressure transducer for use up to 5PSI. My 1000L water tank has about 1650mm height my code is below. I had to make a small compensation for temperature of 4mV per 1C. My equation/lambda function is probably a bit basic but seems to work well enough for now, will keep making tweaks if required. Accurate to about 30L (0.3)% so far. Thanks to everyone for their contributions!


#Voltage from ADS1115 connected to water tank sensor 
  - platform: ads1115
    multiplexer: 'A0_GND'
    gain: 4.096
    name: "Rain Water Tank Sensor Voltage"
    id: tank_sensor_volts
    unit_of_measurement: "V"
    accuracy_decimals: 4
    update_interval: 3s
    filters:
      - multiply: 1.694
     #resistor divider value
      - median:
          window_size: 21
          send_every: 20
          send_first_at: 1            

  - platform: dht
    pin: GPIO4
    model: AM2302
    update_interval: 10s 
    humidity:
      name: "Humidity"
      id: dht_humidity
      accuracy_decimals: 1
      filters:
        - filter_out: NaN
        - sliding_window_moving_average: 
            window_size: 15
            send_every: 6
            send_first_at: 1              
    temperature: 
      name: "Temperature"
      id: dht_temperature
      accuracy_decimals: 1
      filters:
        - filter_out: NaN
        - sliding_window_moving_average: 
            window_size: 15
            send_every: 6
            send_first_at: 1    

#compensation for temperature 4mV per 1C (25C*0.004=0.1)
  - platform: template
    name: "Tank Volts Compensated"
    id: tank_v_comp
    accuracy_decimals: 4
    unit_of_measurement: "V"
    lambda: return id(tank_sensor_volts).state - 0.1 + id(dht_temperature).state * 0.004;

#0% & 100% voltage values taken at 25C 
  - platform: copy
    source_id: tank_v_comp
    name: "Tank % full"
    id: tank_level
    unit_of_measurement: "%"
    accuracy_decimals: 0
    filters:
    - calibrate_linear:
        - 0.5321 -> 0.0
        - 2.0981 -> 100
    - lambda: |-
          if (x >= 100) return 100.0;
          else if (x <= 0.0) return 0.0;
          else return x;

  - platform: copy
    source_id: tank_level
    name: "Tank Litres Remaining"
    id: tank_volume
    unit_of_measurement: "L"
    accuracy_decimals: 0
    filters:
      - lambda: return (x * 10);

Hi Shayne, any chance of seeing your hardware list please? I have a 720l tank on my boat, with limited access to it and this solution is the only one I can use really.

Cheers

Chris

Sure,
Pressure transducer costs vary quite a lot. I canā€™t testify to the reliability of this unit as iā€™ve only had it for a relatively short time, not exactly mission critical.

DHT22 (AM2302) for the temp measurement (remotely mounted)
4.7nf ads input bypass capacitor
1.7 factor resistor divider (I cant remember the values sorry) for the adc input
ESP32 dev kit C (i need more i/o than the esp8266 varieties have)
Cat 5e cabling
Ip rated enclosure + glands
12V/5V buck converter for esp (12V off grid system)
1/8npt tap (should add a1/8npt ball valve for servicing)
Dupont connectors (need to solder)
Small terminal block
Push type din terminals

Iā€™ll probably make a small PCB to tidy thing up in future now that the prototyping is done.

You could use high value resistors, cycle the ADS for better efficiency depending on the frequency you want sensor updates.

Hope this helps.

1 Like

Thanks Shayne, appreciate it