members
Basics: Project 071c Water flow sensor YF-S201, 5V relay module, 12V solenoid valve, LCD1602 I2C mod
of Acoptex.com in UNO
Basics: Project 071c
Project name: Water flow sensor YF-S201, 5V relay module, 12V solenoid valve, LCD1602 I2C module
Tags: Arduino Uno, RPi 20, YF-S201, Hall Effect Water Flow Meter, Hall Effect Water Flow Sensor, Water flow sensor, 1-30L/min Water Flow Hall Counter, Sensor Water control, Water Flow Rate Switch, Flow Meter, Flowmeter Counter, 5V relay module, solenoid valve, Plastic Water Solenoid Valve, electromagnetic valve, 12V solenoid valve, Gravity Feed Electric Solenoid Valve DDB-CD-12VDC, LCD1602 I2C module
WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION.
In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):
1.Arduino Uno R3 (you can also use the other version of Arduino)
2. Water flow sensor YF-S201 1pc
3.Arduino IDE ( you can download it from here )
4.Jumper cables M-M, F-M
5.Breadboard 1 pc
6. 5V relay module 1pc
7. Electromagnetic valve (solenoid valve) 12V 1pc
8. 12V external power supply for solenoid valve 1 pcs
or
9. Diode 1N4007 or 1N4001 1 pc
10. LCD1602 I2C module 1 pc
General
We will learn how to connect Water flow sensor YF-S201, 5 V relay module with 12V solenoid valve and LCD1602 I2C module to Arduino board and use them.
Understanding the LCD1602 I2C module
You can read more about it here.
Understanding the electromagnetic valve (solenoid valve)
Solenoids
Electric solenoids work on similar electromagnetic principles to those of DC motors, however, solenoids can use the magnetic energy to push or pull something rather than turn it. Solenoids are found in paintball guns, pinball machines, printers, valves and even automobiles.
A Solenoid is a coil that when energised, produces a controlled magnetic field down through its centre. By placing a magnetic armature inside that field, the armature can move in or out of the coil. Team this with our Arduino and we open up a number of interesting applications.
The solenoid's strength (the force it can push or pull) is directly proportional to windings of the coil and the current applied. This means that more coils equal greater magnetic fields and greater force. A small design specification for this type of coil is that it must be longer than it is wide, ensuring the magnetic field runs through the centre and allows the in/out movement discussed above.
Common characteristics of solenoid:
- Throw – This refers to the length of the armature that will be moving in and out of the solenoid.
- Mounting options – Most solenoids have mounting holes in the case so that your armature can actually push and/or pull its load. Otherwise, the solenoid would likely push itself around instead of the load!
- Duty cycle – This is expressed as a percentage of time the solenoid is switched on for. For example, if a solenoid is energised for 30 seconds before switching off for 30 seconds, its duty cycle is 50%.
- Operating Voltage – Similarly to DC motors, this refers to the ideal voltage needed for the solenoid to run optimally. If you apply a lesser voltage you can expect a slower and weaker throw.
- Starting Force – Measured in Newtons, this is the force the solenoid will have at the beginning of its movement.
- Actuation Time – The time taken from switch-on to completion of the stroke.
Solenoid valves
A solenoid valve is an electromechanical valve which is normally used for the fluid control of water, air, oil or gas.
They are made up of two components:
i) the solenoid (essentially consisting of a coil, core, core tube, shading coil and spring)
ii) the valve (the body containing orifices in which the disc, diaphragm or piston is positioned).
The solenoid is a coil which has a current passed through it when it is energised. The current causes a magnetic field which moves the core up or down. This movement is what essentially opens or closes the solenoid valve body. If the valve is opened, fluid is allowed to pass. If the valve is closed, fluid will be blocked.
Now for some terminology explanations:
- Solenoid Coil – the coil is the electrical part and consists of a spool wound with insulated copper wire. A magnetic field is created when the coil is energised.
- Core – a soft magnetic plugnut which is moved by magnetic forces.
- Core Spring – the spring is used to keep the core in its fixed position.
- Disc, Valve disc – the sealing material on the disc holder which shuts the seat orifice.
- Disc Holder – part of the valve which is actuated by the core.
- Pilot Orifice – this is located in the centre of the diaphragm and is opened or closed by the core.
- Seating or Valve Seat – this is a specially formed boarder of the valve seat.
There are many valve design variations. Ordinary valves can have many ports and fluid paths. A 2-way valve, for example, has 2 ports; if the valve is open, then the two ports are connected and fluid may flow between the ports; if the valve is closed, then ports are isolated. If the valve is open when the solenoid is not energized, then the valve is termed normally open (N.O.). Similarly, if the valve is closed when the solenoid is not energized, then the valve is termed normally closed.[1] There are also 3-way and more complicated designs.[2] A 3-way valve has 3 ports; it connects one port to either of the two other ports (typically a supply port and an exhaust port).
There are many valve design variations. Ordinary valves can have many ports and fluid paths. A 2-way valve, for example, has 2 ports; if the valve is open, then the two ports are connected and fluid may flow between the ports; if the valve is closed, then ports are isolated. If the valve is open when the solenoid is not energized, then the valve is termed normally open. Similarly, if the valve is closed when the solenoid is not energized, then the valve is termed normally closed. There are also 3-way and more complicated designs. A 3-way valve has 3 ports; it connects one port to either of the two other ports (typically a supply port and an exhaust port).
Solenoid valves are also characterized by how they operate. A small solenoid can generate a limited force. If that force is sufficient to open and close the valve, then a direct acting solenoid valve is possible. When high pressures and large orifices are encountered, then high forces are required. To generate those forces, an internally piloted solenoid valve design may be possible. In such a design, the line pressure is used to generate the high valve forces; a small solenoid controls how the line pressure is used. Internally piloted valves are used in dishwashers and irrigation systems where the fluid is water, the pressure might be 80 psi (550 kPa) and the orifice diameter might be 3⁄4 in (19 mm).
In some solenoid valves the solenoid acts directly on the main valve. Others use a small, complete solenoid valve, known as a pilot, to actuate a larger valve. While the second type is actually a solenoid valve combined with a pneumatically actuated valve, they are sold and packaged as a single unit referred to as a solenoid valve. Piloted valves require much less power to control, but they are noticeably slower. Piloted solenoids usually need full power at all times to open and stay open, where a direct acting solenoid may only need full power for a short period of time to open it, and only low power to hold it.
A direct acting solenoid valve typically operates in 5 to 10 milliseconds. The operation time of a piloted valve depends on its size; typical values are 15 to 150 milliseconds.
The solenoid valve would make a great addition to your robotic gardening project or drip irrigation system. There are two 1/2" or 3/4" (Nominal non-taped National Pipe) outlets. Normally, the valve is closed. When 12VDC is applied to the two terminals, the valve opens and water can push through. The valve has a gasket arrangement inside, so there is a minimum pressure requirement of 0.02 Mpa (3 PSI). Also, liquid can only flow one direction.
You need to remember that:
- Water can only flow in one direction through this valve.
- There is a 3 PSI minimum pressure requirement on the inlet otherwise the valve will not shut off.
- This solenoid valve is not rated for food safety or use with anything but water.
This solenoid does not have a wire harness and instead relies on 0.250″ Quick Connects. These are the best way to connect the solenoid. If you do not have Quick Connects laying around, Alligator Clips or even soldering wires to the tabs will work.
The connections on the solenoid do not matter, the coil does not care which side is positive or negative.
Since a solenoid is an inductive load we need to include a snubber diode across the contacts. Snubber diodes help eliminate transient voltages caused when a magnetic coil (such as those found in a motor, relay, or solenoid) suddenly loses power. Without this diode in place the transient voltage spikes can damage other elements of the circuit. The snubber diode is placed from the negative side of the coil to the positive side. Since diodes only allow current to flow in one direction we need to make sure we get this right, otherwise it will be a dead short between power and ground. Ensure the side with the White stripe is connected to power/positive side of the solenoid.
Specification:
- Type: Solenoid Valve
- Material: Metal, Plastic
- Color: White
- Voltage: DC 12V
- Pressure: 0.02 - 0.8 Mpa
- Max. Fluid Temperature: 100°C
- Operation Mode: Normally Closed
- Inlet and Outlet: Hose Barbs for 1/2" (Outer Diameter) Hose
- Usage: Water and Low Viscosity Fluids
- Valve Type: Diaphragm
- Features: 1/2"
- Screw Diameter: 2cm/0.79" (Approx.)
- Size (L x H): 84mm x 57mm/3.31" x 2.24" (Approx.)
- Coil Size (W x H): 34mm x 23mm/1.34" x 0.91" (Approx.)
Understanding the 5V relay module
See more information here.
Understanding the Water flow sensor YF-S201
See more information here.
Signals and connections of the 5V relay module
The SRD-05 VDC-SL-C relay has three high voltage terminals (NC, C, and NO) which connect to the device you want to control. The other side has three low voltage pins (Ground, Vcc, and Signal) which connect to the Arduino.
NC: Normally closed 120-240V terminal
NO: Normally open 120-240V terminal
C: Common terminal
Signals and connections of the LCD 1602 I2C module
As you can see on the back of LCD 1602 module there 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA) (Arduino Uno SDA or Analog pin A4) and Serial Clock Line (SCL) (Arduino Uno SCL or Analog pin A5).
Signals and connections of the water flow sensor YF-S201
The sensor comes with three wires: red (power), black (ground) and yellow (Hall effect pulse output).
Wiring
WARNING – THIS PROJECT INVOLVES HIGH VOLTAGES THAT CAN CAUSE SERIOUS INJURY OR DEATH. PLEASE TAKE ALL NECESSARY PRECAUTIONS, AND TURN OFF ALL POWER TO A CIRCUIT BEFORE WORKING ON IT. WE ARE NOT RESPONSIBLE FOR ANY DAMAGE, INJURY, DEATH AND OTHER THINGS CAUSED BY THIS PROJECT IMPLEMENTATION.
Let us build a water flow sensor controlled relay circuit that will close the solenoid valve when the water flow rate exceeds a certain predefined threshold value. The relay has two different types of electrical contacts inside – normally open (NO) and normally closed (NC). The one you use will depend on whether you want the 5V signal to turn the switch on or turn the switch off. The 120-240V supply current enters the relay at the common (C) terminal in both configurations. To use the normally open contacts, use the NO terminal. To use the normally closed contacts, use the NC terminal.We will use NC (Normally closed)configuration, when the relay receives a HIGH signal the 120-240V switch closes and allows current to flow from the C terminal to the NC terminal. A LOW signal deactivates the relay and stops the current.
Make sure that the high voltage connections to the 5V relay module are very well secured. Identify the hot power wire (red wire in the diagram above) in the cord leading to the PUMP and make a cut. Connect the side leading to the PUMP to the NO terminal of the 5V relay, and the side leading to the plug to the C terminal. This way the relay is on the hot side, and current is switched before it reaches the PUMP. It’s dangerous to put the relay on the neutral wire, since if the device fails current can still fault to ground when the relay is off.
The following picture shows the needed connections with the Arduino Uno
Step by Step instruction
- Do wiring.
- Open Arduino IDE.
- Plug your Adruino Uno board into your PC and select the correct board and com port.
- Find your I2C address. Each device has an I2C address that it uses to accept commands or send messages. Load the sketch over at http://playground.arduino.cc/Main/I2cScanner and follow the instructions to use it. By opening up the Serial monitor window after you upload the sketch, Arduino will scan the address range looking for a reply. Even though the documentation said it was 0x27, this scanner can detect different (in our case 0x3F)
- Modify the sketch in attachments above (you can use the sketch below too): the line LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) (See part marked bold)
- Verify and upload the the sketch to your Adruino Uno
- Open up serial monitor and set your baud to 9600 baud.
- You will see water quantity, pulses and frequency readings on LCD screen. If the water quantity reading exceeds a certain predefined threshold value (15 liters in our case), the solenoid valve will close.
Summary
We learnt how to connect water level sensor, 5V relay module with 12V solenoid valve and LCD1602 I2C module to Arduino board and use them.
Libraries:
- All libraries attached on the begining of the project description
- We have used the library - NewliquidCrystal_1.3.5.zip which we downloaded, unzipped, changed the name of folder to LiquidCristal and added to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. If you have LiquidCristal folder in this location already - delete this folder and copy folder, which was made by you, to this location.
Sketch:
- See attachment on the begining of this project
Other projects of Acoptex.com










jobs.viewed