Portable rain drop sensor made with Xiaomi door sensor

Just want to share with you guys the rain sensor I’ve made using Xiaomi’s door sensor, a waterproof battery case and a raindrop module.

First, I took out the door sensor PCB board from the casing, rip out (desolder) the reed switch and solder 2 wires onto it.

Then connect the wires and put it inside the waterproof battery case…

Finally close up the case cover, connect the raindrop module to the case and apply some hot glue on the exposed parts to protect them from the weather.

You can also hot glue a magnet at the back of the case so that you can stick the sensor on top of any metal surfaces.


That is at least the third project I have seen hacking these little sensors. Very cool.

1 Like

May I know what other projects with this sensor have you come across? I’m curious what else I can do with it.


Cool! Using it as a light switch is something I can make use of. But considering the price of the door sensor and the button is the same, it’s hard to justify the hack unless I have some spares around.

Fantastic project. Do you mind sharing where to buy the above

I got them from local electronic shop. For next version, I would use waterproof junction box such as this


so that it looks better without wires. Just drill 2 holes for the pins and seal it with hot glue.

For the raindrop module, you can consider this.


1 Like

Perfect timing to see this. (and sorry to necro this thread).
I just received in the mail today a aqara door sensor and a rain sensor (same as yours).
I was planning to extend the wire to have the aqara device inside and the sensor outside, but I love your solution.

BTW regarding the other switch project, a benefit is that the door sensor is an on/off switch as opposed to (the also great and very flexible) aqara push momentary switches.

Aqara door sensor, cheapo rain sensor from eBay, and a cheap weatherproof junction box from my local DIY store.
All in all about £12.


May I ask about your long term experiences with these kind of sensors? Do they still work reliably after some month? I assume, this sensor uses permanent dc power to monitor the original (reed) switch, thus I’d expect them to corrode quite fast because of electrolysis, when replacing the switch with the raindrop module.

And even without any electricity involved, I wouldn’t expect copper tracks on a standard pcb exposed 24/7 to sun, wind and weather to last more than some month either.

Does waterproofing the cable bushing with hot glue really work? Doesn’t the glue get brittle over time because of the permanent exposure to uv radiation?

Don’t get me wrong, I’d really appreciate if such a cheap design is working reliably in the long term, but I do have my doubts if this is really worth the effort.

Many years ago as a teenager I DIY’d some moisture sensors for indoor plants from prototype pcb boards. They were gone in days because of the corrosion and I had to replace them by graphite probes.

mine still working since the day I posted this (Oct 2018)

Too early to say for me, but tbh I share your concern regarding bare copper traces.


Thanks for the project. I just made mine and it worked on my desk. The funny thing is that after a period of a lot of rain the forecast shows no rain for the next 10 days(!) so I will have to wait to really test it. How do you deal with the “inverted” values of this sensor? If you change the sensor device class to moisture it will show “wet” (open) instead of dry.

I use this to invert the sensor:

# Binary sensors
  - platform: template
        friendly_name: "Rain"
        device_class: "moisture"
        value_template: >
          {{ is_state("binary_sensor.0x00158d000321d100_contact", "off") }}

Reading this, I wonder if you could use the Xiaomi water leak sensor as a rain detector (obviously not how much rain but good enough to know if it’s raining somewhat or not)

probably not, because when it stops raining, the contact may still be wet for a long time, showing its raining, when its not (have same problem with the proposed DiY, but I think that with the water leak the problem is bigger

Should be no problem but the water leak sensor is more expensive than the door sensor.

I have both.
The water leak sensor is not as “hackable” as the door sensor if you want to maintain its water resistance.
There are two metal contacts on the base of the water leak detector, but its not trivial to connect to them. They look like hex screws, but you cannot remove them.
Also I dont think that the water leak sensor is designed for extended exposure to moisture that will be suffered by a rain sensor. This is why @masterkenobi and I are using sealed outdoor enclosured for our electronics.

1 Like

This is so simple and cool. I used the Aqara variant door sensor and it’s working very well.

I had some pichers handy so I just snipped off the reed switch (rather than desoldering) , which left something easier to solder on to for me (my soldering sucks).

I’m keen to find a slimline housing for it. Haven’t found one I like yet.

nice :slight_smile:
Actually when I made mine I left the reed switch in place. As long as you are not expecting magnets to be moved near your sensor it should remain in a stable state.

1 Like