D1 Mini rain sensor

Hello,
does someone has a code for the D1 Mini for a rain detection sensor?
Thank you!!

Some stuff here should help. But the bigger issue will be the corrosion on that sensor will render it next to useless after a few weeks in the rain.

yes, but its not the code for a D1

All you have to change is the analogue input pin assignment and the board type.

could you tell me how depending on the connection scheme at the image? that would be great. thank you in advance!!

Just change the lines

pin: GPIOxx

To whatever GPIO pin you have them connected to.

I wonder if you can just hook these up directly as a GPIO binary sensor without the intermediate hardware similar to the door sensor set-up?

For the board type:

esphome:
  name: rain-sensor
  platform: ESP8266
  board: d1_mini

For the pin allocation change this section to use the correct pin for the D1 as per below.

  - platform: adc
    pin: A0
    name: "Rain Sensor"
    attenuation: 11db
    internal: true

Which should be avoidable by not permanently connecting DC voltage to the sensor but only turning it on when taking a measurement - this and other improvements can be found here :point_down:

Hi. Could you finish your project? Can you write your latest working config pls? I would like to make the same rain sensor, but i couldn’t get the right code for it.

My Solution:

esphome:
  name: wetterstation
  friendly_name: wetterstation
  platform: ESP8266
  board: d1_mini

logger:

api:
  encryption:
    key: "xxx"

ota:
  password: "xxx"

wifi:
  ssid: xxx
  password: xxx
  domain: ".fritz.box"
  ap:
    ssid: "Wetterstation Fallback Hotspot"
    password: "xxx"

web_server:
  local: true


time:
  - platform: homeassistant
    timezone: Europe/Berlin
    id: homeassistant_time

switch:
  - platform: restart
    name: "Restart Wetterstation"

text_sensor:
  - platform: version
    name: Wetterstation Version



sensor:
  - platform: adc
    pin: A0
    name: "Regen Wert"
    id: RegenWert
    internal: true
    update_interval: 10s
    accuracy_decimals: 1    
    unit_of_measurement: 'V'
  - platform: template
    name: "Regen Sensor Volt"
    unit_of_measurement: "V"
    lambda: return id(RegenWert).state;
    update_interval: 10s

binary_sensor:
  - platform: gpio
    pin:
      number: D1
      inverted: true
    name: "Regensensor"


Regen Sensor Volt:
1V = No Rain
if below 1V than its raining

Regensensor = Rain / No Rain

1 Like

I have rebuilt it, but my sensor reports 0.5v when there is no rain.
So I always have rain. Any idea how I can change this?

Thanks

found my mistake :frowning:

What was the problem?

wrong wireing :weary:

Hello

I have the Rainsensor running like the one above.
It works very well.
The only question I have is how to leave the sensor on for a certain time when rain is detected, for example. Could also be a second sensor.
I plan to use the rain sensor for my lawnmower robot, as soon as it rains go into the garage for 3 hours.
I think it’s better if the sensor itself can do this than if I trigger it via an automation. Or do you have any better suggestions.

Thank you

A “delayed_off” should be sufficient for that task

2 Likes

You could do what indeeed said but put that filter on a copy binary sensor if you’d like to keep the original sensor separate.

1 Like

@indeeed @Mahko_Mahko

Thank You both!

binary_sensor:
  - platform: gpio
    id: Regensensor
    pin:
      number: D1
      inverted: true
    name: "Regensensor"
  - platform: copy
    source_id: Regensensor
    id: Regensensor_Verzoegert
    name: "Regensensor_Verzoegert"
    filters:
      - delayed_off: 1h

works perfect!

2 Likes

Would you please show me your wiring diagram ?
Thank you!