Arduino UNO Q - Rain Sensor
A rain sensor can detect rain or snow and measure rainfall intensity. It provides both a digital output (rain/no rain) and an analog output (intensity level). On Arduino UNO Q, the MCU's 12-bit ADC gives higher resolution intensity readings. With Bridge and Telegram, you get instant rain alerts on your phone.
In this tutorial, you will learn:
- What a rain sensor is and how it works
- How to wire the rain sensor to the Arduino UNO Q MCU
- How to read both the digital (DO) and analog (AO) outputs
- How to use Bridge to expose rain state and events to the Linux side (Python)
- How to receive Telegram alerts when rain is detected on Arduino UNO Q
- How to use OpenClaw on Arduino UNO Q with the rain sensor

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of the Rain Sensor
The rain sensor has two parts: a sensing pad and an electronic module.

Sensing pad: Placed outdoors (on a roof or window ledge). Has alternating power and sensor copper lines — water bridges these lines when rain falls.
Electronic module: Converts the pad signal into readable outputs:
- VCC pin: 3.3V to 5V power supply
- GND pin: Ground
- DO pin: Digital output — HIGH = no rain, LOW = rain detected. Sensitivity set by onboard potentiometer.
- AO pin: Analog output — lower value = more rain, higher value = less rain. Potentiometer does NOT affect AO.
It also has two LEDs:
- PWR-LED: Power indicator
- DO-LED: Lights up when rain is detected (DO pin LOW)
How It Works
- DO pin: The potentiometer sets a threshold. If rain exceeds the threshold, DO goes LOW. Adjust the potentiometer to set sensitivity.
- AO pin: Continuously outputs an analog voltage proportional to the water on the pad. On Arduino UNO Q the MCU reads this as a 12-bit value (0–4095) — lower values mean more rain.
※ NOTE THAT:
Connect VCC to a digital output pin (not always-on 5V) and power the sensor only during readings. This reduces electrochemical corrosion and extends sensor lifetime.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| Rain Sensor Pin | Arduino UNO Q MCU |
|---|---|
| GND | GND |
| VCC | D3 (controlled power) |
| DO | D4 |
| AO | A0 |
How To Program For Rain Sensor
- Set up pins:
- Power sensor, read both outputs, then power off:
- Check rain from digital output:
Arduino UNO Q Code
The Arduino UNO Q has two processors working together:
- The STM32 MCU reads both DO (digital) and AO (analog) outputs from the rain sensor every second
- The Qualcomm MPU runs Debian Linux and handles Wi-Fi, Python, and cloud connectivity
- In this section, only the MCU is programmed — the Linux side stays idle. A later section shows how both processors work together via Bridge.
※ NOTE THAT:
The Arduino UNO Q MCU uses a 12-bit ADC (0–4095). The AO intensity values will be in this range — adjust detection thresholds accordingly.
Detailed Instructions
First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.
- Connect: Wire the rain sensor to the Arduino UNO Q MCU as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q.
- Create a new App: Click the Create New App button.

- Give the App a name, for example: RainSensor
- Click Create to confirm.

- Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino. Keep other files as default.
- No library required — uses only the built-in digitalRead() and analogRead().
- Upload: Click the Run button in Arduino App Lab.

- Place a few drops of water on the sensing pad and observe the output in the Serial Monitor.
- Adjust the potentiometer on the module if the DO LED does not respond correctly.
App Lab Console Output
Bridge: Linux + MCU
This section shows how to program both processors of the Arduino UNO Q so the Linux side can read rain state and receive rain start events via Bridge:
- The rain sensor is connected to the MCU — the MCU reads DO and AO every second and caches the values
- The MPU cannot read the sensor pins directly — it calls Bridge functions to get state, analog value, or events
- The MPU has Wi-Fi — running full Debian Linux, it can send Telegram alerts the moment rain is detected
- Arduino_RouterBridge enables RPC communication between the two processors
- ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code
In short: MCU detects rain via DO pin → sets event flag → MPU polls Bridge → MPU sends Telegram alert.
MCU Code (Bridge)
Python Code (Bridge)
Detailed Instructions
- Connect: Wire the rain sensor to the Arduino UNO Q as shown in the wiring diagram.
- Open Arduino App Lab: Launch Arduino App Lab and wait for the board to be detected.
- Create a new App: Click Create New App, name it RainSensorBridge, then click Create.
- Paste the MCU sketch: Copy the MCU Bridge code above and paste it into sketch/sketch.ino.
- Paste the Python code: Copy the Python Bridge code above and paste it into the Python file in the App.
- Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.

- Search for Arduino_RouterBridge created by Arduino and click the Install button.
- Upload: Click the Run button in Arduino App Lab.

- Add water to the sensor pad — observe rain state change in both consoles.
App Lab Console Output
Telegram
Receive instant Telegram alerts when rain is detected on the Arduino UNO Q rain sensor.
MCU sketch: Keep the same MCU sketch from the previous Bridge section.
Python Code (Telegram)
Detailed Instructions
- Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
- Replace YOUR_CHAT_ID with your Telegram chat ID.
- Paste this Python code into your App's Python file (keep the same MCU sketch).
- Click the Run button. Add drops of water to the sensor — receive the Telegram alert instantly.
App Lab Console Output
ArduinoBot
OpenClaw
...OPENCLAW
OpenClaw support for Arduino UNO Q Rain Sensor is coming soon.
...OPENCLAW
Project Ideas
You can build many useful projects with the rain sensor and Arduino UNO Q:
- Rain Alert System: Mount the sensing pad on a rooftop — when rain starts, the MPU sends a Telegram alert with the AO intensity value, so you can take action (close windows, bring in laundry) from anywhere
- Automatic Awning Controller: Use the rain sensor with a motor/relay — when rain is detected, the MCU automatically closes an awning or blind via Bridge, and sends a Telegram notification
- Rainfall Logger: Log every rain detection event with timestamp and AO intensity to a CSV file on Linux — generate a daily rainfall summary and send it to Telegram at midnight
- Smart Irrigation Inhibitor: Combine with the pump tutorial — if rain is detected, Python skips the scheduled irrigation cycle to conserve water, and sends a Telegram message explaining why
- Rooftop Garden Monitor: Track rain intensity over time using AO values — Python calculates average rainfall every 15 minutes and sends a periodic Telegram summary
Challenge Yourself
Ready to go further with the rain sensor on Arduino UNO Q? Try these challenges:
- Easy: Classify AO intensity in Python: if int(value) > 3000 → "dry", > 1500 → "light rain", > 500 → "moderate rain", else "heavy rain" — include this label in every Telegram alert.
- Medium: Implement a rain duration tracker: record the start time when rain is detected and the end time when it stops — send a Telegram message when rain stops reporting how long it lasted.
- Advanced: Build a 24-hour rainfall chart: log AO values every minute to a list in Python — implement a /chart Telegram command that sends a text-based bar chart of rainfall intensity per hour over the last 24 hours.