thank you, for the answer but i did take the code directly from ESPHome as i don’t really know how to format it correctly
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.
i see, now i get ya.
binary_sensor:
-
platform: gpio
pin:
number: GPIO13
inverted: true
name: “1/4 Full”
device_class: moisture
filters:- delayed_on: 10s
- delayed_off: 10s
-
platform: gpio
pin:
number: GPIO14
inverted: true
name: “1/2 Full”
device_class: moisture
filters:- delayed_on: 10s
- delayed_off: 10s
i hope this is better
No
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.
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "3D Printer Button"
on_press:
- switch.toggle: relay
sensor:
- platform: wifi_signal
name: "Greenhouse Signal Sensor"
update_interval: 60s
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.
esphome:
name: rodi-x2-sensors
friendly_name: RoDi X2 Sensors
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "SHHHHHHHHHHHHHPreformatted text"
ota:
- platform: esphome
password: "BLABLABLA"
wifi:
ssid: !secret 2_wifi_ssid
password: !secret 2_wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Rodi-X2-Sensors Fallback Hotspot"
password: "d9yOhOhmxDil"
captive_portal:
binary_sensor:
- platform: gpio
pin:
number: GPIO13
inverted: true
name: "1/4 Full"
device_class: moisture
filters:
- delayed_on: 10s
- delayed_off: 10s
- platform: gpio
pin:
number: GPIO14
inverted: true
name: "1/4 Full"
device_class: moisture
filters:
- delayed_on: 10s
- delayed_off: 10s
if this worked thank you “paddy0174”
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.
Thanks for taking the time to format it!
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
can anyone help with this?
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
i tried to do what you suggested about the “ADC” but i’m getting nowhere
esphome:
name: rodi-x2-sensors
friendly_name: RoDi X2 Sensors
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: ""
ota:
- platform: esphome
password: ""
wifi:
ssid: !secret 2_wifi_ssid
password: !secret 2_wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Rodi-X2-Sensors Fallback Hotspot"
password: ""
captive_portal:
sensor:
- platform: adc
pin:
number: GPIO13
mode: INPUT
inverted: true
name: "1/2 Full"
device_class: moisture
- platform: adc
pin:
number: GPIO14
mode: INPUT
inverted: true
name: "1/4 Full"
device_class: moisture
Are you sure they’re even analog? Theyre much more common as digital sensors.
No one can tell which sensors you have. Theres no model #, no product link, data sheet?
They’re digital sensors…
You need binary_sensor not adc
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…
Output - On/Off High level is On
If a sensor is On/Off or High/Low this is a Digital Sensor not Analog.
https://www.naukri.com/code360/library/analog-vs-digital-sensors
You need to configure it as a binary_sensor just like I said earlier.
You should end up with something just like this…
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode: INPUT
inverted: true
name: "1/2 Full"
device_class: moisture
Hi, did you managed to get good readings with this sensor_ did you use any other sensors_ I am having trouble with a ultrasound sensor, for measuring a plastic diesel tank, but I am getting horrendous results.
I am considering sensor that glue on the exterior of the tank, It would be nice to have a % sensor, but right now I am ok with 3 levels measured with this type of sensors if I can’t find any other way, I am more looking for a low level sensor than a % sensor
You will likely get better answers starting a new thread instead of reusing an old one that is only remotely related to what you are trying to do.
Start with WHAT you are trying to accomplish and what things you have tried to solve it (your HOW).
Details always help. A 1000 liter tank likely needs a different solution from a 10 liter tank. What the fluid is matters. What accuracy you need does too.