ESPHome with Pressure Transducer

Hi All - I’m building a pool controller with temperature and pressure using a Esp32 DevC board. I have the temperature working just fine. On the pressure sensor i’m getting a lot of inconsistent readings of voltage. Its a basic transducer powered by 5Vs and reads between 0 and 150psi. Since my pool would never go above 50psi i simply connected the output to GPIO35 pin. The specs are 0psi=0.5V, 50psi=2.5v, 150psi=4.5V. I know normally i would need to shift the voltage down to 0-3.3V but in theory this should never go above 2.5V.

Below is the ESPHome code and its pretty simple. Problem is i’m getting inconsistent readings and they are no way close to what my analog gauge is reading so i assume this is a hardware problem. Can anyone see anything wrong with my setup here?

  - platform: adc
    name: "Filter Pressure"
    pin: GPIO35
    id: pressure
    update_interval: 30s
    unit_of_measurement: "PSI"
    accuracy_decimals: 2
    attenuation: 11db
    filters:
      - calibrate_linear:
        - 0.5 -> 0.0
        - 2.5 -> 50.0

Would love to know this too

I’m not familiar with ESPHome as I don’t use it, but it is likely not an ESPHome issue.

Analog readings are not straightforward in general, subject to noise and jitter. Pressure sensors respond to vibrations typically by bouncing.

Use shielded cable to connect the pressure sensor to the ESP32 board. Ground the shield at the ESP32 end.

Connect a low value capacitor (0.1 - 1uF) between the sensor output line and ground.

However this is done in ESPHome, configure the ESP32 to take a bunch of readings (say, 25 - 50) then discard any readings above your expected value, below 0 PSI, then average the good readings and send that to Home Assistant.

You also need a well filtered DC supply to the ESP32, and keep the sensor wires away from the WiFi end of the board.

ESPHome likely has some “rolling average” filters as well as high and low pass that would work.

Yes, looks like they do:

Yep - this is a hardware issue and not an ESPHome thing - but figured this group would have experience with sensors with the ESP module’s ADC pins. Your suggestions are super helpful and i will try those.

I’m currently using the “median” filter but not sure if that takes out the outliers that i’m getting. I may have to put a scope on this to see what the noise is. When the pool filter is off and there is zero pressure i’d expect 0.5V output - but its all over the place. So i must have an electrical source of noise somewhere.

@aaronCake - sorry to ask a basic question - but should the negative side of the Capacitor be on the ground side or the signal side? I’m using a 1uF electrolytic cap because thats what i have in stock in my spare parts…

What type of pressure sensor.
Have you seen this thread. Maybe it can give some information.

Seems that his sensor was very sensitive to noise and the power supply was important.

/Mattias

So today I swapped out the sensor for another one and voila - it works just fine and all day i have pretty consistent values. From time to time i do see some random values that the median filter takes care of. But its a pretty simple setup - power the sensor with 3.3 from the ESP and then plug the output of the sensor into an ADC pin. ESPHome does the rest!

What you’ve described is definitely a project I want to undertake soon. Do you have details on your build for a newbie?

yep - got it all built nicely and worked flawlessly for the entire season. was pretty easy but you need to be comfortable with the esp hardware. Feel free to ping me and i’d be happy to share what i did.

pool