ESP32 - Pressure Transducer: Static (incorrect Reading)

Hi everyone-

I’ve created a pretty basic pressure sensor in HA for my pool filter using an ESP32 and a 3 wire (5v, GND, COMM) 100psi pressure transducer. However, after working for a little while, it begins to return a static value of 66.375 PSI over and over again with no fluctuation whatsoever. (See logs below):

I have also included my fairly basic code in ESP Home below as well.

Any ideas what is causing this?

captive_portal:
  
sensor:
- platform: adc
  name: "Filter Pressure"
  pin: GPIO32
  id: pressure
  update_interval: 10s
  unit_of_measurement: "PSI"
  accuracy_decimals: 2
  attenuation: 11db
  filters:
    - calibrate_linear:
      - 0.5 -> 0
      - 4.5 -> 100
    - median:
         window_size: 50
         send_every: 5
1 Like

The returned value of 66 psi would mean the ADC conversion is measuring 2.1V which is pretty much the maximum voltage the ESP32 ADC can read. Try adding a voltage divider with two 10k resistors to halve the voltage output from the sensor. I’d also disable the filters for testing so that the raw voltage gets reported.

1 Like

Ah … really appreciate the feedback. I’m going to have to do some research as I’m afraid I have no idea why that means / how to do what you’ve described. (This is my first ESP project… so learning as I go here)

The one follow up question would be… why does it work sometimes (I.e. matches my manual gauge perfectly). Also why such a low cut off voltage if it has a 5v pin and advertised to be able to handle 0-5v sensor input?

Could you post the details on the pressure sensor and the ESP32 board you are using? Some of the boards have the scaling resistors included.

Approximately how long does it provide accurate readings?

Do you have a multimeter to measure the voltage independently?

100 Psi 1/8" NPT Thread Pressure Transducer Sensor Pressure Sender Stainless Steel Oil Pressure Transmitter for Car Automobile Motorcycle Boat Oil Fuel Air Gas Liquid Water Pressure https://a.co/d/034ZEke

2pcs ESP32-DevKitC core Board… https://www.amazon.com/dp/B089F6LRBS?ref=ppx_pop_mob_ap_share

I’m terms of how long it operates - I believe it worked for upwards of 30 mins once. Other times it bounces back and forth between accurate reading and the attic 66psi reading every other reading or so.

Yea I do have a multi meter.

My experience:-
I used a Gravity SEN0257 pressure sensor to measure water pressure in a similar setup.
(0 to 10bar (~145psi) 0.5V to 4.5V )
I used a 2k2 resistor in series with signal connection to the ESP input pin. This is to prevent any issues with voltage levels inadvertently damaging the ESP input. (Limiting any current flow into the I/O pin).
The analogue input on the ESP version I used can measure to around 3.2V.
So the input easily scaled from 0 to 6.5bar
I was only interested in measuring to less than 5bar, so all good so far.

I then had some strange readings intermittently, which would come and go.
In between, it worked as expected.
I have an oscilloscope, which I eventually connected to see if I could identify what was happening.
Sure enough, occasionally, the output of the sensor was bursting into oscillation, giving the odd readings. It would start and stop randomly.
I tried putting various capacitors on the sensor supply for de-coupling etc.
Nothing has any effect.
I eventually put a 0.01uF cap directly across the sensor output. (to 0V).
That stopped it and it’s worked perfectly ever since.

Appreciate the feedback!

Any chance you could send a pic of how your wiring configuration worked out?

I’ve never tried adding resistors or capacitors and quite frankly don’t really know how / where to add them in relation to the ESP pins / on the breadboard.

Really appreciate the feedback. Feel like there is an actual path to getting this thing working consistently now.

So this how the resistors and capacitor should be connected to improve the signal issue, scale it 50%, and limit current into the ESP pin.

Scaling on the adc input would need cut in half as well.

  filters:
    - calibrate_linear:
      - 0.25 -> 0
      - 2.25 -> 100
1 Like

This ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exactly as mulcmu has described.
:+1:

I am working on doing this with a D1 Mini (so no need for scaling resistors) and a [G1/4 Pressure Transducer Sensor Pressure Gauge Transduce Input 5V Output 0.5-4.5V / 0-5V Pressure Transmitter for Water Gas Oil(0-80PSI)]

Being that it’s still winter now and the pool is still closed I just have it working on the bench now. My question is since it is just open to the free air, I would expect it to be measuring 0 +/- a reasonable error factor, but I am getting readings that change constantly.

[16:42:22][D][sensor:093]: ‘Filter Pressure’: Sending state 0.63232 psi with 2 decimals of accuracy
[16:42:32][D][sensor:093]: ‘Filter Pressure’: Sending state 2.96875 psi with 2 decimals of accuracy
[16:42:42][D][sensor:093]: ‘Filter Pressure’: Sending state 1.35742 psi with 2 decimals of accuracy
[16:42:52][D][sensor:093]: ‘Filter Pressure’: Sending state 0.14893 psi with 2 decimals of accuracy
[16:43:02][D][sensor:093]: ‘Filter Pressure’: Sending state 2.80762 psi with 2 decimals of accuracy
[16:43:12][D][sensor:093]: ‘Filter Pressure’: Sending state 2.16309 psi with 2 decimals of accuracy
[16:43:22][D][sensor:093]: ‘Filter Pressure’: Sending state -0.65674 psi with 2 decimals of accuracy
[16:43:32][D][sensor:093]: ‘Filter Pressure’: Sending state 0.14893 psi with 2 decimals of accuracy
[16:43:42][D][sensor:093]: ‘Filter Pressure’: Sending state 2.72705 psi with 2 decimals of accuracy
[16:43:52][D][sensor:093]: ‘Filter Pressure’: Sending state 1.76025 psi with 2 decimals of accuracy
[16:44:02][D][sensor:093]: ‘Filter Pressure’: Sending state -0.33447 psi with 2 decimals of accuracy
[16:44:12][D][sensor:093]: ‘Filter Pressure’: Sending state 2.80762 psi with 2 decimals of accuracy
[16:44:22][D][sensor:093]: ‘Filter Pressure’: Sending state 2.00195 psi with 2 decimals of accuracy
[16:44:32][D][sensor:093]: ‘Filter Pressure’: Sending state 0.22949 psi with 2 decimals of accuracy
[16:44:42][D][sensor:093]: ‘Filter Pressure’: Sending state 3.29102 psi with 2 decimals of accuracy
[16:44:52][D][sensor:093]: ‘Filter Pressure’: Sending state -1.05957 psi with 2 decimals of accuracy
[16:45:02][D][sensor:093]: ‘Filter Pressure’: Sending state 3.61328 psi with 2 decimals of accuracy
[16:45:12][D][sensor:093]: ‘Filter Pressure’: Sending state 3.45215 psi with 2 decimals of accuracy
[16:45:22][D][sensor:093]: ‘Filter Pressure’: Sending state 2.48535 psi with 2 decimals of accuracy
[16:45:32][D][sensor:093]: ‘Filter Pressure’: Sending state 0.71289 psi with 2 decimals of accuracy
[16:45:42][D][sensor:093]: ‘Filter Pressure’: Sending state 2.24365 psi with 2 decimals of accuracy
[16:45:52][D][sensor:093]: ‘Filter Pressure’: Sending state 3.29102 psi with 2 decimals of accuracy
[16:46:02][D][sensor:093]: ‘Filter Pressure’: Sending state 2.96875 psi with 2 decimals of accuracy
[16:46:12][D][sensor:093]: ‘Filter Pressure’: Sending state -0.57617 psi with 2 decimals of accuracy
[16:46:22][D][sensor:093]: ‘Filter Pressure’: Sending state 1.84082 psi with 2 decimals of accuracy
[16:46:32][D][sensor:093]: ‘Filter Pressure’: Sending state 1.51855 psi with 2 decimals of accuracy
[16:46:42][D][sensor:093]: ‘Filter Pressure’: Sending state -0.81787 psi with 2 decimals of accuracy
[16:46:52][D][sensor:093]: ‘Filter Pressure’: Sending state 0.22949 psi with 2 decimals of accuracy
[16:47:02][D][sensor:093]: ‘Filter Pressure’: Sending state 3.21045 psi with 2 decimals of accuracy
[16:47:12][D][sensor:093]: ‘Filter Pressure’: Sending state -0.89844 psi with 2 decimals of accuracy
[16:47:22][D][sensor:093]: ‘Filter Pressure’: Sending state 3.53271 psi with 2 decimals of accuracy
[16:47:32][D][sensor:093]: ‘Filter Pressure’: Sending state -0.57617 psi with 2 decimals of accuracy
[16:47:42][D][sensor:093]: ‘Filter Pressure’: Sending state 3.12988 psi with 2 decimals of accuracy
[16:47:52][D][sensor:093]: ‘Filter Pressure’: Sending state 0.22949 psi with 2 decimals of accuracy
[16:48:02][D][sensor:093]: ‘Filter Pressure’: Sending state 0.79346 psi with 2 decimals of accuracy
[16:48:12][D][sensor:093]: ‘Filter Pressure’: Sending state 0.71289 psi with 2 decimals of accuracy

Here is a copy of my YAML:

captive_portal:

sensor:
  - platform: adc
    pin: A0
    name: "Filter Pressure"
    id: "FilterPressure"
    unit_of_measurement: "psi"
    icon: "mdi:gauge"
    filters:
    - offset: 0
    - lambda: return ((x * 3.3 -0.5) * 25);  
    update_interval: 10s
    accuracy_decimals: 2

Any Ideas?

Where is your calibrate_linear? Should go first in filters.

Thanks, but when I include that, my values are 200-300 psi

Hello @waank1

Sorry if you have already done some of these steps already, but to get your pressure transducer working for the first time you need to:

  1. comment out all your filters
  2. measure the raw voltage from the ADC with pressure at zero and then at the Working Maximum Voltage. You will need a manual pressure gauge to measure the pressure at that same Working maximum Voltage
  3. these four numbers (voltage and pressure) then are used as the numbers for linear_calibrate; which you can now comment back into the yaml. Test again and make sure you sensor is reporting the correct maximum pressure as the manual pressure gauage.

if you are still getting incorrect numbers then start again and take it back to raw voltage to solve. There is no lambda formulas needed

Please note that 4.5/ 5v is above the working voltage of D1 Mini so I have used a ADS ADS1115 which depending on power supply can go to 5v.

I am using same board and same type of pressure transducer for a few years.

Thanks Mate, I commented out all of the filters and am now getting consistent readings of 0 +/- .1, I am planning on using this on my pool filter which only reads from 0 to 20 psi, so I shouldn’t have a problem driving the D1 voltage out of spec. I can’t really try it out till I put the pool in service around mid May. I do have a manual pressure gauge and a T-fitting so I should be able to get it fairly accurate.

BTW I saw that you are from the South Coast, my wife is from Dorset!

1 Like