Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

Water Level Monitoring with Arduino

Importance and Utility of Water Level Monitoring

Water level monitoring is a crucial aspect of various applications, such as irrigation systems, water tanks, and flood detection systems. By monitoring the water level, we can ensure efficient water usage, prevent overflow or depletion, and even detect potential water-related disasters. Arduino, with its versatility and ease of use, provides an excellent platform for implementing water level monitoring systems.

Project: Water Level Monitoring System

In this project, we will create a water level monitoring system using Arduino. The objective is to measure the water level in a tank and provide real-time data for further analysis or control actions. The system will utilize an ultrasonic sensor to measure the distance between the sensor and the water surface, and then calculate the water level based on this distance.

Functionalities:

  1. Real-time water level measurement
  2. Visual indication of water level using LEDs
  3. Serial communication for data logging or remote monitoring

List of Components:

  1. Arduino Uno - 1x
  2. Ultrasonic Sensor (HC-SR04) - 1x
  3. Breadboard - 1x
  4. Jumper Wires - Male to Male - 10x
  5. LED (any color) - 3x
  6. Resistor (220 ohms) - 3x
  7. USB Cable (Type A to B) - 1x

Note: All components can be easily found online or at local electronics stores.

Examples:

Example 1: Basic Water Level Monitoring

// Water Level Monitoring with Arduino

// Define pins for ultrasonic sensor
const int trigPin = 2;
const int echoPin = 3;

// Define pins for LEDs
const int ledLow = 4;
const int ledMedium = 5;
const int ledHigh = 6;

// Variables for water level calculation
long duration;
int distance;
int waterLevel;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Set pin modes for ultrasonic sensor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  // Set pin modes for LEDs
  pinMode(ledLow, OUTPUT);
  pinMode(ledMedium, OUTPUT);
  pinMode(ledHigh, OUTPUT);
}

void loop() {
  // Trigger ultrasonic sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Measure echo duration
  duration = pulseIn(echoPin, HIGH);

  // Calculate distance in centimeters
  distance = duration * 0.034 / 2;

  // Calculate water level based on distance
  waterLevel = 100 - map(distance, 0, 100, 0, 100);

  // Print water level to serial monitor
  Serial.print("Water Level: ");
  Serial.print(waterLevel);
  Serial.println("%");

  // Control LEDs based on water level
  if (waterLevel < 30) {
    digitalWrite(ledLow, HIGH);
    digitalWrite(ledMedium, LOW);
    digitalWrite(ledHigh, LOW);
  } else if (waterLevel < 70) {
    digitalWrite(ledLow, LOW);
    digitalWrite(ledMedium, HIGH);
    digitalWrite(ledHigh, LOW);
  } else {
    digitalWrite(ledLow, LOW);
    digitalWrite(ledMedium, LOW);
    digitalWrite(ledHigh, HIGH);
  }

  // Delay before next measurement
  delay(1000);
}

Example 2: Remote Water Level Monitoring via Serial Communication

// Water Level Monitoring with Arduino - Remote Monitoring

// Define pins for ultrasonic sensor
const int trigPin = 2;
const int echoPin = 3;

// Variables for water level calculation
long duration;
int distance;
int waterLevel;

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Set pin modes for ultrasonic sensor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  // Trigger ultrasonic sensor
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // Measure echo duration
  duration = pulseIn(echoPin, HIGH);

  // Calculate distance in centimeters
  distance = duration * 0.034 / 2;

  // Calculate water level based on distance
  waterLevel = 100 - map(distance, 0, 100, 0, 100);

  // Send water level data to serial monitor
  Serial.print("Water Level: ");
  Serial.print(waterLevel);
  Serial.println("%");

  // Delay before next measurement
  delay(1000);
}

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.