Sensor

๐ŸŒง๏ธ Raindrop Detection Sensor

๐Ÿ“Œ Description

The raindrop detection sensor is designed to sense water droplets on its surface. It works by detecting changes in conductivity: when raindrops fall on the sensorโ€™s board, the circuit closes and sends a signal to the microcontroller.

๐ŸŽฏ Use

In our projects, the raindrop sensor is used to:

  • Detect rain for weather monitoring.
  • Trigger protective actions (like closing a window or covering electronics).
  • Help robots react to environmental conditions outdoors.

๐Ÿ‘‰ Think of the raindrop sensor as the robotโ€™s rain detector โ€” it knows when itโ€™s wet outside.

Module parameters

Pin name Description
G GND (Power Input Negative)
V VCC (Power Input Cathode)
S Digital signal pins
A Analog signal pins
  • Supply voltage: 3.3V/5V
  • Connection: 2.54mm pin header
  • Installation method: double screw fixing

๐Ÿ–ฅ๏ธ Code Explanation

import machine

pin25 = machine.Pin(25, machine.Pin.IN)    # Sensor input
pin26 = machine.Pin(26, machine.Pin.OUT)   # LED output

while True:
    if pin25.value() == 1:                 # If no rain detected
        pin26.value(0)                     # LED OFF
    else:                                  # If rain detected
        pin26.value(1)                     # LED ON

Step by Step

  1. pin25 = machine.Pin(25, machine.Pin.IN) โ†’ Reads the raindrop sensorโ€™s digital signal.
  2. pin26 = machine.Pin(26, machine.Pin.OUT) โ†’ Controls the LED (output).
  3. while True: โ†’ Loop that repeats forever.
  4. if pin25.value() == 1: โ†’ Checks if the sensor is dry (no rain).
  5. pin26.value(0) โ†’ LED stays off when no rain is detected.
  6. else: โ†’ If raindrops are detectedโ€ฆ
  7. pin26.value(1) โ†’ LED turns on to indicate rain.

๐Ÿ‘‰ Together, this program makes the LED light up when rain is detected.


โœ… Conclusion of the Test

  • If the LED stays off when the sensor is dry, and turns on when raindrops touch the sensor, the program is working correctly.
  • This test shows how the robot can sense rain and react with an output (LED).
  • Later, the sensor could be used to trigger alarms, activate windshield wipers, or protect outdoor robots from water damage.
On this page