top of page
Writer's pictureSanskruti Ashtikar

Creating a Rain Sensor System Using TinkerCAD

Introduction


Rain sensors are widely used in various applications such as automatic wipers in cars, smart irrigation systems, and weather monitoring devices. By detecting the presence of rain, these systems can automatically respond to changing weather conditions. In this tutorial, we'll walk you through the process of creating a simple rain sensor system using TinkerCAD and Arduino. This project is a great way to learn about sensors, circuit design, and programming with Arduino.



Materials Needed


To build this project in TinkerCAD, you will need the following components:

  • Arduino Uno

  • Breadboard

  • Rain Sensor Module (Raindrop sensor)

  • LED

  • Buzzer

  • Resistor (220Ω for LED)

  • Jumper Wires


Step 1: Setting Up the Components


  1. Arduino and Breadboard: Start by opening TinkerCAD and creating a new circuit project. Drag and drop an Arduino Uno and a breadboard onto the workspace.

  2. Rain Sensor Module: The rain sensor module has two parts: the sensor board (which detects rain) and the control board (which outputs the signal). Connect the following pins:

    • VCC pin of the control board to the 5V pin on the Arduino.

    • GND pin to the GND pin on the Arduino.

    • The DO (digital output) pin of the control board to digital pin 7 on the Arduino.

  3. LED and Buzzer: These components will serve as indicators when rain is detected.

    • Connect the longer leg (anode) of the LED to digital pin 13 on the Arduino through a 220Ω resistor. Connect the shorter leg (cathode) to GND.

    • Connect the positive leg (longer leg) of the buzzer to digital pin 8 on the Arduino and the negative leg to GND.


Step 2: Wiring Diagram


Your wiring should look like this:

  • Rain Sensor Module:

    • VCC → 5V on Arduino

    • GND → GND on Arduino

    • DO (Digital Output) → Digital Pin 7 on Arduino

  • LED:

    • Anode (long leg) → Digital Pin 13 on Arduino (through a 220Ω resistor)

    • Cathode (short leg) → GND on Arduino

  • Buzzer:

    • Positive Leg → Digital Pin 8 on Arduino

    • Negative Leg → GND on Arduino



Step 3: Writing the Code


Now that the circuit is set up, let’s write the Arduino code to control the rain sensor system.


int rainSensorPin = 7;  // Digital pin connected to rain sensor's digital output
int ledPin = 13;        // LED connected to pin 13
int buzzerPin = 8;      // Buzzer connected to pin 8
int sensorState = 0;    // Variable to store the rain sensor status
void setup() {
  pinMode(rainSensorPin, INPUT);  // Set the rain sensor pin as input
  pinMode(ledPin, OUTPUT);        // Set the LED pin as output
  pinMode(buzzerPin, OUTPUT);     // Set the buzzer pin as output
  Serial.begin(9600);             // Initialize serial communication for debugging
}
void loop() {
  sensorState = digitalRead(rainSensorPin);  // Read the state of the rain sensor
  if (sensorState == LOW) {  // Rain detected (assuming LOW indicates rain)
    digitalWrite(ledPin, HIGH);    // Turn on the LED
    digitalWrite(buzzerPin, HIGH); // Activate the buzzer
    Serial.println("Rain detected!");  // Print message to the serial monitor
  } else {
    digitalWrite(ledPin, LOW);     // Turn off the LED
    digitalWrite(buzzerPin, LOW);  // Deactivate the buzzer
    Serial.println("No rain detected.");  // Print message to the serial monitor
  }
  
  delay(1000); // Delay for stability
}




Step 4: Simulating the Circuit


  1. After writing the code, click the "Start Simulation" button in TinkerCAD.

  2. The rain sensor will detect "rain" (which you can simulate by manipulating the sensor’s value in TinkerCAD).

  3. When rain is detected, the LED lights up, the buzzer sounds, and a message is printed to the serial monitor. If no rain is detected, the LED and buzzer remain off.


Step 5: Understanding the Code


  • The rain sensor module outputs a digital signal (LOW or HIGH) depending on whether it detects rain. This signal is read by the Arduino.

  • When rain is detected (sensor output is LOW), the Arduino turns on the LED and activates the buzzer to indicate the presence of rain.

  • The serial monitor provides a real-time log of the sensor's state, helping you debug and monitor the system's performance.


Conclusion


You have successfully created a rain sensor system using TinkerCAD and Arduino. This project demonstrates how sensors can be used to detect environmental changes and trigger responses in electronic systems. You can expand on this project by integrating it with a weather station, an automatic wiper system, or even a smart irrigation system that stops watering when it rains.


By following this guide, you’ve gained practical experience in working with sensors, designing circuits, and programming microcontrollers. Keep experimenting and pushing the boundaries of what you can create with TinkerCAD and Arduino!


Want us to guide you through your project or make the project for you ?







Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



8 views0 comments

Related Posts

See All

Comments


bottom of page