I’m trying to use esphome to measure the water pressure using sensors. Board is an ESP32-WROOM32 and the sensors are from DFRobot SEN0257 Analog Water Pressure Sensor.
But I always get negative values (even if the voltage at the analog port is positive) and can’t find out what I’m doing wrong or can it be that filters: calibrate_linear doesn't work?
ESPHome version 1.17.1
[18:30:25][D][adc:058]: 'Heizung "Wasserdruck Rücklauf"': Got voltage=0.35V
[18:30:27][D][adc:058]: 'Heizung "Wasserdruck Vorlauf"': Got voltage=0.34V
[18:30:27][D][sensor:099]: 'Heizung "Wasserdruck Vorlauf"': Sending state -0.72707 bar with 2 decimals of accuracy
[18:30:27][D][sensor:099]: 'Heizung "Wasserdruck bar Delta"': Sending state 0.02177 bar with 2 decimals of accuracy
[18:30:34][D][adc:058]: 'Heizung "Wasserdruck Warmwasser"': Got voltage=0.05V
[18:30:35][D][adc:058]: 'Heizung "Wasserdruck Rücklauf"': Got voltage=0.35V
[18:30:37][D][adc:058]: 'Heizung "Wasserdruck Vorlauf"': Got voltage=0.36V
[18:30:37][D][sensor:099]: 'Heizung "Wasserdruck Vorlauf"': Sending state -0.62694 bar with 2 decimals of accuracy
[18:30:37][D][sensor:099]: 'Heizung "Wasserdruck bar Delta"': Sending state -0.07837 bar with 2 decimals of accuracy
The 2nd linear calibration you have set is like multiplying by 4. Can you comment out that filter and see what you get . If it’s not too hard disconnect the power to the other sensors just to rule out some type of power fluctuation.
This means that it make an avarage on aproximate the latest 100 values and send the value to the next filter or output every 100 value.
But that means that you have to decrease update_interval to 0.1 s.
But due to the filter it will send a value every 10 s.
I would skip the linear calibration until you know that you get good data out.
If you don’t get proper adc values. I suggest is to buy a ads1115 adc.The ADS1115 can measure 4 adc signals.
I have used it when I needed to measure the difference between two analog signals.
The second theory.
I also saw that you have a resistor in your wiring diagram. According to the pdf from dfrobot there should not be any there. The sensor output a voltage which should go directly to the adc.
Both signals are not very constant and fluctuate. I’m still looking for how I can smooth it out and find a better method to calibrate the sensors.
But think that it is in the tolerance range.
I still have to test the whole thing with all sensors, in this case I only did a simple test to rule out other sources of error.
The ADS1115 has lower noise level. It fluctuate 0.02 compare to the adc that fluctuate 0.15.
So it almost 7 times less noisy.
Are the pressure meters not tested in air pressure or installed?
If i air maybe the dont work as good in air.
I’m not sure about the scaling you have done. It seems that it comes from the arduino uno example.
The analog read on uno gives a value between 0-1023 on the range of 5 volts. So to calculate the voltage you do (x/1024.0)*5.0 = x in volts.
The value you get here in esphome is already in volts i think.
The scaling factor should something more like (x- offset)* 4.0 to get it in bar.
# I²C Bus
i2c:
- id: bus_b
scl: 26
sda: 25
scan: True
ads1115:
- address: 0x48
sensor:
# ---------------------------
# SEN0257 on ADC PORT GPIO35
# The nominal output voltage offset of the sensor is 500mV, but due to the
# zero-drifting of the internal circuit this may varies and an initial calibration setup is
# required. For calibration, connect the sensor’s 3 pin cable (VCC, GND, and SIGNAL) to the
# Arduino (+5V, GND, and A0) without attaching the sensor to the water pipe and run your demo program for once.
# Write down the lowest voltage value through the serial monitor and revise the “const float offset” value to complete calibration.
# After calibration, the sensor is ready for the intended purpose!
# see: https://www.codrey.com/arduino-projects/how-to-play-with-a-water-pressure-sensor/
# ---------------------------
- platform: adc
name: "SEN0257 ADC GIPO35 pressure"
pin: GPIO35
id: outgoing_water_pressure_raw
icon: "mdi:gauge-low"
update_interval: 5s
state_topic: ${topic_prefix}/SEN0257_ADC_GPIO35
unit_of_measurement: "bar"
accuracy_decimals: 2
attenuation: 11db
filters:
- lambda: |-
if(x-0.41<0) return 0.00;
return (x-0.41) * 4.00;
# -------------------------------
# SEN0257 on ADS1115 PORT A0_GND
# -------------------------------
- platform: ads1115
multiplexer: 'A0_GND'
gain: 6.144
update_interval: 5s
name: "SEN0257 ADS1115 A0_GND"
id: incomming_water_pressure_A0_GND
state_topic: ${topic_prefix}/SEN0257_ads1115_A0_GND
unit_of_measurement: "bar"
icon: "mdi:gauge"
accuracy_decimals: 2
filters:
- lambda: |-
if(x-0.429188<0) return 0.00;
return (x-0.429188) * 4.00;
# -------------------------------
# TRIM POT on ADS1115 PORT A0_GND
# -------------------------------
- platform: ads1115
multiplexer: 'A1_GND'
gain: 6.144
update_interval: 5s
name: "TRIM POT ADS1115 A1_GND"
id: incomming_water_A1_GND
state_topic: ${topic_prefix}/TRIM_POT_ads1115_A1_GND
unit_of_measurement: "bar"
icon: "mdi:gauge"
accuracy_decimals: 2
filters:
- lambda: |-
if(x<0) return 0.00;
return (x) * 4.00;
Using the sensor on the ADC GIPO35 does not work because it has too high an error rate.
The sensor on the ADS115 works better, but here too the error is in the range of 0.15.
To make sure that the calculation is correct, I connected a potentiometer to the A1 port of the ADS115 and set the voltage to 1.2 volts. But I see that this does not remain constant either. This fluctuates between 960 mV and 1.02 V.
It looks like it is due to the 5V voltage of the ESP32 DEV which is not constant and therefore the fluctuations occur.
I am now looking for a solution to stabilize the 5V voltage for the sensors.
I am no good on trying to stabilize the power. So I cannot help you there.
Do you know nature of the noise. If it is high frequency noise you can just sample with higher speed and use a sliding window filer or the exponential filter I mentioned earlier.
The sensor type of piezo resistance sensor has quite low signal to noise ration according to google. Maybe it what you going to expect?
The accuracy of the sensor is 0.5% so that means at 16 bar that is 0.08 bar accuracy at the sensor.
I think that it all depend on what you are going to use it for. How high accuracy do you need and how fast must it react to change. If you want high accuracy use a mean filter. But then you loose that ability see fast changes.
The problem is the signal on the data channel, which fluctuates too much if the sensor is used without it being mounted on the pipe.
Does this mean that If you connect all sensors to the pipe. The fluctuations will be less or is it that you see problems when you have connected them all three sensors the adc that they interfere with each other.
About the filtering:
These settings send only every 100 values. That it means it will take quite a long time to get any data in your case 500s. Thats almost a value every 8 minutes.
Try to change the update interval to 1s instead of 5 for your sensors and use the filter below.
This should result in a value every 10 sec if you have change the update interval 1 s.
The alpha is set to 0.01 that means that is approximate a mean of the last 100 values.
So If you want a mean of the last 10 values it becomes 1/10 =0.1.
The signal from the ocilloscope seems rather periodic. Do you see that same when you connect the sensor to the scope directly with out any esp connected. You could also compare it to the power supply voltage ripple. If you have a ocilioscope than you could measure things independent.
Yesterday I spent most of the day investigating the cause.
Filter works now (Thanks)
Power pack and power supply
If I use a high-quality power supply, it works better and it makes no difference whether I use the ESP32 with ADC or an ESP8266 with ADS1115.
But I only get 4.85V to the 5V connection and the SEN0257 is very sensitive to the supply voltage. If I use a potentiometer, the signals are correct and there are no errors in the measurement.
I now have to find a solution, the supply voltage for the ESP and the sensors with which I can work.
continuous_mode (Optional, boolean): Set if the ADS1115 should continuously measure voltages or only measure them when an update is called. Please enable this for the CT Clamp Current Sensor integration. Defaults to off.
It sounds like you need continuous measurements, I believe you need to set this to true.
Negative, when i use continuous_mode: True on ESP32 : Reading ADS1115 timed out
## continuous_mode: True
[08:32:00][I][mqtt:210]: MQTT Connected!
[08:32:00][I][app:059]: setup() finished successfully!
[08:32:00][W][ads1115:116]: Reading ADS1115 timed out
[08:32:00][W][ads1115:116]: Reading ADS1115 timed out
[08:32:00][W][ads1115:116]: Reading ADS1115 timed out
[08:32:00][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][I][app:105]: ESPHome version 1.18.0b3 compiled on May 15 2021, 08:31:24
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][I][main:126]: Raw Value A3: 0.490875
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:01][I][i2c:033]: Scanning i2c bus for active devices...
[08:32:01][I][i2c:040]: Found i2c device at address 0x48
[08:32:01][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
[08:32:02][W][ads1115:116]: Reading ADS1115 timed out
## continuous_mode: False
08:34:12][I][mqtt:210]: MQTT Connected!
[08:34:12][I][app:059]: setup() finished successfully!
[08:34:12][I][app:105]: ESPHome version 1.18.0b3 compiled on May 15 2021, 08:33:36
[08:34:13][I][i2c:033]: Scanning i2c bus for active devices...
[08:34:13][I][i2c:040]: Found i2c device at address 0x48
[08:34:13][I][main:195]: Raw Value A0: 0.046875
[08:34:13][I][main:126]: Raw Value A3: 0.490687
[08:34:13][I][main:150]: Raw Value A2: 0.494437
[08:34:13][I][main:171]: Raw Value A1: 0.487500
[08:34:14][I][main:126]: Raw Value A3: 0.491062
[08:34:14][I][main:150]: Raw Value A2: 0.494437
[08:34:14][I][main:171]: Raw Value A1: 0.487500
[08:34:15][I][main:126]: Raw Value A3: 0.490875
[08:34:15][I][main:150]: Raw Value A2: 0.494063
[08:34:15][I][main:171]: Raw Value A1: 0.487500
[08:34:16][I][main:126]: Raw Value A3: 0.491062
[08:34:16][I][main:150]: Raw Value A2: 0.494250
[08:34:16][I][main:171]: Raw Value A1: 0.487500
[08:34:17][I][main:126]: Raw Value A3: 0.490875
[08:34:17][I][main:150]: Raw Value A2: 0.494250
[08:34:17][I][main:171]: Raw Value A1: 0.487500
[08:34:18][I][main:195]: Raw Value A0: 0.047063
[08:34:18][I][main:126]: Raw Value A3: 0.490312
[08:34:18][I][main:150]: Raw Value A2: 0.494250
Hi petsie,
i’m encountering the same problem you faced an year ago. I have no stable voltage supply, and causes fluctuation on ADC wich is sampling voltabe from a CT Clamp. The fluctuation is more visible at voltage near 0.
Did you find a solution to filter out noise from ADC or to stabilize voltage supply?
Same here. I’ve tried at least 3 sensors. They work for like 5 mins (enough to calibrate) and then they become very inconsistent. I’ve tried on both ESP8266 and ESP32s
I’m using one of these df robot sensors It kinda works. I get consistent readings over the last 6 months. The problem is that it reads about 240psi when it is actually 140.
I only use it to see if there is pressure not as limiter. It’s also connected to the adc on the esp.