Interfacing Rain Sensor with Raspberry Pi 3 ☔
🎯 Objective
To detect the presence of rain using a Rain Sensor module with Raspberry Pi 3 and display alerts on the console. Perfect for smart weather stations and automatic window systems!
🧰 Components Required
Component | Quantity |
Raspberry Pi 3 | 1 |
Rain Sensor Module (Analog & Digital Output) | 1 |
Jumper Wires | As required |
Breadboard | 1 |
⚡ Circuit Connections
Rain Sensor Pin | Connect To |
VCC | 5V (Raspberry Pi) |
GND | GND (Raspberry Pi) |
D0 (Digital Out) | GPIO17 (Pin 11) |
🧠 Python Code
import RPi.GPIO as GPIO
import time
RAIN_SENSOR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(RAIN_SENSOR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(RAIN_SENSOR_PIN) == 0:
print("🌧️ Rain Detected!")
else:
print("☀️ No Rain.")
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
📊 Output
- Prints "🌧️ Rain Detected!" when water droplets are sensed.
- Otherwise prints "☀️ No Rain."
💡 Applications
- Smart weather monitoring
- Automatic rain-sensing wipers/windows
- Rain alert systems for farmers
🎯 उद्दिष्ट
रेन सेन्सर वापरून पावसाची उपस्थिती शोधणे आणि रास्पबेरी पाय 3 वर कन्सोलमध्ये अलर्ट दर्शविणे.
🧰 लागणारे साहित्य
घटक | संख्या |
Raspberry Pi 3 | 1 |
Rain Sensor Module | 1 |
जंपर वायर्स | गरजेनुसार |
ब्रेडबोर्ड | 1 |
⚡ सर्किट कनेक्शन
Rain Sensor | जोडणी |
VCC | 5V (Raspberry Pi) |
GND | GND (Raspberry Pi) |
D0 (Digital Out) | GPIO17 (Pin 11) |
🧠 पाइथन कोड
import RPi.GPIO as GPIO
import time
RAIN_SENSOR_PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(RAIN_SENSOR_PIN, GPIO.IN)
try:
while True:
if GPIO.input(RAIN_SENSOR_PIN) == 0:
print("🌧️ पाऊस सुरू आहे!")
else:
print("☀️ पाऊस नाही.")
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
📊 आउटपुट
- पाणी आल्यावर "🌧️ पाऊस सुरू आहे!" असे प्रिंट होते.
- नसल्यास "☀️ पाऊस नाही." असे प्रिंट होते.
💡 उपयोग
- स्मार्ट हवामान यंत्रणा
- स्वयंचलित विंडो/वायपर सिस्टम्स
- शेतीसाठी पावसाचे अलर्ट सिस्टीम
Comments