New Water Lavel

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

Ultrasonic Wireless Water Level Indicator – Solar Powered

An ultrasonic water level controller is a device which can detect water levels in a tank
without a physical contact and send the data to a distant LED indicator in a wireless
GSM mode.

In this post we are going to construct a ultrasonic based solar powered wireless water
level indicator using Arduino in which the Arduinos would be transmitting and
receiving at 2.4 GHz wireless frequency. We will be detecting the water level in the
tank using ultrasonics instead of traditional electrode method.
Overview
There are many practical considerations before we design one.
• Nobody wants to drill a hole on water tank’s body for electrodes which might leak
water later on.
• Nobody wants to run 230 / 120 VAC wire near water tank.
• Nobody wants to replace batteries every month.
• Nobody wants to run additional long wires hanging on a room for water level
indication as it is not pre-planned while building the house.
• Nobody wants to use the water which is mixed with metal corrosion of the electrode.
• Nobody wants to remove the water level indicator setup while cleaning the tank
(inside).
Some of the reasons mentioned above may look silly but, you will find less satisfactory
with commercially available products with these cons. That’s why penetration of these
products are very less among the average households.
After considering these key points, we have designed a practical water level indicator
which should remove the cons mentioned.
Our design:
• It uses ultrasonic sensor to measure the water level so no corrosion problem.
• Wireless indication of water level real time at 2.4 GHz.
• Good wireless signal strength, enough for 2 story high buildings.
• Solar powered no more AC mains or replacing battery.
• Tank full / overflow alarm while filling the tank.
Let’s investigate the circuit details:
Transmitter:
The wireless transmitter circuit which is placed on the tank will send water level data
every 5 seconds 24/7. The transmitter consists of Arduino nano, ultrasonic sensor HC-
SR04, nRF24L01 module which will connect the transmitter and receiver wirelessly at
2.4 GHz.
A Solar panel of 9 V to 12 V with current output of 300mA will power the transmitter
circuit. A battery management circuit board will charge the Li-ion battery, so that we
can monitor the water level even when there is no sunlight.
Let us explore how to place the ultrasonic sensor at water tank:
Please note that you have to use your creativity to mound the circuit and protect from
rain and direct sunlight.
Cut a small hole above the tank’s lid for placing the Ultrasonic sensor and seal it with
some kind of adhesive you can find.

Now measure the full height of the tank from bottom to lid, write it down in meters.
Now measure the height of water holding capacity of tank as shown in the above image
and write in down in meters.
You need to enter these two values in the code.
Schematic diagram of Transmitter:

NOTE: nRF24L01 uses 3.3V as Vcc do not connect to 5V output of Arduino.


Power supply for transmitter:

Make sure that your solar panel’s output power i.e. output (volt x current) is greater
than 3 watts. The solar panel should be 9V to 12V.
12V and 300mA panel is recommended which you can find easily on market. Battery
should be around 3.7V 1000 mAh.
5V 18650 Li-ion charging module:
The following image shows a standard 18650 charger circuit
The input can be USB (not used) or external 5V from LM7805 IC. Make sure that you
get the correct module as shown above, it should have TP4056 protection, which has
low battery cut-off and short circuit protection.
The output of this should to be fed to XL6009’s input which will boost to higher
voltage, using a small screw driver output of XL6009 should be adjusted to 9V for
Arduino.
Illustration of XL6009 DC to DC boost converter:

That concludes the transmitter’s hardware.


Code for Transmitter:
// ----------- Program Developed by R.GIRISH / Homemade-
circuits .com ----------- //
#include <RF24.h>
#include<SPI.h>
RF24 radio(9, 10);
const byte address[6] = "00001";
const int trigger = 3;
const int echo = 2;
const char text_0[] = "STOP";
const char text_1[] = "FULL";
const char text_2[] = "3/4";
const char text_3[] = "HALF";
const char text_4[] = "LOW";
float full = 0;
float three_fourth = 0;
float half = 0;
float quarter = 0;
long Time;
float distanceCM = 0;
float distanceM = 0;
float resultCM = 0;
float resultM = 0;
float actual_distance = 0;
float compensation_distance = 0;
// ------- CHANGE THIS -------//
float water_hold_capacity = 1.0; // Enter in Meters.
float full_height = 1.3; // Enter in Meters.
// ---------- -------------- //
void setup()
{
Serial.begin(9600);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
digitalWrite(trigger, LOW);
radio.begin();
radio.openWritingPipe(address);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
full = water_hold_capacity;
three_fourth = water_hold_capacity * 0.75;
half = water_hold_capacity * 0.50;
quarter = water_hold_capacity * 0.25;
}
void loop()
{
delay(5000);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
digitalWrite(trigger, LOW);
Time = pulseIn(echo, HIGH);
distanceCM = Time * 0.034;
resultCM = distanceCM / 2;
resultM = resultCM / 100;
Serial.print("Normal Distance: ");
Serial.print(resultM);
Serial.println(" M");
compensation_distance = full_height - water_hold_capacity;
actual_distance = resultM - compensation_distance;
actual_distance = water_hold_capacity - actual_distance;
if (actual_distance < 0)
{
Serial.print("Water Level:");
Serial.println(" 0.00 M (UP)");
}
else
{
Serial.print("Water Level: ");
Serial.print(actual_distance);
Serial.println(" M (UP)");
}
Serial.println("============================");
if (actual_distance >= full)
{
radio.write(&text_0, sizeof(text_0));
}
if (actual_distance > three_fourth && actual_distance <= full)
{
radio.write(&text_1, sizeof(text_1));
}
if (actual_distance > half && actual_distance <= three_fourth)
{
radio.write(&text_2, sizeof(text_2));
}
if (actual_distance > quarter && actual_distance <= half)
{
radio.write(&text_3, sizeof(text_3));
}
if (actual_distance <= quarter)
{
radio.write(&text_4, sizeof(text_4));
}
}
// ----------- Program Developed by R.GIRISH / Homemade-
circuits .com ----------- //

Change the following values in the code which you measured:


// ------- CHANGE THIS -------//
float water_hold_capacity = 1.0; // Enter in Meters.
float full_height = 1.3; // Enter in Meters.
// ---------- -------------- //
That concludes the transmitter.
The Receiver:

The receiver can show 5 levels. Alarm, when the tank reached absolute maximum water
holding capacity while filling tank. 100 to 75 % - All four LEDs will glow, 75 to 50 %
three LEDs will glow, 50 to 25 % two LEDs will glow, 25% and less one LED will
glow.
The receiver can be powered from 9V battery or from smartphone charger to
USB mini-B cable.
Code for Receiver:
// ----------- Program Developed by R.GIRISH / Homemade-
circuits .com ----------- //
#include <RF24.h>
#include<SPI.h>
RF24 radio(9, 10);
int i = 0;
const byte address[6] = "00001";
const int buzzer = 6;
const int LED_full = 5;
const int LED_three_fourth = 4;
const int LED_half = 3;
const int LED_quarter = 2;
char text[32] = "";
void setup()
{
pinMode(buzzer, OUTPUT);
pinMode(LED_full, OUTPUT);
pinMode(LED_three_fourth, OUTPUT);
pinMode(LED_half, OUTPUT);
pinMode(LED_quarter, OUTPUT);
digitalWrite(buzzer, HIGH);
delay(300);
digitalWrite(buzzer, LOW);
digitalWrite(LED_full, HIGH);
delay(300);
digitalWrite(LED_three_fourth, HIGH);
delay(300);
digitalWrite(LED_half, HIGH);
delay(300);
digitalWrite(LED_quarter, HIGH);
delay(300);
digitalWrite(LED_full, LOW);
delay(300);
digitalWrite(LED_three_fourth, LOW);
delay(300);
digitalWrite(LED_half, LOW);
delay(300);
digitalWrite(LED_quarter, LOW);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setChannel(100);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
}
void loop()
{
if (radio.available())
{
radio.read(&text, sizeof(text));
Serial.println(text);
if (text[0] == 'S' && text[1] == 'T' && text[2] == 'O' &&
text[3] == 'P')
{
digitalWrite(LED_full, HIGH);
digitalWrite(LED_three_fourth, HIGH);
digitalWrite(LED_half, HIGH);
digitalWrite(LED_quarter, HIGH);
for (i = 0; i < 50; i++)
{
digitalWrite(buzzer, HIGH);
delay(50);
digitalWrite(buzzer, LOW);
delay(50);
}
}
if (text[0] == 'F' && text[1] == 'U' && text[2] == 'L' &&
text[3] == 'L')
{
digitalWrite(LED_full, HIGH);
digitalWrite(LED_three_fourth, HIGH);
digitalWrite(LED_half, HIGH);
digitalWrite(LED_quarter, HIGH);
}
if (text[0] == '3' && text[1] == '/' && text[2] == '4')
{
digitalWrite(LED_full, LOW);
digitalWrite(LED_three_fourth, HIGH);
digitalWrite(LED_half, HIGH);
digitalWrite(LED_quarter, HIGH);
}
if (text[0] == 'H' && text [1] == 'A' && text[2] == 'L' &&
text[3] == 'F')
{
digitalWrite(LED_full, LOW);
digitalWrite(LED_three_fourth, LOW);
digitalWrite(LED_half, HIGH);
digitalWrite(LED_quarter, HIGH);
}
if (text[0] == 'L' && text[1] == 'O' && text[2] == 'W')
{
digitalWrite(LED_full, LOW);
digitalWrite(LED_three_fourth, LOW);
digitalWrite(LED_half, LOW);
digitalWrite(LED_quarter, HIGH);
}
}
}
// ----------- Program Developed by R.GIRISH / Homemade-
circuits .com ----------- //
That concludes the receiver.
NOTE: if no LEDs are glowing, which means the receiver can’t get signal from transmitter.
You should wait 5 seconds to receive the signal from transmitter after turning on the receiver
circuit.
Author’s prototypes:
Transmitter:

Receiver:
What is a 5V Relay Module : Working & Its Applications
Relay is one kind of electro-mechanical component that functions as a switch. The relay coil is
energized by DC so that contact switches can be opened or closed. A single channel 5V relay
module generally includes a coil, and two contacts like normally open (NO) and normally closed
(NC). This article discusses an overview of the 5V relay module & its working but before going to
discuss what is relay module is, first we have to know what is relay and its pin configuration.
What is a 5V Relay?
A 5v relay is an automatic switch that is commonly used in an automatic control circuit and to
control a high-current using a low-current signal. The input voltage of the relay signal ranges from 0
to 5V.
5V Relay Pin Configuration
The pin configuration of the 5V relay is shown below. This relay includes 5-pins where each pin
and its functionality are shown below.

Pin1 (End 1): It is used to activate the relay; usually this pin one end is connected to 5Volts
whereas another end is connected to the ground.

Pin2 (End 2): This pin is used to activate the Relay.

Pin3 (Common (COM)): This pin is connected to the main terminal of the Load to make it active.

Pin4 (Normally Closed (NC)): This second terminal of the load is connected to either NC/ NO
pins. If this pin is connected to the load then it will be ON before the switch.

Pin5 (Normally Open (NO)): If the second terminal of the load is allied to the NO pin, then the
load will be turned off before the switch.

Features

The features of the 5V relay include the following.


 Normal Voltage is 5V DC
 Normal Current is 70mA
 AC load current Max is 10A at 250VAC or 125V AC
 DC load current Max is 10A at 30V DC or 28V DC
 It includes 5-pins & designed with plastic material
 Operating time is 10msec
 Release time is 5msec
 Maximum switching is 300 operating per minute
5V Relay Module
The relay module with a single channel board is used to manage high voltage, current loads
like solenoid valves, motor, AC load & lamps. This module is mainly designed to interface through
different microcontrollers like PIC, Arduino, etc.
5V Relay Module Pin Configuration
The pin configuration of the 5V relay module is shown below. This module includes 6-pins where
each pin and its functionality are discussed below.

Normally Open (NO): This pin is normally open unless we provide a signal to the relay modules
signal pin. So, the common contact pin smashes its link through the NC pin to make a connection
through the NO pin.
Common Contact: This pin is used to connect through the load that we desire to switch by using
the module.
Normally Closed (NC): This NC pin is connected through the COM pin to form a closed circuit.
However, this NC connection will break once the relay is switched through providing an active
high/low signal toward the signal pin from a microcontroller.
Signal Pin: The signal pin is mainly used for controlling the relay. This pin works in two cases like
active low otherwise active high. So, in active low case, the relay activates once we provide an
active low signal toward the signal pin, whereas, in an active high case, the relay will trigger once
we provide a high signal toward the signal pin.
However, these modules generally work on an active high signal which will strengthen the relay coil
to make contact with the common terminal with the normally open terminal.
5V VCC: This pin needs 5V DC to work. So 5V DC power supply is provided to this pin.
Ground: This pin connects the GND terminal of the power supply.
5Volts 1-Channel Relay Module Components
The components in a 5v relay module with a single channel include a relay, output terminal, status
LED, power LED, freewheeling diode, input connector & switching transistor.
Relay
A 5V relay is coated with blue color plastic material. For both AC & DC loads, the utmost operating
voltage & current are also displayed on the relay. This relay operates with 5V, so it is called a 5V
relay.
Output Terminal
The output terminal of the relay module is located at the left-hand side, used to fix an AC/DC load
& AC/DC i/p power source. Every o/p connector’s terminal is connected through NC, COM pins &
NO of the relay.
The relay module consists of screws that are used to connect wires & cables. The max current
supported by this module is 10A & the max contact voltage is 250V AC & 30V DC. Thick main
cables are mainly used whenever high voltage & current load is used.
Status LED
Status LED is connected by using a current limiting resistor that is located on the top right side of
the relay module. So this LED illustrates the relay status by activating the relay & coil through a
signal pin. The DC supplies throughout a relay coil.
Power LED
Power LED shows the condition of the power source that is connected through the single channel
module. If we provide the above 5V source toward both the pins of the module like Vcc & GND,
the LED will be damaged due to high voltage.
Freewheeling Diode
The connection of this diode can be done across the coil to keep away from the back EMF effect,
so-called a flyback diode. The type of coil used in the relay is the inductive type. Once the current
supplies throughout an inductive load, then it generates a back EMF voltage, which may harm the
circuit. So, this diode is mainly used to keep away from this effect.
Input Connector
The input connector is located on the right side of the module. This connector is mainly used to
supply a 5V power supply & input signal. In addition, it also supplies power supply toward the
power LED, relay coil & status LED.
Switching Transistor
Generally, the input signal which is given to a relay is from the I/O pins of microcontrollers like
ESP32, TM4C123, Arduino, etc. However, the highest current sourcing capacity of GPIO pins is
usually below 20mA.
Therefore, a switching transistor is used in this module is to strengthen the current to the
requirement of the minimum current level of the relay coil. A switching transistor is used to control
the 5V relay from the microcontroller’s GPIO pin.
Some kinds of relay modules are available with an optoisolator like a switching device to give
optical isolation among high & low voltage circuits.
However, if you are utilizing a separate relay exclusive of a module & you want to utilize several
relays within your projects, then a relay driver IC can be used to drive several arrays from the pins
of GPIO in a microcontroller.
Specifications
The specifications of a 1- channel relay module include the following.
 Voltage supply ranges from 3.75V – 6V
 Quiescent current is 2mA
 Once the relay is active then the current is ~70mA
 The highest contact voltage of a relay is 250VAC/30VDC
 The maximum current is 10A
Working
The relay uses the current supply for opening or closing switch contacts. Usually, this can be done
through a coil to magnetize the switch contacts & drags them jointly once activated. A spring drives
them separately once the coil is not strengthened.
By using this system, there are mainly two benefits, the first one is, the required current for
activating the relay is less as compared to the current used by relay contacts for switching. The other
benefit is, both the contacts & the coil are isolated galvanically, which means there is no electrical
connection among them.
How to Use/Relay Module Circuit Diagram
The circuit diagram of the single-channel relay module circuit is shown below. In this circuit, we
can observe that how the relay module is activated and deactivated through a digital signal. This
signal is applied to a control pin of the relay module. The following circuit diagram is the internal
5V single channel relay module diagram.

Single Channel Relay Module Circuit


In the above circuit diagram, the single-channel relay module includes resistors-2, transistors,
LEDs-2 & a 5V relay. Relay modules are available in two types based on the control signal type
used for activation of the relay.
One relay module comes with an NPN transistor whereas another module comes with a PNP
transistor. If the relay module uses an NPN Transistor, then it will activate the relay by applying an
active high signal to the control pin. Alternatively, if a PNP is used then the relay will be activated
through an active low signal on the control pin.
It’s working in proteus simulation software is, when we provide an active high signal toward the
control pin in a relay module, then the coil in the relay activates to make the relay active through the
connection of the NO pin through the COM pin.
Likewise, once we provide an active low no signal toward the relay’s control pin, then the coil
deactivates using a freewheeling diode so that the relay will be deactivated.
In the same way, for PNP based relay module, the relay is activated through an active low signal,
whereas an active high signal will deactivate the relay.
The controlling of a 5v single channel relay module can be done by interfacing any kind of
microcontroller. For that, we use a GPIO pin like a digital o/p pin which gives an active high & low
signal toward the control pin. Once the relay activates, we can listen to an audible sound that comes
from the module.
Advantages
The advantages of the relay module include the following.
 A remote device can be controlled easily
 It is triggered with less current but it can also trigger high power machines
 Easily contacts can be changed
 At a time, several contacts can be controlled using a single signal
 Activating part can be isolated
 It can switch AC or DC
 At high temperatures, it works very well
Disadvantages
The disadvantages of the relay module include the following.
 When contacts of relay modules are used overtime then they may damage
 Noise can be generated through the opening & closing of the contacts.
 Time taken for switching is High
Applications
Relay modules are used in different applications which include the following.
 Used in over voltage/under voltage protection system
 Mains Switching
 Speed control of motors through start-delta converters
 Automatic electrical appliances
 Electrical isolation in between high & low power sources
 Lights
 AC voltage load switching using less voltage DC
 Delivery of Isolated power
 Home automation projects
 Switching with High Current
Thus, this is all about an overview of a 5v single channel relay module that uses a 5v relay like an
essential component
From home automation to industrial control, the 5V relay module is one of the most popular
modules for switching power systems. So we decided to write an article about it, explaining how it
works and some of its popular applications.
What is a 5V Relay Module?
Before we can understand how a 5V relay module works, we need to know what it is. The 5 volt
relay module is a type of relay module that requires a 5V DC input to operate. But that’s not all
there’s to it. Here’s more, including the specifications
5V Relay Module Description
A 5V relay module is a single or multi-channel relay module that works with a low-level trigger
voltage of 5V DC. The input voltage can be from any microcontroller or logic chip that outputs a
digital signal.
Like most other relays, the 5V relay module is an electrically operated, electromagnetic switch that
can be used to turn on or turn off a circuit. It consists of two parts: the relay itself and the control
module.
 The relay contains the coil that creates the magnetic field, the armature that move to
complete or disconnect a circuit, and contacts that open and close to operate the load
switch.
 The relay control module is the interface or part of the relay module that the user interacts
with. It contains the input terminals for connecting to the microcontroller, as well as the
output terminals for connecting to the load.
 The control module also contains LED indicators for power and status and other devices
such as protection diode, transistor, resistor, and other semiconductor devices necessary for
its operation.
5V Relay Module Specifications
The 5V relay module specifications are normally written on the top side. These include the input
voltage/current, load current/voltage, and operating or release times. The specifications vary
depending on the manufacturer. In general, they would look something like this:
 Normal voltage: 5V DC
 Normal current: 70mA
 Maximum load current: 10A/250V AC, 10A/30V DC
 Maximum switch voltage: 250V AC, 30V DC
 Operate time: ≤ 10ms
 Release time: ≤ 5ms

GEYA FY-41F-1 5V relay module technical parameter:

Apply to
Input
Rated Rated Relay the Screw Stripped
Type Temperature Input Voltage voltage
Voltage Current Rated Torque Wire Length
polarity
Voltage

250VAC 6A -40°℃~70℃ AC/DC12V 12VDC / 0.5N.M 7mm

AC/DC24V 24VDC / 0.5N.M 7mm


FY-41F-
1
AC/DC48V 48VDC / 0.5N.M 7mm

110V/230V 60VDC / 0.5N.M 7mm

FY-41F- AC/DC12V 12VDC / 0.5N.M 7mm


2
AC/DC24V 24VDC / 0.5N.M 7mm
110V/230V 60VDC / 0.5N.M 7mm

AC/DC12V 12VDC / / 7mm

FY-41F-
AC/DC24V 24VDC / / 7mm
3

110V/230V 60VDC / / 7mm

5V Relay Module Circuit


The 5V relay modules are made up of connection points or pins, and several major components,
such as diodes, transistors, resistors, and the relay itself. These make up the circuit that controls the
relay. The 5V relay module circuit is further explained below.
5V Relay Module Pinout
The 5V relay module pinout is composed of connections on the input side where it receives the
trigger signal, and the output side where it controls the load.
The input side, as shown in the above relay module circuit diagram, has 3 or 4 connections: These
are listed and explained below.
 VCC – this is the power connection. It supplies 5V DC to the module and is normally
connected to the positive terminal of the power supply.
 GND – this is the ground connection. It connects to the negative terminal of the power
supply.
 IN1, IN2 – these are the inputs where the trigger signal is applied. IN1 is for a single-
channel relay module, while IN2 is for a dual-channel relay module. The IN (Input) pin is
connected to the output of the microcontroller, sensor, or logic device.
The relay module output side has three connections:
 NO (Normally Open) – this is the load connection when the relay is ON. When the relay
is off, the NO maintains an open connection with the COM.
 COM (Common) – The relay module connection labeled “COM” is the common
connection for both the NO and NC (Normally Closed) pins.
 NC (Normally Closed) – this is the load connection. It connects to the COM terminal by
default, or when the relay is OFF.
5V Relay Module Parts
Now, let’s take a look at the main components of a 5V relay module. They include
 The LED – this is an indicator or status LED that lights up when the relay is ON.
 The transistor – the transistor amplifies the trigger signal so that it can activate the relay.
 The diode – a flyback diode is used to protect the 5V relay module circuit from flyback
voltage spikes when the relay coil de-energizes.
 The resistor – the resistor limits the current flowing through the relay module circuit.
 The relay – this is the main switching component of the module and usually either an NC
(Normally Closed) or NO (Normally Open) type.
5V Relay Module Working
The 5V relay module requires a 5V signal delivered from a microcontroller or sensor to trigger the
switch. Its working is also very simple. When the input pin is HIGH, the relay turns on, and when
the input is LOW it turns off. Below is the 5V relay module working principle.
 The relay is activated by a low-level trigger signal applied to its IN1 or IN2 pin. When the
trigger signal is applied, the transistor turns ON and amplifies the signal.
 This triggers the relay to turn ON and connect the load to either the NO or NC pin. The
LED will light up to indicate that the relay is ON.
 When the trigger signal is removed, the transistor turns OFF and the relay turns OFF. The
load is then disconnected from the NO or NC pin. The LED will turn OFF to indicate that
the relay is OFF.
The 5V relay module can be used to control a load such as a lighting system, motor, or solenoid. It
can also be used to switch AC or DC voltages. The maximum voltage and current that the 5V relay
module can control is dependent on the specifications of the relay.
5V Relay Module for Arduino
The 5V relay module can be easily interfaced with an Arduino. The above diagram shows how to
connect a single-channel relay module with Arduino microcontrollers, a popular project among
hobbyists. The 5V relay module Arduino wiring is very simple:
You only need to connect the VCC and GND pins of the relay module to the 5V and GND pins of
the Arduino, connect the IN1 pin of the relay module to a digital output pin of the Arduino, and
connect the load to the NO and COM pins of the relay module.
 When the digital output pin is set to HIGH, the module turns ON and activates the relay.
This will turn ON the load connected to the NO and COM pins of the relay module.
 When the digital output pin is set to LOW, the circuit OFF and deactivates the relay,
turning OFF the load.
The 5V relay module can also be easily interfaced with a Raspberry Pi. When used with a Raspberry
Pi, 5V relay module can be used to control a load such as an LED system, motor, or solenoid.

You might also like