Arduino Projects

GSM based Water Level Monitoring and Control using Arduino, Sim900A, and Ultrasonic Sensor

GSM Based Water Level Monitoring:

GSM based Water Level Monitoring and Control using Arduino, Sim900A, and Ultrasonic Sensor- In today’s article, you will learn how to make GSM based Water Level Monitoring and control system using Arduino Nano, GSM SIM900A module, and HC-SR04 Ultrasonic Sensor.

By the way, I have written many articles related to the water level monitoring and control system, in which I have used different technologies to monitor water levels and control water pumps. For example,




allpcb circuit

Wireless Water level monitoring using Long-range LoRa transceiver modules, with the help of this project water level inside a tank can be monitored within a range of 5 Kilometers.

IoT based water level monitoring and control system using ESP32 WiFi + Bluetooth module, Waterproof ultrasonic Sensor, and the new Blynk V2.0. With the help of this water level monitoring system, you can monitor the water level inside a tank from anywhere in the world.

I also made a water level monitoring system using a Pressure Sensor and displayed the water level information on LEDs.

If you’re interested in exploring technologies beyond GSM, such as LoRa and IoT platforms, I highly recommend read my previous articles on the Water Level Monitoring and Control Systems.



Amazon Links:

Arduino Nano USB-C Type (Recommended)

HC-SR04 Ultrasonic Sensor

GSM SIM900A

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.



Anyway, let’s get back to our project.

GSM based Water Level Monitoring

For the demonstration purposes, I am going to monitor the water level inside a bucket which you can think of as the water tank and you can think of this 110/220Vac Bulb as the water Pump.

GSM based Water Level Monitoring

The Ultrasonic sensor is right on top of the water tank. Everything is in place and it looks good; so let’s go ahead and power up the entire system.

As usual, I am using my designed Arduino and LoRa based development board, because I specially designed it for projects like these. I am not using a separate power supply for the GSM SIM900A module, because my board has a 5V and 3A power supply which is more than enough to power up the Arduino, GSM, and relays.



If you don’t want to make such a development board then you can make a dedicated 5V and 3A power supply.

When the 110/220Vac supply is connected never touch the relay contacts as it can be dangerous. So, as far as possible, wear protective gloves and perform such high voltage experiments in the presence of a companion or someone having basic knowledge of the electrical systems.

When the water level in the water tank drops below a certain level, the Arduino starts sending alert messages with the help of GSM module.

GSM based Water Level Monitoring

In the programming, I’ve utilized a timer to ensure that alert messages are generated every 2 minutes. Having an alert message every 2 minutes could indeed be quite annoying. However, it’s important to note that this time duration is adjustable, and I will explain how to modify it later in this article.




We have two options, we can turn ON the water pump automatically or we can do it manually. In my case, I don’t want the water pump to turn ON automatically. Anyway, let’s write a message to turn ON the water pump.

GSM based Water Level Monitoring

abc123 is a password to add a little bit of security so that nobody else can control the water pump, you can use any combination of letters, characters, and numbers. Then the word relay, and command on. The % signs are used to separate these parameters. I have already explained this in my GSM based Home automation project. Anyway, the message is ready and let’s send it to control the water pump.

GSM based Water Level Monitoring

You can see the bulb just turned ON which represents a water pump. Now, it will stay ON until the water tank is filled. I filled the Bucket and then the Light “Water Pump” automatically turned OFF.

I have also added another feature that is; you can check the water level inside a water tank at anytime, all you need is to write a message which consists of a password and the word level.

GSM based Water Level Monitoring

Anyway, before I send this message, first let’s remove some water. Now, let’s send the message and check the level.

GSM based Water Level Monitoring

This is pretty amazing; with this feature you will never run out of water because you can check the water level at anytime and you can turn ON the water pump whenever you want, you don’t need to wait for the water tank to get completely empty.



GSM based Water Level Monitoring, Circuit:

GSM based Water Level Monitoring

Connect the 5V TXD and RXD pins of the GSM SIM900A module to the Arduino digital pins D9 and D10. Connect the 5V and GND pins of the GSM module to the 5V and 3A power supply Vin and GND. The power supply 5V and GND are connected to the Arduino Vin and GND pins.

Connect the VCC and GND pins of the HC-SR04 Ultrasonic Sensor to the Arduino Vin and GND pins. Connect the Trigger and Echo pins of the Ultrasonic Sensor to the Arduino D2 and D3 pins respectively.

Connect the VCC and GND wires of the relay module to the 5V and GND. Connect the relay input pin to the Arduino digital pin D4. The Vin and Gnd wires should be connected to a 5V and 3A power supply.

GSM based Water Level Monitoring

You can follow this circuit diagram if you want to make your own 5V and 3A power supply. Now, let’s go ahead and take a look at the programming.



GSM based Water Level Monitoring, Programming:



About the code:

I started off by adding the SoftwareSerial.h header file. Using the SoftwareSerial we can define multiple serial ports. You know, in Arduino Uno and Arduino Nano we have only one serial port that is available on pins 0 and 1. As I want to use the Arduino’s default serial port for the debugging purposes; so that’s why I defined another serial port for the GSM SIM900A module.

Next, I defined pins for the Trigger, Echo, and Relay.

I also defined some variables for storing the water level value, password, incoming message, and alert message.

I also defined some variables for the timer.

Code inside the setup() function is exactly the same as explained in my previous GSM based home automation project. So, let’s go to the loop() function.

Using the millis() function, we calculate the seconds and minutes.

So, when the minutes are greater than or equal to 2,  we set the Zero_Level_Flag to false which signals the Arduino to send an alert message. When the alert message is sent the Zero_Level_flag is again set to true, and this whole process starts again.

All the other instructions are from my GSM based home automation project, all these instructions are used to split the string message and store the corresponding values in variables. Then we use these different parameters for requesting the water level and for controlling the water pump. I highly recommend you guys should watch my video on the GSM based home automation project. Anyway, that’s all for now.




Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button