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