How to Build a Simple Arduino Water Level Indicator with Buzzer Alarm

Introduction

I want to build a simple water level indicator that can detect the water level in a tank or container and sound an alarm if the water reaches a preset high or low level. This project will use an Arduino microcontroller board along with a few basic electronic components.

The main components I will need are:

The circuit will work by using the photocell sensor to detect the presence or absence of water at a specific height. The photocell sensor works by changing resistance depending on the amount of light hitting it. When placed at the desired water level in the tank, the sensor will detect when the water level reaches that point and trigger the buzzer alarm.

The Arduino will monitor the sensor input and control the buzzer. It will sound the alarm when the preset water level is reached.

How a Photocell Water Level Sensor Works

A photocell, also known as a photoresistor, is a light-controlled variable resistor. It works by changing resistance depending on the amount of light hitting the sensor.

When the photocell is in the dark, its resistance is very high, often up to 1M ohm. When light hits the sensor, the resistance decreases dramatically, down to a few hundred ohms.

I can use this variable resistance to detect the presence of water. By placing the photocell at a specific height on the side of a water tank, it will normally be hit with ambient light, meaning its resistance will be low. But when the water level rises up and submerges the sensor, blocking ambient light, the resistance will increase drastically.

This change in resistance is detected by the Arduino, allowing it to sense when the water level has hit the height of the sensor. I just need to preset a threshold value in the Arduino code to trigger the alarm.

Circuit Diagram

Here is the circuit diagram showing how to connect the components:

The photocell sensor is connected in series with a 10K resistor between 5V and ground. This creates a voltage divider, allowing the Arduino to measure the changing voltage depending on the photocell's resistance.

The buzzer is connected to Arduino pin 8 through a 220 ohm resistor. This resistor protects the buzzer from excessive current.

Setting up the Sensor

To position the photocell sensor, I will:

The key is positioning the sensor so it is exposed to ambient light when water is below it, but blocked from light when the water level rises over it. This triggers the change in resistance.

Arduino Code

The Arduino code will do the following main tasks:

Here is simple code to achieve this:

```
const int sensorPin = A0; // Photocell connected to analogue pin A0
const int buzzer = 8; // Buzzer connected to digital pin 8

int sensorValue = 0; // Variable to store sensor value

void setup() {

pinMode(buzzer, OUTPUT); // Set buzzer as output

}

void loop() {

sensorValue = analogRead(sensorPin); // Read analogue voltage from sensor

// Check if over threshold
if(sensorValue > 400) {

tone(buzzer, 1000); // Sound buzzer if sensor triggered

} else {

noTone(buzzer); // Turn off buzzer if below threshold

}
delay(10); // Small delay
}
```

The code is fairly simple. The key points are:

The buzzer will sound an alarm when water is detected. The threshold of 400 was chosen as an example and can be adjusted as needed.

Testing the Sensor

Once everything is wired up, the code can be uploaded to the Arduino board.

To test the water level sensor:

Once tuned correctly, the sensor will work reliably to detect water and sound the alarm automatically at the desired water level.

Conclusion

This simple Arduino based water level indicator provides an easy way to monitor tank water levels and sound an alarm when needed.

The photocell sensor along with Arduino input monitoring allows reliable and customizable water detection. With multiple sensors, several water levels can be monitored.

The buzzer alarm brings instant indication when the tank water reaches concerning levels. This type of automated indicator has many useful applications in irrigation, water storage systems, aquariums and more.

Some ways to expand this project include adding an LCD display to show the current water level, incorporating a float switch for analog water level readout, or connecting the alarm to the internet for text or email alerts.

I hope you found this water level indicator project useful! Let me know if you have any other questions.