ESPHome water level sensor

Thanks once again for your invaluable input!

All devices are sharing a common ground - thanks for this (as per the pic below).

Would you mind sharing your template so that I can try your height of water method (we also use meters here :slight_smile: )?

When I measure the voltage on the signal wire (going to the sensor) on A0 on the ADS1115, there seems to be some fluctuation and I suspect that this could be causing my ups and downs.

I have ordered a DC - DC converter which I should get tomorrow, Iā€™d like to make sure that the input voltage is as stable as possible to rule this out.

All cabling to the sensor is CAT6 bare copper so quality is good.

This project is making more grey by the day :hot_face:

Hello @mrmuttley . I would change your filters around. Do the median first. I notice that you linear calibration is not correct; there should be two numbers in there ā€¦. a voltage corresponding to zero height (empty) and then a voltage corresponding to the full height. I got my tape measure out.

My tank is a horizontal cylinder with a tower; so if your tank is a vertical cylinder it is much easer IIr2 x H. Otherwise my template is below. It is a lambda and I therefore had to learn C++ to write it!

    name: "Water Tank h1"
    id: h1
    internal: true
    lambda: !lambda |-
      const float h3 = id(wtd).state;
      if (h3 < 1.98) {return h3;} else {return 1.98;};
    accuracy_decimals: 4
    update_interval: 10s

  - platform: template
    name: "Water Tank h2"
    id: h2
    internal: true
    lambda: !lambda |-
      const float h4 = id(wtd).state;
      if (h4 < 1.98) {return 0;} else {return (h4-1.98);};
    accuracy_decimals: 4
    update_interval: 10s

  - platform: template
    name: "Water Tank Volume"
    unit_of_measurement: 'Litres'
    icon: 'mdi:water-percent'
    lambda: |-
      const float r = 0.99;
      const float l = 2175;
      return (0.331831*id(h2).state)+(((sqrt((2*r*id(h1).state)-powf(id(h1).state,2))*(id(h1).state-r))+(powf(r,2)*(3.141592653-acos((id(h1).state-r)/r))))*l);
    accuracy_decimals: 0
    update_interval: 10s
1 Like

Thanks once again - ill try this and get back to you

Hey,
I seem to be having some luck - well sortaā€¦
I purchased a new ADS1115 today and hooked it up.

Voltages were averaging around 0.456 with the tank being full and then it dropped down to 0.391 where it stayed for a while and then back up to 0.456 - this is with no water leaving or entering the tank.

This leaves me to believe that thereā€™s something wrong with the pressure sensorā€¦

Iā€™ve ordered a throw in type from DF Robot which should arrive in a day or soā€¦ lets see what happens with the new one.

1 Like

For what it is worth, I have this one.

https://www.aliexpress.com/item/1005002655746818.html?spm=a2g0o.order_list.order_list_main.44.21ef1802kLvI6a

I chosen0-5v and 5m (24v powered). My tank is 3.5m deep so I assumed I would never go above the range of ads1115

Thanks for sharing - seems like Iā€™ve ordered the exact same one :smiley:
Gravity: Industrial Stainless Steel Submersible Pressure Level Sensor(0~5m)

Already purchased a 24V power supply and an additional DC - DC converter for this. Need to get this project done before my wife gets :face_with_symbols_over_mouth: with me

1 Like

Maybe weird question but do you not also measure some air pressure fluctuations with it?? Maybe need to compensate for those too.

@jayjay some of these sensors have a hollow tube up the centre of the wire core which allows the pressure to be equalised inside the sensor. My sensor shows no variation with atmospheric pressure change ā€¦ I read through the specs for @mrmuttley and no mention but I can see in the photo there is a red tube next to the core wire bundle. Fingers crossed.

Hi guys, has anybody have any successful experience with Seeedstudio Water Sensor 10cm? Iā€™ve seen it being mentioned in a thread long time ago, but maybe something has changed (improved)?

As far as I understand, ESPHome still doesnā€™t support it natively. Iā€™m a completely noob in ESP devices, I2S protocol, etc. I have bought this sensor and Seeedstudio ESP32C3 board. There is some exemplary code for Arduino IDE, but I will miss ESPHome benefits.

Is there any way to process raw sensor data (kinda Arduino code) within ESPHome YAML? Maybe use some platform of type ā€˜templateā€™?

Iā€™ve started using a sonic sensor with esphome and getting good results.

Thanks for your postings, I used this whole thread and specifically yours to create my own ā€œdrop inā€ pressure sensor readings for my sump pump/sump pit. I tried the tof10120 sensor to take depth measurements from the lid of the sump pit, but found it inaccurate even with some moving average smoothing. Iā€™ll probably keep the tof sensor there as a backup but I am having really good success with the pressure sensor and the ina219.

FYI for anyone else using the ina219 and if you are wanting to convert your mA readings to inches, I sat by my sump pit and measured the reported mA readings, while comparing to inches of water in the sump pit, and then plugged the mA-to-inch (x,y) values into online calculator for ā€œleast-squares-calculatorā€ and it gave me the equation that I needed to convert my mA to depth that is probably unique to everyones situation. I ended up with x=mA, y=inches and a y=2.5x - 10.26
{% set height = ((states(ā€˜sensor.ina219_currentā€™ )|float * 2.5) - 10.26 ) |round(2) %}
Thanks to all that contributed to this thread!

I realize esphome offers a built in calibrate_linear and calibrate_polynomial built in, but I didnt know what I had on my hands so using an online calculator with my values was helpful to me to see im dealing with linear.

Hi,

I have finally started serious work on water tank device. I have a few questions I am hoping the group can answer/scrutineer before i start soldering.

Background: I am not a hard core tech d00d. I am just wanting to build a device monitor my house water tanks (40,000l in-ground concrete)

  1. replace a manual valve with an electronic one
  2. tell the level of water
  3. monitor the water flow.

The microprocessor iā€™m using in a Sparkfun ESP32Thing. I noted that the hookup guide says: ā€œPins 34, 35, 36, 37, 38 and 39 cannot be configured as outputs, but they can be used as either digital inputs, analog inputs, or for other unique purposes. Also note that they do not have internal pull-up or pull-down resistors, like the other I/O pins.ā€

I have seen posts where others have experienced ā€˜noiseā€™ coming from the pressure sensors so I thought avoiding pins without pulldown resistors was sensible?

Iā€™ve also read some posts where people suggest using a common ground (ground wire). I havenā€™t got this in my design for the relay or current converter cards.

I am opting for a 12V supply with a boost and buck converter to meet my power needs.

Any comments welcome.

Will the tank have a pump or is it elevated?
I would look at pressure sensor first and then see what voltage that needs. If you read up their some links

I already have the tanks installed, weā€™re on a rural property. 2 x 40,000l concrete in-ground tanks. primary and secondary, approximately 4m deep. They have mains power and independent pressure regulated pumps. The pumps are not directly part of the system/problem. The pressure sensor is the same as others here have used, a TL231 itā€™s 24v. It seems that 24V is required for that degree of pressure.

I am simply wanting to be able to cut the tanks over when the primary is getting low, also monitor use.

Do you really need the flow sensor when change in volume over time will give you the same data?

totally. water is a precious resource here. $30 for another data source, iā€™m in.

@ashscott agreeā€¦ that is what I am doing ā€¦but if you can put a sensor in why not

@xarmoda same as me. The TL231 i think is similar to mine; i went for 5m depth and 0-5v. I used ADS1115 ADC to monitor voltage (and you can add additional pressure sensors to same unit). However, I did care about my automated pump; i want to monitor when it is ā€œonā€ and pumping and used a Shelly EM to monitor current draw and also to control a contactor which could turn it off. What I didnā€™t want to happen, is a leak in the pipe network that would lead to the tank being drained. A bit of automation writing still needed. This is a safeguard and safes that precious resource

Another consideration is the life of the motors; if there is a slight leak in the system the pressure sensor in the pump will be going on and off constantly. So an expansion vessel (to give the motor some breathing room) and being able to monitor the pressure in the pipes was required.

yes, totallyā€¦ i am installing some shellys as well when my electrician has some free time. Itā€™s an easy job, but where I live anything installed on mains must be done by a licensed electrician.

Same here in UK. My electrician and I worked like a glove. He kept me safe and I taught him about being a geek