Hi
I have twp pcs XKC-Y25-PNP water level sensors that I'm trying to set up. I found a similar post here. Just as OP in that post, I am able to do an analog read from the sensor giving a value 1024 or ~20 depending on trigger status. In the same post OP is adviced to switch to a digitalRead and work with HIGH/LOW. I'd prefer that solution but can't get the digitalRead to work. If I have the sensor on pin A0 digitalRead always returns 0 (printing the read value to serial monitor). If I move to a digital pin, it always returns 1. I have tried switching from pinType INPUT to INPUT_PULLUP, but to no avail.
I have a Lolin D1 Mini, so only one analog pin. If I could get this to work with a digital pin, that would be great!
I have played with the built-in examples AnalogReadSerial, DigitalReadSerial and DigitalInputPullup making changes here and there to test.
Hi
Thanks for the reply.
I'm not very harware or software skilled, but a lot of patience and my best friend is Google..
The sensor can be configured as both NC and NO with NO as default. When just using computer USB power through the D1 Mini I have little less than 4.5 v going through the sensor. Closing the circuit will make the voltage drop to about 3.15 v. So, not 0 v as described in the manual.
I haven't tried with a resistor. I only have a few 470R around but should give just above 1mA if my math is correct.. I didn't realize a resistor was needed but I'll see if there's a difference adding it.