ESPHome water level sensor

The tank volume is not the issue, it’s the depth. ie: a tank that is only 100mm in diameter but 10m tall will create 10x more pressure on the sensor (or at the bottom) than a 100m diameter tank that is only 1m tall despite having a fraction of the volume.

Thanks guys, i’ve ordered a 4-20ma 3m sensor (w/5m cable). Should fit the bill.

Will create the esphome entity while I wait for sensor to arrive!

This version comes with the current to voltage converter. Used it in my setup and it’s been working great for almost 2 years. Easy to read voltage from an ESP. I posted about it higher up in this thread here

1 Like

Rusty,
Looking at your diagram you show the positive from dc converter going to gnd on the esp? Is that correct?
Patraff

Hi rusty_away,

3 beginner’s questions to your diagram:
(1) after adding the ADS1115 and following your description, the Gravity/A to NodeMCU/A0 connection should no longer be there, right? If correct, is this the only connection that needs to be removed?
(2) do I see this right that GND and ADDR of the ADS1115 go both to Vout- of the LM2596?
(3) why is Gravity/+ connected to LM2596/Vout- and Gravity/- to LM2596/Vout+?

Thanks!!!

Andreas

Is it possible that in the picture in and out of the DC-DC converter are swapped?

No it looks correct to me.
The ESP32 gets 5V from a USB Adapter.
I then take that 5V to the IN of the DC-DC Boost converter to boost it to 24V. Then the 24V is fed into the pressure sensor.

Hello @rusty_away thanks a lot for this diagram. I think this is the easiest method, at least for beginners like me. I replicated your setup exactly, using the Gravity sensor + Current to Voltage converter kit, the LM2596 and the NodeMCU. I used a MeanWell 230V to 24V adapter to get to 24V.

However, I am having trouble with something as simple as getting the NodeMCU to read the i2c, so I must have done something obvious wrong. Would you be willing to help?

I wired it up exactly as shown in your diagram. I adopted the NodeMCU using ESPhome and gave it your config with a customized name. However, once powered on and logging to Home Assistant, I keep getting the following:

snipped
15:52:57][C][logger:233]: Logger:
[15:52:57][C][logger:234]:   Level: DEBUG
[15:52:57][C][logger:235]:   Log Baud Rate: 115200
[15:52:57][C][logger:236]:   Hardware UART: UART0
[15:52:57][C][i2c.arduino:038]: I2C Bus:
[15:52:57][C][i2c.arduino:039]:   SDA Pin: GPIO4
[15:52:57][C][i2c.arduino:040]:   SCL Pin: GPIO5
[15:52:57][C][i2c.arduino:041]:   Frequency: 50000 Hz
[15:52:57][C][i2c.arduino:044]:   Recovery: bus successfully recovered
[15:52:57][I][i2c.arduino:054]: Results from i2c bus scan:
[15:52:57][I][i2c.arduino:056]: Found no i2c devices!
[15:52:57][C][ads1115:070]: Setting up ADS1115...
[15:52:57][C][ads1115:071]:   Address: 0x48
[15:52:57][E][ads1115:073]: Communication with ADS1115 failed!
[15:52:57][C][ads1115:077]:   Sensor 'AH vijver niveau'
[15:52:57][C][ads1115:077]:     Device Class: 'voltage'
snipped

I have tried powering the sensor and current to voltage converter seperate from the NodeMCU and checked the voltages. On the sensor side, voltages are around 24V as expected. On the NodeMCU side, voltages are around 5.2V as expected.

Surely I have overlooked or missed something simple, but I cannot figure it out. Would you be willing to help me get it working?

iFloris,
As I understand it If you are only using the gravity current to voltage converter then you don’t need 12c. I have a similar setup with only the gravity one and I read my values on one of the ADC pins on my esp32 code for sensor is

sensor:
  - platform: adc
    pin: 35
    update_interval: 2s
    id: "waterTankSensorVoltagev2"
    name: "Water Tank Sensor Voltage v2"
    icon: "mdi:water-percent"
    filters:
    - multiply: 3.3
    - median:
        window_size: 15
        send_every: 15
        send_first_at: 15

I deleted the reference to i2c as i wasn’t using it.

Pat

1 Like

Hello @Patraff thank you, I will try that!

I think I’ve linked this video before in this thread (or a similar one).

It shows that the ESP32 has a particularly poor built-in ADC.
That’s why an external one like the ADS1115 is recommended.
Using the ADS1115 and a well suited pressure sensor (in my case one with a range from 0 - 2 meters for a pool that fills up to about 1.35m) I get a precision of about 1-2 millimeters!

Quizzical
Yeah the guy with the swiss accent is on my subscribe list. He also convinced me to purchase the ads1115. I am measuring a 22000 litre water tank - depth about 2.4. I should have it all in a box soon.
Pat

Hi liflitz

  1. The ADS1115 uses an I2C interface to send data to the NodeMCU, therefore the A0 connection is not required at all.
  2. The ADS1115 uses the connection between the ADDR and other pins to set its address so, yes, that connection is correct for the address “0x48”. Other connections and addresses below:
    ADDR → VDD “0x49”
    ADDR → SDA “0x4a”
    ADDR → SCL “0x4b”

This is a very handy feature which allows connection of multiple ADS1115 modules to a single NodeMCU if required. I have 3 water tanks in my RV that each have four outputs “1/4”, “1/2”, “3/4” and “Full”. This is a total of 12 possible water levels. Using 3 x ADS1115 I can configure my tanks to display individually in HA, using one NodeMCU.

  1. The gravity sensor uses current in the range of 4mA - 20mA as its output. This means that the circuit current must flow through the device for it to work. The accompanying module converts the current to a voltage for the ADS1115.

Cheers

1 Like

Hello @iFloris

Can you post your ESPHome config (in its entirety) so that I can have a look at it?

Also, double-check that you are definitely using the correct pins for the SDA and SCL connections on the NodeMCU.

Cheers

Hi Liflitz

No, the picture is correct. The throw-in sensor uses the 24V directly and the 5.2V output of the regulator is used only for powering the NodeMCU and the current to voltage converter.

Cheers

@rusty_away, can you share your config and more detail about the wire; I’m looking for a solution to measure 2 tanks (one next to the other) and your description rang me the bell that I can use a single NodeMCU for that

Hi @bremby

First you have to set up the pins on the NodeMCU that the I2C interface will use:

i2c:
  sda: GPIO4
  scl: GPIO5
  scan: true
  id: bus_a

Then you declare the address the ADS1115 will be using (for example “0x48”) In this case the address is set on the ADS1115 itself by connecting “ADDR” to “GND” of the same module.

ads1115:
  #  continuous_mode : on
 - address: 0x48
   id: ads1115_48
   i2c_id: bus_a

Then you configure each of the inputs on the ADS1115 that you will be connecting:

sensor:
# ads1115-48
  - name: "Tank 1"
    id: ads1115_48_a0
    ads1115_id: ads1115_48
    multiplexer: 'A0_GND'
    update_interval: 60s
    gain: 6.144
    platform: ads1115
    unit_of_measurement: "V"
    icon: "mdi:gauge"
    accuracy_decimals: 2
  - name: "Tank 2"
    id: ads1115_48_a1
    ads1115_id: ads1115_48
    multiplexer: 'A1_GND'
    update_interval: 60s
    gain: 6.144
    platform: ads1115
    unit_of_measurement: "V"
    icon: "mdi:gauge"
    accuracy_decimals: 2

In the above code I have configured the first two analogue inputs of the ADS1115 which is using address 0x48. Read up on the ADS1115 as you will need to use a “gain” value that matches your input voltage range. In the example, above, the ADS1115 input 1 (A0) and input 2 (A1) are referenced to ground (GND) which is the -ve DC rail of the circuit.

So, if you are using throw-in level sensors, connect the output of the first current to voltage module (Tank 1 ??) to A0 and the output of the second current to voltage module (Tank 2 ??) to A1 of the ADS1115.

Hope that helps.

I have just connected all my bits together yesterday and the results look good. I was struggling a bit at first and I believe I found two possible issues.
The board type may be crucial - I had originally flashed my esp32 using the esphome io. It put the board as a esp32 dev board. I changed this to nodemcu-32s.
I also decided to send power from a 3v pin on my esp to the ads1115.
After making these two changes my error with receiving no connection from the ads1115 fixed straight away.
So now a couple more twekas before going into the box. If anyone has advice.
I read in this forum, possibly from hummingbear - that it is better to send the power to the ads1115 through a gpio. Then the ads1115 is only drawing power when you wake from deep sleep otherwise it is sucking 3v all the time?
I am also then considering that my project should all run on a parallel 3 x 18650 battery. Currently I draw .2A through my 24v battery bank (18650). If I tie my smaller 18650 battery to a 5v solar and use deep sleep I should have about 150 days of running without being charged. This is based on the power usage calculator at IOT Battery Life Calculator (thanks Mr swiss man)
I then thought I could use less power by instead of using a 5v relay to send a regular 18v to the sensor that I could use the small battery bank with a dc/dc step up to 18v as the gravity throw in sensor only draws minimal power. This step up would then be switched with a n channel mosfet driven by gpio from the esp32.
Does this make sense?
Pat

Got it - thanks!

Hi rusty_away,

Thansk for all your help, works for me very well now. I took the freedom to slightly modify your diagram based on your instructions and what worked for me:

image

Best wishes,

liflitz

2 Likes