so i have a few XKC-Y25-PNP sensors on a ESP32s, so there is one sensor to one board. i have tried to hook up 2 sensors to 1 board and it works… kind of. so when NOT inverted they both work changing back and forth to “Dry” & “Wet” every second no problem. the issue is when i set “inverted” to True they change to dry, but don’t change state when there is actually something there i.e… my finger (testing purposes can anyone help? I’m really only started to dip my toes into this kind of as i did just use off the shelf items so bear with me. this is the code:-
PS once i get this sorted i plan on changing the other 2 into 1 board
When posting a reply use the formatting symbol above the reply which looks like this
</> it then puts the dots in and tells you where to put your code.
When you hit that button above. It says “type or paste code here” this is where you paste your text. You will then end up with it looking something like this. This can then be checked for indentation or syntax issues.
The link to the forum guidelines is good, but it doesn’t explain why and how to format code as good as our Cookbook entry:
@darrenmonk87
It’s not that we don’t want to, but we need to see, if there are indentation or white space errors in the code.
That being said, as you took the code from the ESPHome page, it should be correct. Please keep in mind, you need to copy it exactly - no changes in white space and/or indentation.
What are you trying to achieve by setting “invert: true”? Maybe it would help, if you’d describe what you’re trying to achieve, and not what’s not working for you.
Anyway, it would make sense, if you’d post your complete YAML code from ESPHome, so we get a better feeling, what you’re trying to do.
so i have a 250 l water barrel that contains RO/Di water and im trying to use 2 XKC-Y25-NPN sensors on 1 ESP32. the end goal is to have 4 esnosrs on 2 ESP32s rather than 4-4.
So, let’s see, where this goes sideways. You posted the name of the sensors you’re using, but even after looking these up, I couldn’t find out, if this is what I assume it is: an analogue sensor.
If these sensors in fact are ADC (analogue to digital), you need to use other GPIO pins. ADC is only available on the “standard” ESP boards on GPIO 32 to 39, where you’re using 12 and 13.
The next thing is, why are you using the platform: gpio? Is there any specific reason? The standard way would be (still assuming your sensor is ADC) to use platform: adc. Please let me know why you chose this platform in the first place, as you said, the sensors are working.
And, as I said above, why do you use invert: true? What’s the reason for that?
I took the platform i think from ESPHome or ChatGTP. They detect water (even my finger) it gives a output od “dry” or “wet” im guessing because of the moisture class. The boards im using only have 30pins. As for the ADC i jave no idea. So by defult when there is nothing next to the sensor it says “wet” it needs to be “Dry” and vice versa here is a picure of the sensor if i can
So… its working correctly orher than wet/dry being backwards? It switches to Dry when in contact with water?
I would have never guessed!
Without a product link or better pics, its hard to say 100% but, those things are 99% digital sensors not analog.
We all started at the bottom too… If you dont know what those are how they work differently, its important you do. You’ll run into these two a lot. Sometimes analog may be best or your only option and other times you may have a choice to buy sensors in either analog or digital. Very very important to know.
Heres a guide to explain these two things. They have lots of good learning material too. Hint Hint…
ok thank you, ill give that a read. so i have got bot sensors into home assistant via esphome and they work. they change but incredibly fast back and forth, so i have added the “filter” and that is when it seems to go down the toilet. it no longer changes at all
Im not sure what you mean by “bot sensors” but, if its not working and you need help, you gotta give me something to work with. I lost my psychic skills and cant see what you’ve got going on unless you post things like your esphome config.
well its all in the post. that is meant to say “both”. when i apply the “Filter” to stop the sensor changing back and forth from “wet” to “dry” nothing happens at all, no change what so ever. i have been looking online to try and find a answer but have no luck finding anything
did you figure it out? If you do an online search for that sensor, “XKC-Y25-PNP” I had no problems finding specifications and user manual. It very clearly sais…