Yes thanks I will do this tonight. Im sure it will work.
No doubts. Good ânightâ.
Good night and thank you!
Just voltage, 0-5v as thats the sensor I selected from the options when ordering.
Thanks all, this Voltage Divider worked well.
One thing I noticed is I do get quite fluctuating readings? Is this normal or can this be smoothed out?
My board is a WT32-ETH01 and the code as follows:
sensor:
- platform: adc
pin: GPIO15
name: "Water Tank Level"
update_interval: 60s
attenuation: auto
unit_of_measurement: "%"
accuracy_decimals: 1
filters:
- calibrate_linear:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.00 -> 0
- 0.40 -> 10
- 0.70 -> 20
- 1.00 -> 30
- 1.30 -> 40
- 1.60 -> 50
- 1.90 -> 60
- 2.10 -> 70
- 2.40 -> 80
- 2.70 -> 90
- 3.00 -> 100
Thanks
[21:40:02][D][sensor:094]: 'Water Tank Level': Sending state 2.51813 V with 2 decimals of accuracy
[21:40:03][D][sensor:094]: 'Water Tank Level': Sending state 2.48815 V with 2 decimals of accuracy
[21:40:04][D][sensor:094]: 'Water Tank Level': Sending state 2.51013 V with 2 decimals of accuracy
[21:40:05][D][sensor:094]: 'Water Tank Level': Sending state 2.53511 V with 2 decimals of accuracy
[21:40:06][D][sensor:094]: 'Water Tank Level': Sending state 2.47117 V with 2 decimals of accuracy
[21:40:07][D][sensor:094]: 'Water Tank Level': Sending state 2.53111 V with 2 decimals of accuracy
[21:40:08][D][sensor:094]: 'Water Tank Level': Sending state 2.47916 V with 2 decimals of accuracy
[21:40:09][D][sensor:094]: 'Water Tank Level': Sending state 2.48516 V with 2 decimals of accuracy
[21:40:10][D][sensor:094]: 'Water Tank Level': Sending state 2.54510 V with 2 decimals of accuracy
[21:40:11][D][sensor:094]: 'Water Tank Level': Sending state 2.47117 V with 2 decimals of accuracy
[21:40:12][D][sensor:094]: 'Water Tank Level': Sending state 2.46618 V with 2 decimals of accuracy
[21:40:13][D][sensor:094]: 'Water Tank Level': Sending state 2.52112 V with 2 decimals of accuracy
[21:40:14][D][sensor:094]: 'Water Tank Level': Sending state 2.51313 V with 2 decimals of accuracy
[21:40:15][D][sensor:094]: 'Water Tank Level': Sending state 2.51912 V with 2 decimals of accuracy
[21:40:16][D][sensor:094]: 'Water Tank Level': Sending state 2.47916 V with 2 decimals of accuracy
[21:40:17][D][sensor:094]: 'Water Tank Level': Sending state 2.49914 V with 2 decimals of accuracy
[21:40:18][D][sensor:094]: 'Water Tank Level': Sending state 2.53411 V with 2 decimals of accuracy
[21:40:19][D][sensor:094]: 'Water Tank Level': Sending state 2.52812 V with 2 decimals of accuracy
[21:40:20][D][sensor:094]: 'Water Tank Level': Sending state 2.48416 V with 2 decimals of accuracy
[21:40:21][D][sensor:094]: 'Water Tank Level': Sending state 2.52812 V with 2 decimals of accuracy
[21:40:22][D][sensor:094]: 'Water Tank Level': Sending state 2.54310 V with 2 decimals of accuracy
[21:40:23][D][sensor:094]: 'Water Tank Level': Sending state 2.50214 V with 2 decimals of accuracy
[21:40:24][D][sensor:094]: 'Water Tank Level': Sending state 2.51513 V with 2 decimals of accuracy
[21:40:25][D][sensor:094]: 'Water Tank Level': Sending state 2.53211 V with 2 decimals of accuracy
[21:40:26][D][sensor:094]: 'Water Tank Level': Sending state 2.48416 V with 2 decimals of accuracy
You can try with median filter with quite high window.
Also, in case you find out calibrate_linear is not âstraight lineâ, change it to:
- calibrate_linear:
method: exact
datapoints:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.00 -> 0
- 0.40 -> 10
- 0.70 -> 20
- 1.00 -> 30
- 1.30 -> 40
- 1.60 -> 50
- 1.90 -> 60
- 2.10 -> 70
- 2.40 -> 80
- 2.70 -> 90
- 3.00 -> 10
I feel like trying to eliminate the noise on the ADC would be a better option,
If it reads,
1.34000 volts thens it needs to read just 1.34000 volts.
Is there a wau to clean up the ADC noise?
Noise is always there. Itâs not necessarily better to filter if with hardware than with software. Use shielded twisted pair wiring (grounded at supply end), far from power wires, add some small capacitor etc. But in your case you donât need fast response so just filter in in your code.
Ok im all for software filters then,
Where do I start, with
method: exact
Thatâs for calibration, not for filtering.
I wrote to try median filter.
filters:
- median:
window_size: 15
send_every: 4
Thanks, I have tried with that, but still quite varying voltage. What kind of accuracy can I expect.
[23:12:31][D][sensor:094]: 'Water Tank Level': Sending state 2.60804 V with 1 decimals of accuracy
[23:12:35][D][sensor:094]: 'Water Tank Level': Sending state 2.60804 V with 1 decimals of accuracy
[23:12:39][D][sensor:094]: 'Water Tank Level': Sending state 2.61803 V with 1 decimals of accuracy
[23:12:43][D][sensor:094]: 'Water Tank Level': Sending state 2.61803 V with 1 decimals of accuracy
[23:12:47][D][sensor:094]: 'Water Tank Level': Sending state 2.62202 V with 1 decimals of accuracy
[23:12:51][D][sensor:094]: 'Water Tank Level': Sending state 2.62202 V with 1 decimals of accuracy
[23:12:55][D][sensor:094]: 'Water Tank Level': Sending state 2.62302 V with 1 decimals of accuracy
[23:12:59][D][sensor:094]: 'Water Tank Level': Sending state 2.63601 V with 1 decimals of accuracy
[23:13:03][D][sensor:094]: 'Water Tank Level': Sending state 2.65000 V with 1 decimals of accuracy
[23:13:07][D][sensor:094]: 'Water Tank Level': Sending state 2.65000 V with 1 decimals of accuracy
[23:13:11][D][sensor:094]: 'Water Tank Level': Sending state 2.65000 V with 1 decimals of accuracy
[23:13:15][D][sensor:094]: 'Water Tank Level': Sending state 2.63501 V with 1 decimals of accuracy
[23:13:19][D][sensor:094]: 'Water Tank Level': Sending state 2.63501 V with 1 decimals of accuracy
I donât know your sensors accuracy. Your log readings are within 1.5%, should be enough for water tank level.
You could replace that median filter with:
filters:
- delta: 0.1
With that itâs not changing the value if itâs not at least 0.1V higher or lower.
Try different filters and or higher values.
This isnât what your video shows.
Sorry I changed for testing.
Weird, now it doesnât report any values at all. The sensor just doesnât read or report any data.
sensor:
- platform: adc
pin: GPIO15
name: "Water Tank Level"
update_interval: 1s
attenuation: auto
# unit_of_measurement: "%"
accuracy_decimals: 1
filters:
- delta: 0.1
- calibrate_linear:
datapoints:
# Map 0.0 (from sensor) to 0.0 (true value)
- 0.00 -> 0
- 0.40 -> 10
- 0.70 -> 20
- 1.00 -> 30
- 1.30 -> 40
- 1.60 -> 50
- 1.90 -> 60
- 2.10 -> 70
- 2.40 -> 80
- 2.70 -> 90
- 3.00 -> 10
log output? what does that mean?
Values donât change? Reports 0.0? Reports NaN? Reports Unknown? Sensor is completely missing?
How much water are you measuring?
No one knows what your talking about if you arenât specific or provide config, logs, pictures⌠Anything thatâs better than a vague description open to interpretation please.
Sorry, my code is
sensor:
- platform: adc
pin: GPIO15
name: "Water Tank Level"
update_interval: 1s
attenuation: auto
# unit_of_measurement: "%"
accuracy_decimals: 1
filters:
- delta: 0.1
# - calibrate_linear:
# datapoints:
# # Map 0.0 (from sensor) to 0.0 (true value)
# - 0.00 -> 0
# - 0.40 -> 10
# - 0.70 -> 20
# - 1.00 -> 30
# - 1.30 -> 40
# - 1.60 -> 50
# - 1.90 -> 60
# - 2.10 -> 70
# - 2.40 -> 80
# - 2.70 -> 90
# - 2.70 -> 10
The log output is just this,
[09:05:12][D][api:102]: Accepted 192.168.1.102
[09:05:12][D][api.connection:1388]: Home Assistant 2024.8.3 (192.168.1.102): Connected successfully
[09:06:08][I][safe_mode:041]: Boot seems successful; resetting boot loop counter
[09:06:08][D][esp32.preferences:114]: Saving 1 preferences to flashâŚ
[09:06:08][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
Oh, Ok. Since you decided which tiny pieces of the config and log output are the only relevant information anyone needs to see in order to assist you then, you should have no problem figuring it out. Obviously the problem can be known from that 1/20th of a log output you chose limit information to.
Itâs not well documented how all filters work together. For example accuracy decimal and delta could fight against each other. Just play with the filters, your use case doesnât need super responsive values so tune it to your preferenceâŚ