100% found this document useful (1 vote)
717 views21 pages

Arduino Water Pressure Sensor Project, Water Level Pressure Sensor

This document discusses a project using an Arduino water pressure sensor to measure and monitor water levels. It describes connecting the sensor to an Arduino, calibrating the sensor, and using it to display the water pressure on an OLED display and indicate the water level with LEDs as it changes. Code and instructions are provided to implement this water level monitoring system.

Uploaded by

DoruGiurca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
717 views21 pages

Arduino Water Pressure Sensor Project, Water Level Pressure Sensor

This document discusses a project using an Arduino water pressure sensor to measure and monitor water levels. It describes connecting the sensor to an Arduino, calibrating the sensor, and using it to display the water pressure on an OLED display and indicate the water level with LEDs as it changes. Code and instructions are provided to implement this water level monitoring system.

Uploaded by

DoruGiurca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Arduino Projects

Arduino Water Pressure Sensor Project, Water


Level Pressure Sensor
 Engr Fahad  • August 14, 2022  14,429

Table of Contents
1. Arduino Water Pressure Sensor,
Description:
2. Altium Designer + Altium 365 + Octopart:
3. Amazon Links:
4. Water Pressure Sensor:
4.1. Water Pressure Sensor
Specifications:
4.2. Features
5. Pressure Sensor Interfacing with Arduino:
6. Water Pressure Sensor Calibration:
6.1. Download the following Libraries:
6.2. Water Pressure Sensor Calibration
Code:
7. Water Pressure Sensor Arduino
Programming:
8. Watch Video Tutorial:

Arduino Water Pressure Sensor,


Description:

1 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Arduino Water Pressure Sensor Project, Water


Level Pressure Sensor- Recently I got this water
pressure sensor from DFRobot; which I am going to use
with Arduino Nano. You can also use this sensor for
measuring Gas pressure. In this tutorial, I will only use this
sensor for water detection, and for measuring the water
pressure, and for measuring the water level inside a water
tank. Using this Water Pressure Sensor you can build
yourself a smart water control system using Arduino, Oled
display Module, and some LEDs.

You can also watch my video on IoT based Water level


monitoring and automatic water pump control system
using the ESP32 WiFi + Bluetooth Module, Waterproof
Ultrasonic Sensor, and the New Blynk V2.0 more…

It has happened to me and my family members many times


that when we start the water pump, we often forget because
we are busy with other work. And we don’t remember that
we have turned the water pump ON, due to which a lot of
water is wasted. And obviously, it makes a lot of difference
on the electricity bill as well.

So, to avoid this type of situation, I have resorted to this


water pressure sensor, by using which I can measure
the water pressure inside the pipe. When the water level in
the tank changes, then obviously the water pressure inside
the pipe will also change. So, if I use Arduino to measure
the water pressure, I can easily make a control system for
myself, which will alert me when the water tank is empty, or
when the water tank is full.

2 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

To explain this idea, I have done this basic setup, you can
see the water tap and I have also attached the Water
pressure sensor. Here, this water storage drum is
representing the water tank.

As I am using this Water pressure sensor for the first time,


so this tutorial is going to be a kind of a getting started
tutorial. And I will try my level best to explain the most
basic things including technical specifications, Pinout, it’s
interfacing with Arduino, its calibration, final circuit
diagram, and final Arduino code. Anyway, first let me share
with you the Final test results, and afterward, I will explain
everything else.

3 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Altium Designer + Altium 365 +


Octopart:

Altium 365 lets you hold the fastest design reviews ever.
Share your designs from anywhere and with anyone with a
single click. it’s easy, leave a comment tagging your
teammate and they’ll instantly receive an email with a link
to the design. Anyone you invite can open the design using
a web browser. Using the browser interface, you’re able to
comment, markup, cross probe, inspect, and more.
Comments are attached directly to the project, making
them viewable within Altium designer as well as through
the browser interface. Design, share, and manufacture, all
in the same space with nothing extra to install or configure.
Connect to the platform directly from Altium
Designer without changing how you already design
electronics. Altium 365 requires no additional licenses
and comes included with your subscription plan.

Get real-time component insights as you design with


Octopart built into Altium 365. Octopart is the fastest
search engine for electronic parts and gives you the most
up-to-date part data like specs, datasheets, cad models, and
how much the part costs at different amounts etc. Right in
the design environment so you can focus on your designs.
Start with Altium Designer and Activate Altium 365. Search

4 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

for electronic parts on Octopart.

I have connected everything as per the circuit diagram,


which I will explain in a minute. I have already calibrated
the water pressure sensor. You guys don’t need to worry
about it. I will explain in detail how you can calibrate this
sensor. First, I am going to explain the working and then I
will start practical demonstration.

On the Oled display module, I will print the Water Pressure


in Kpa “Kilo Pascal”. And the LEDs will show water level. If
the first LED is ON it means 20%, similarly the 2nd LED

5 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

means 40%, 60%, 80%, and the 5th LED represents 100%
water level. So, when all the LEDs are ON, it means that the
water tank is full. And when all the LEDs are OFF, it means
that the water tank is empty. Now let us move ahead and
start our practical demonstration.

I have powered up the Arduino. Right now All the LEDs are
OFF as the water drum is completely empty. And on the
Oled display module you can see value is around 0 Kpa.

6 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

I am going to add water and you will see an increase in the


pressure value and the LEDs will turn ON one by one as the
water level increases.

When the Water Drum completely filled, all the LEDs turn
ON. For the practical demonstration watch video tutorial
given at the end of this article. I am sure by now, you might
have got an idea of how does this system work. So, without
any further delay let’s get started!!!

Amazon Links:

7 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Water Pressure Sensor from DFRobot

Arduino Nano

SSD1306 Oled Display Module

Water Storage Drum

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a


commission if you buy the components through these links.
I would appreciate your support in this way!

Water Pressure Sensor:

8 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

This is the Water pressure sensor from DFRobot. The most


important specs are already printed on the sensor itself. It
adopts DFRobot Gravity 3-pin interface. The Yellow wire is
the analog signal output wire, Red wire is the VCC, and the
Black wire is the ground.

Label Name Description

Yellow Signal(Output:0.5~4.5V) Analog Signal

Red VCC(5VDC) +

Black GND –

Water Pressure Sensor Specifications:


As I said earlier, you can use this sensor for measuring the
Liquid or Gas pressure without corrosion. It supports
standard 5V voltage input and 0.5 to 4.5V linear voltage
output. The recommended pressure measurement range is
0 to 1Mpa but you can use it to measure pressure up to
1.5Mpa. As per the manufacturer, the normal operating
pressure should be less than or equal to 2.0 Mpa. Pressure
Greater than or equal to 3 Mpa will damage the sensor. The
measure accuracy is 0.5% at around 55 degrees Celsius. The

9 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

waterproofing level is IP68. The Operating temperature is


from -20 to 85 degrees Celsius. The Sensor response time is
less than 2ms.

• Medium: liquid/gas without corrosion


• Wiring: Gravity-3Pin (Signal-VCC-GND)
• Pressure Measurement Range: 0~1 Mpa
• Input Voltage: +5 VDC
• Output Voltage: 0.5~4.5 V
• Threadably: G1/4
• Adapter: G1/2 to G1/4
• Waterproof Level: IP68
• Operating Temperature: -20~85°C
• Response Time: <2.0 ms
• Quiescent Current: 2.8 mA
• Normal Operating Pressure: ≤2.0 Mpa
• Damaged Pressure: ≥3.0 Mpa
• Service Life: ≥10’000’000 times (10 million)

Features
• Support water pressure detection of living
environmental water systems, such as houses, gardens
and farms.
• Support water pressure detection of outdoor
environment, such as rivers, lakes and sea.
• Support water pressure detection of tanks.
• Support liquid level detection in special situation.

Now, let’s take a look at the circuit diagram.

10 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Pressure Sensor Interfacing with


Arduino:

On the Left side is the regulated 5 volts power supply based


on the 7805 linear voltage regulator. I am using this
regulated 5 volts power supply to power up the Arduino and

11 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

all the other electronics.

The VDD and GND pins of the SSD1306 Oled display


module are connected with the Arduino 3.3V and GND
pins. While the SCK or SCL and SDA pins of the Oled
display module are connected with the Arduino A5 and A4
pins.

5 LEDs are connected with the digital pins D2, D3, D4, D5,
and D6. As these are 2.5V LEDs that’s why I am using 330-
ohm current limiting resistors.

The Signal wire which is the Yellow wire on the Water


pressure sensor is connected with the A0 pin, the Red wire
is connected with 5 volts, and the GND wire is connected
with the Arduino ground.

Water Pressure Sensor


Calibration:
This water pressure sensor is not Factory calibrated. So,
first you will have to calibrate this sensor. Before you start
the calibration process, first of all, make sure there is no
water or any other liquid inside the Drum or Barrel or
Water tank etc.

Next, all you need to do is to download the code given


below and upload it to your Arduino. This is the code for
the calibration.

Download the following Libraries:


Download: Adafruit_GFX.h

Download: Adafruit_SSD1306.h

12 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Water Pressure Sensor Calibration Code:


1 /************************************************************
2 Water Sensor Key Parameter
3 - Parts No.:KY-3-5
4 - Sensing range: 0 - 1 MPa
5 - Input Voltage: 5VDC
6 - Output Voltage: 0.5 - 4.5 VDC
7 (Linearly corresponding to 0 - 1 MPa)
8 - Accuary: 0.5% - 1% FS
9 **************************************************************/
10
11 /************************************************************
12 Water Sensor Calibration
13
14 The output voltage offset of the sensor is 0.5V (norminal).
15 However, due to the zero-drifting of the internal circuit, the
16 no-load output voltage is not exactly 0.5V. Calibration needs to
17 be carried out as follow.
18
19 Calibration: connect the 3 pin wire to the Arduio UNO (VCC, GND and Sig
20 without connecting the sensor to the water pipe and run the program
21 for once. Mark down the LOWEST voltage value through the serial
22 monitor and revise the "OffSet" value to complete the calibration.
23
24 After the calibration the sensor is ready for measuring!
25 **************************************************************/
26 #include <Wire.h>
27 #include <Adafruit_GFX.h>
28 #include <Adafruit_SSD1306.h>
29 #define SCREEN_WIDTH 128 // OLED display width, in pixels
30 #define SCREEN_HEIGHT 64 // OLED display height, in pixels
31 #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset
32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &
33 const float OffSet = 0.254 ; // adjust this value
34
35 float avgV = 0.0;
36
37 float V=0;
38 float P;
39
40 void setup()
41 {
42 [Link](9600); // open serial port, set the baud rate to 96
43 [Link]("/** Water pressure sensor demo **/");
44 [Link]("/** Water pressure sensor demo **/");
45 [Link](SSD1306_SWITCHCAPVCC, 0x3C);
46 delay(2000);
47 [Link]();
48 [Link](WHITE);
49 }
50 void loop()

13 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

51 {
52 //Connect sensor to Analog 0
53
54 V = analogRead(0) * 5.00 / 1024; //Sensor output voltage
55
56
57 P = (V - OffSet) * 250; //Calculate water pressure
58
59 [Link]("Voltage:");
60 [Link](V, 3);
61 [Link]("V");
62
63 [Link](" Pressure:");
64 [Link](P, 1);
65 [Link](" KPa");
66 [Link]();
67 [Link]();
68 [Link](25,0);
69 [Link](1);
70 [Link](WHITE);
71 [Link](" Caliberation");
72 [Link](10,20);
73 [Link](2);
74 [Link]("P:"+S String(P));
75 [Link]("KPa");
76
77 [Link](10,45);
78 [Link](2);
79 [Link]("V: ");
80 [Link](V);
81 [Link]();
82 delay(1000);
83
84 }

On the Oled display, you can see the pressure in Kpa and
the voltage.

14 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

As per the table when the voltage is 0.5V the pressure


should be 0.0Kpa. But as you can see on the display, the
pressure value is wrong, which means we will have to adjust
the Offset value in the Arduino code. Keep on changing the
offset value until you get a value that is around 0.0 Kpa.
Don’t worry if you see very small fluctuations, you can see
the voltage is not perfectly 0.5 volts and also this sensor has
0.5% accuracy.

In my case, I am happy with this offset value of 0.545. So I


will use this value in my final code.

Now, I am going to fill the Drum with water so that I can


find the maximum value of Water pressure, as I will need
this for the programming to define the range. So, when I
filled the drum the Kpa value was around 112.

15 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Water Pressure Sensor Arduino


Programming:
1 /************************************************************
2 Water Sensor Key Parameter
3 - Parts No.:KY-3-5
4 - Sensing range: 0 - 1 MPa
5 - InPut Voltage: 5VDC
6 - OutPut Voltage: 0.5 - 4.5 VDC
7 (Linearly corresPonding to 0 - 1 MPa)
8 - Accuary: 0.5% - 1% FS
9 **************************************************************/
10
11 /************************************************************
12 Water Sensor Calibration
13
14 The outPut voltage offset of the sensor is 0.5V (norminal).
15 However, due to the zero-drifting of the internal circuit, the
16 no-load outPut voltage is not exactly 0.5V. Calibration needs to
17 be carried out as follow.
18
19 Calibration: connect the 3 Pin wire to the Arduio UNO (VCC, GND and Si
20 without connecting the sensor to the water PiPe and run the Program
21 for once. Mark down the LOWEST voltage value through the serial
22 monitor and revise the "OffSet" value to complete the calibration.
23
24 After the calibration the sensor is ready for measuring!
25 **************************************************************/
26 #include <Wire.h>
27 #include <Adafruit_GFX.h>
28 #include <Adafruit_SSD1306.h>
29 #define SCREEN_WIDTH 128 // OLED display width, in pixels
30 #define SCREEN_HEIGHT 64 // OLED display height, in pixels
31 #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino rese
32 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
33 const float OffSet = 0.454 ;
34 int psensor=A0;
35 int led1 = 2;
36 int led2 = 3;
37 int led3 = 4;
38 int led4 = 5;
39 int led5 = 6;
40 float V, P;
41
42 void setup()
43 {
44 [Link](9600); // open serial port, set the baud rate to 9
45 pinMode(psensor,INPUT);
46 pinMode(led1, OUTPUT);
47

16 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

48 pinMode(led2, OUTPUT);
49 pinMode(led3, OUTPUT);
50 pinMode(led4, OUTPUT);
51 pinMode(led5, OUTPUT);
52
53 digitalWrite(led1, LOW);
54 digitalWrite(led2, LOW);
55 digitalWrite(led3, LOW);
56 digitalWrite(led4, LOW);
57 digitalWrite(led5, LOW);
58 [Link]("/** Water pressure sensor demo **/")
59 [Link](SSD1306_SWITCHCAPVCC, 0x3C);
60 delay(2000);
61 [Link]();
62 [Link](WHITE);
63 }
64 void loop()
65 {
66 //Connect sensor to Analog 0
67 V = analogRead(psensor) * 5.00 / 1024; //Sensor output voltage
68 P = (V - OffSet) * 250; //Calculate water pressure
69
70 [Link]("Voltage:");
71 [Link](V, 3);
72 [Link]("V");
73
74 [Link](" Pressure:");
75 [Link](P, 1);
76 [Link](" KPa");
77 [Link]();
78 [Link]();
79 [Link](10,0);
80 [Link](2);
81 [Link](WHITE);
82 [Link]("Value:");
83 [Link](10,30);
84 [Link](2);
85 [Link](P);
86 [Link]("KPa");
87 [Link]();
88
89 // total pressure when the water drum is completely filled = 112kpa
90 // but i am going to consider it as 100Kpa
91
92 if( (P > 0) && (P<=10) )
93 {
94 digitalWrite(led1, LOW);
95 digitalWrite(led2, LOW);
96 digitalWrite(led3, LOW);
97 digitalWrite(led4, LOW);
98 digitalWrite(led5, LOW);
99 } else
100 if( (P > 10) && ( P <= 20) )
101 {
102
103 digitalWrite(led1, HIGH);
104 digitalWrite(led2, LOW);
105 digitalWrite(led3, LOW);
106 digitalWrite(led4, LOW);
107 digitalWrite(led5, LOW);
108
109 } else
110
111 if( (P > 20) && (P <= 40) )
112 {
113
114 digitalWrite(led1, HIGH);
115 digitalWrite(led2, HIGH );
116 digitalWrite(led3, LOW);
117 digitalWrite(led4, LOW);
118 digitalWrite(led5, LOW);
119 } else
120

17 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

121 if( (P> 40) && (P <= 60) )


122 {
123
124 digitalWrite(led1, HIGH);
125 digitalWrite(led2, HIGH );
126 digitalWrite(led3, HIGH);
127 digitalWrite(led4, LOW);
128 digitalWrite(led5, LOW);
129 } else
130
131 if( (P > 60) && (P <= 80) )
132 {
133 digitalWrite(led1, HIGH);
134 digitalWrite(led2, HIGH );
135 digitalWrite(led3, HIGH);
136 digitalWrite(led4, HIGH);
137 digitalWrite(led5, LOW);
138 } else
139
140 if( P >= 95 )
141 {
142
143 digitalWrite(led1, HIGH);
144 digitalWrite(led2, HIGH);
145 digitalWrite(led3,HIGH);
146 digitalWrite(led4, HIGH);
147 digitalWrite(led5, HIGH);
148 }
149
150 delay(100);
}

If you are planning on using the SSD1306 Oled display


module then you will need Adafruit_GFX and
Adafruit_SS1306 libraries. The download links I have
already shared above.

Here is the offset value which I found using the hit and trail
technique.

The water pressure sensor is connected with the Analog pin


A0.

5 LEDs are connected with Arduino pins 2, 3, 4, 5, and 6.

I also defined two variables for storing the Voltage and


Pressure values.

Rest of the code is self-explanatory, we are reading the


voltage on the Analog pin A0.

Next, we find the pressure and then display the


corresponding values on the Oled display module.

18 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Next, as per the minimum and maximum pressure values I


am controlling all the 5 LEDs. So, that’s all about the
programming.

Consider subscribing my YouTube channel, if you want


to see Long Range wireless and IoT versions of the
same project.

Watch Video Tutorial:

 Tags analog water pressure sensor Arduino water pressure sensor

dfrobot water pressure sensor electronic clinic water level pressure sensor

19 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

water pressure measurement unit water pressure monitor

water pressure monitoring system water pressure sensor water pressure sensor Arduino

water pressure transducer water pressure transmitter

3 Comments

20 of 21 7/6/2023, 3:08 PM
Arduino Water Pressure Sensor Project, Water Level Pressure Sensor [Link]

Brendan O'Kane
February 3, 2023 at 4:20 pm

hi what hight in water was yor tank in yor example 112kpa


would equal 1142 cms of water this doesnt seem right
1mpa of pressure wouuld equal 10197.2cms of water

Reply

Instrument Calibration nz
May 30, 2023 at 5:28 pm

This water pressure sensor Arduino project looks


interesting. DIY fans will appreciate the clear directions and
available code that make recreating the project a breeze.
Sensing water pressure and levels has a number of useful
real-world applications. We appreciate you providing us
with this in-depth, practical guide.

Reply

Flowmeters NZ
June 1, 2023 at 5:03 pm

This Arduino water pressure sensor project is a great


solution for monitoring water levels and controlling water
pumps efficiently. The tutorial provides clear instructions
on using the sensor for water detection, measuring water
pressure, and monitoring water levels in a tank. The
addition of an OLED display module and LEDs allows for a
smart water control system. This project is not only
practical but also helps conserve water and reduce
electricity bills.

Reply

21 of 21 7/6/2023, 3:08 PM

You might also like