Rain Detection Sensor

Rain Detection Sensor

Introduction

This experiment demonstrates how to measure voltage using Arduino's analog-to-digital converter (ADC).

Voltage Measurement Circuit

Components Needed

Circuit Setup

  1. Connect the potentiometer's wiper to the analog input pin A0 on the Arduino.
  2. Connect the other two pins of the potentiometer to 5V and GND.

This will allow you to vary the voltage at the analog input pin.

Voltage Measurement Circuit Setup

Code for Measuring Voltage

Upload the following code to your Arduino to measure the voltage:


const int sensorPin = A0;
int sensorValue = 0;
float voltage = 0.0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  sensorValue = analogRead(sensorPin);
  voltage = sensorValue * (5.0 / 1023.0);  // Convert ADC value to voltage
  Serial.println(voltage);
  delay(100);
}
            

Explanation

The Arduino reads the voltage from the potentiometer and converts the analog signal into a digital value using the ADC. The voltage is then calculated and displayed on the Serial Monitor.

Troubleshooting