Building an ESP8266 with multiple pressure sensors (using ADS1115 and ESPHome)

I have similar pressure sensor and works fine with ADA1115

I tried just that, but still struggling on software side, I definitely need to check into that again (but sensors are not installed anyway)

Guys any pointers on articles/ videos on hooking up the ADS1115 with the D1Mini and how stuff gets configured in ESPHome?

Thanks a lot @Patraff for suggesting this … I was about to throw out my D1Minis :joy:

I haven’t used D1 minis. I use mostly ESP32 now. I have followed the advice of swiss guru Andreas whose testing showed the ADC on esp32 is pretty crap and now link sensors through ads1115 to one pin.

1 Like

Hi,
i’m trying to make a water flow / pressure sensor ^^

Am i going on the right way?

Thks

Wemos D1 Mini;
whadda WPSE470 (Flow sensor);
DFRobot SEN0257 (Pressure sensor).

Hi @DrJeff!

I read many things on the web but i can’t figure out a solution for my water pressure sensor. It seems you got yours to work with an ESP32 so I would appreciate if you could help me with this issue, please.

I am trying to read values from a 100 PSI water pressure but I can’t find a way to get it working well with my ESP32-WROOM-32 controller.
The pressure sensor specs are:

Input: 0-100 psi.
Output: 0.5V – 4.5V linear voltage output. 0 psi outputs 0.5V, 50 psi outputs 2.5V, 100 psi outputs 4.5V.

This is my configuration in EspHome YAML file:

# Pressure: raw (volts)
  - platform: adc
    pin: A5
    name: "Pressão caldeira"
    id: "pressao_caldeira_volts"
    unit_of_measurement: "v"
    icon: "mdi:gauge"
    accuracy_decimals: 2
    update_interval: 1s

  # Pressure: psi
  - platform: template
    name: "Pressão caldeira (PSI)"
    id: "pressao_caldeira_psi"
    lambda: |-
      return 5 * id(pressao_caldeira_volts).state * 43.75 - 21.875;
    update_interval: 1s
    unit_of_measurement: 'PSI'
    icon: "mdi:gauge"

  # Pressure: bar
  - platform: template
    name: "Pressão caldeira (Bar)"
    id: "pressao_caldeira_bar"
    lambda: |-
      return id(pressao_caldeira_psi).state * 0.068948;
    update_interval: 1s
    unit_of_measurement: 'bar'
    icon: "mdi:gauge"

With this configuration I get values changing each 1s that goes from -5.5 PSI (negative!) to 27 PSI. I know that the “real” pressure is arround 21 PSI (because I can read it in the analog pressure meter).

Do I need a level shifter when using this pressure sensor with the ESP32? If so, what would be the resistences I should use? Note that the pressure I am reading will never be greater then 58 PSI so I should never receive more than 3.3V in my ESP32 pin (by the way, I am using the pin ADC2-5/GPIO12).

Can someone help me with this issue? I am not a electrician so… I am trying to learn from what I read here and there.

Thank you very much.


EDIT

Just found the solution some minutes after submiting this post! Maybe this information can help someone in the future dealing with the same problem:

I read this warning:

“Note: ADC2 pins cannot be used when Wi-Fi is used. So, if you’re using Wi-Fi and you’re having trouble getting the value from an ADC2 GPIO, you may consider using an ADC1 GPIO instead. That should solve your problem.”

… and I was using one of the ADC2 pins! (ADC2-5) I just changed it to the pin 33 (ADC1-5) and it worked like a charm with @DrJeff code!

Thank you.

1 Like

You solved it, but I went with ADS1115 partly because I ended up with a few analogue sensors and so I could ensure my ESP board was protected. But who cares. They are super cheap!

Awesome you figured it out! Glad it works

Hi, would you mind sharing your ESPHome config?
Trying to figure out how to set it up.
I also use a ADS1115 with an ESP32.

And i would love to measure in bar och kg, if someone have any idea how to do the calculations for that?

Thanks in advance :slight_smile:

@sabbath

ads1115:
  - address: 0x48

sensor:
  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 4.096
    name: "Irrigation Pressure"
    id: IP
    internal: false
    unit_of_measurement: 'bar'
    accuracy_decimals: 1
    icon: "mdi:volts"
    update_interval: 2s
    filters:
      - median:
          window_size: 5
          send_every: 5
          send_first_at: 5
      - calibrate_linear:
          - 0.51 -> 0
          - 3.38775 -> 3.7
      - lambda: |-
          if (x <= 0){      
            return 0;
          } else {
            return x;}
  • calibrate_linear:
    converts voltage to bar.

First thing you need to do is to find out the numbers to put into calibrate_linear. That means you need an actual pressure dial that is in line with your pipework. I then set my pipe to full pressure (in my numbers 3.7bar) and then set the pressure to zero. In both cases, I measured the corresponding voltage from the dashboard logs of the ESP node. With that I could set up the calibrate_linear.

I have a second pressure sensor at the bottom of a deep tank; this with a lambda calculation allows me to know the depth and therefore the litres of the tank. Hope this helps and is clear. Good luck

1 Like

Got it working, thanks :slight_smile:

1 Like

Hello Everyone,
Im attempting something similar and wanted some assistance using the below components. Also would prefer to use ESPhome for this. This is for a home water pump and water tank system. Would like to know if this is possible to do using these components and ESPhome. Any diagram would also be appreciated. Thank you.

Controller: NodeMCU - I already have this.
Water Flow: GREDIA G3/4" - I already have this and would need only 1 of these.
Water PSI and Presence: Gravity: Analog Water Pressure Sensor - I dont have these and would need 2 of these.
Tank Water Level: Gravity: Photoelectric High Accuracy Liquid Level Sensor for Arduino - I dont have this and would need 1 of these.

How big is your tank and what type of tank is it?
Is your water pump pressure activated i.e is your pipe permanently pressurised?
Why do you need two psi pressure sensors?

I see that the psi pressure and flow sensors are 5v ADC and assume you will also need ADS115

The following is code for the ADS1115. GND needs to be same between the node and the ADS. And you will also need a good solid 5v supply for the flow, pressure sensors and ADS1115. The wiring diagrams are on the link you posted

Edit: I just saw my my code is above

Hello Julian,

The tank is a 200 gallon tank. The way the pump is being setup is with a standard mechanical pressure switch that comes with the pump. Those that are set to 20 psi min and 40 psi max. So when you turn a faucet on the pressure goes down, when it hits 20 psi the pump turns on and will stay on until it reaches 40 psi. Process repeats. Its a continuous system so the city water is always filling the tank and the house is always feed from the tank/pump.

The reason for the 2 psi and presence sensors is for monitoring the city water and the tank/pump water. So the first one will tell me if the city is providing water and the second one is to tell me if everything is ok with the system. For example, if there is water in the tank but no water or psi in the system then something is wrong.

With my limited knowledge this is what I drew up. Would this be correct? The pins on the headers might have the wrong order but I can correct the order when im putting it together.

Thanks.

Hi. I did also try your suggested setup but got from ESPHome error, Component ads1115 requires component i2c.

  • address: 72
    Have u any idea what I am doing wrong here?

@catdogmaus indeed that error message is completely correct. As the instructions state this platform communicates with ADS1115 using i2c. You must set i2c up first.

I post instructions for ADS1115 and you will see that there is a link on the page to the i2c page. Good luck

Hello @ErnieP sorry slow to get back. I think that looks good. I have never done a wiring diagram so looks very organised! I usually end up with a spreadsheet for all the pins. You are only using two. And the correct ones! I have just built a new board set up yesterday for my rain sensor. Good luck

Somehow this is not working for me, I simply get errors

[10:52:38][I][i2c.arduino:069]: Results from i2c bus scan:
[10:52:38][I][i2c.arduino:071]: Found no i2c devices!
[10:52:38][D][api.connection:1031]: Home Assistant 2023.7.3 (172.16.0.158): Connected successfully
[10:52:38][C][ads1115:073]: Setting up ADS1115…
[10:52:38][C][ads1115:074]: Address: 0x48
[10:52:38][E][ads1115:076]: Communication with ADS1115 failed!