The sensor requires 24V DC, but I read it works fine with 10-30V, so I connected it to a 12V DC adapter I had. The output is 0-5V and I read ESP32 can only manage 3,3V so I used two resistors as voltage dividers before connecting it to GPIO 32. ESPHome configuration looks like this:
The distance from the well to the ESP32 in my basement is about 30 meters. When I connect the sensor with a 30 meter cable I get some small 0,1V spikes. When I connect via 10m, the spikes are bigger - around 0,3V.
I'm not sure where the issue lies and how to narrow it down. Could be faulty sensor, cable length, too low sensor voltage, incorrect esp32 connection, not really sure.
I have nothing against Polish, but I just don't understand any.
sorry, I corrected the link to point to the US version
The sensor requires 24V DC, but I read it works fine with 10-30V
..... not sure what to reply to this
This could be the issue, but there's a lot of Aliexpress offers with this sensor model QDY30A-B and they have this in the specs: power supply is DC24V (DC10-30V can be used). To test it I'd need to buy another adapter, so wanted to check other things first
If the sensor is analog, what do you read from it with a multimeter, both with and without the voltage divider?
Is the flat line below 0.1V correct? If so you can make a moving-average and add some "fuzzy logic" to throw-out the spikes.
Smoothing/averaging can help to filter the noise, but if all of the noise is in one direction you'll be left with a biased average.
A capacitor at between the ESP's analog input and ground may help to filter-out the spikes. Try 0.1uF. Or, with the voltage divider there's no danger of the capacitor "loading" the sensor's output so you can use a bigger capacitor for more filtering.
If you'll never need the full 5V range an over-voltage protection circuit might be better than a voltage divider. It will give you bigger readings and more resolution. (Of course it will also make the spikes proportionally bigger.)
Thanks for the hints, I was also thinking about removing the voltage divider, since the water will never be that high. The flatline is what's reported if there's nothing connected, I guess it should be zero, instead of 0,1v.
One thing I don't understand is why are there such spikes, instead of a constant line. I understand this isn't normal for an analogue sensor, right?
Ok, thanks. And If I need the 30 meters distance, then what can I do? This sensor is also sold in 4-20 mA and RS485 versions. Can one of those work over 30 meters and ESP32? I can also put ESP32 inside the well, but there's a lot of humidity there and problem with wifi.
Is it possible to make an improved diagram, with all wires? I suspect there's more clues in a complete diagram. And the voltage divider, is it sensor -> 20 k - ESP32 - 10 k - GND or the opposite?
there are more wires, because there's also a water flow sensor and temperature sensor connected, but in theory they are unrelated I can do some more testing with a bare esp32. But I previously had a different sensor connected to the same voltage divider and the diagram back the looked much better:
And I checked with a multimeter that the voltage was around 0,5V and behind the voltage divider ESP32 reported around 0,3V. 20kOhm is first as in the digram.
Tomorrow I'll check direct 4m connection with an empty ESP32 and just the 0-5V output to GPIO 32. Hopefully I won't fry ESP32 If I only put the sensor 10 cm under water for minimal output voltage
It looks much better now, and that initial spike is probably just from initializing, you could add a certain delay after the initial peak, and after that average the readings.
About the sensor itself and the way it measure, I'm just throwing in the possibility that it could be sensible to induced pressure waves in the water like sound, hence spikes in the readings.
The ESP32 is in a separate box, but I guess I could move/connect the two. ESP32 is separate because it's close to a flow meter on a pipe and initially I had a different pressure sensor that was 5V and I powered it directly with ESP32 without any power adapters. A shop recommended it to me, but I later read it's not submersible.
Not likely since you would need greater than 10V for the 10V output version.
Yeah, that's a good hint. I ordered a 24V adapter, should arrive tomorrow for testing, hopefully that's it.
I'm thinking about buying a multimeter e.g. this one to be able to check the output voltage instead of connecting it to ESP32 and do some tests connecting the output directly and via a 20m cable to check what's the difference. That multimeter has a oscilloscope, so maybe I can also see some simple short lived charts there of voltage changes.