members
Basics: Project 071e DS1307 RTC, Water flow YF-S201, 5V relay, solenoid valve, LCD2004 I2C - water f
of Acoptex.com in UNO
Basics: Project 071e
Project name: DS1307 Real Time Clock (RTC) module, Water flow sensor YF-S201, 5V relay module, 12V solenoid valve, LCD2004 I2C module - water flow meter
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, LCD2004 I2C module, water flow meter, water flow gauge, DS1307 Real Time Clock (RTC) 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. LCD 2004 I2C module (or LCD2004 + I2C Driver module)1 pc
11. Resistor 3 pcs (2 pcs 1 KOhm and 1 pc 220 Ohm for status LED)
12. Momentary switch 2 pcs
13. LED 1 pc (any color)
14. DS1307 Real Time Clock module 1 pc
General
We will learn how to connect DS1307 Real Time Clock module, Water flow sensor YF-S201, 5 V relay module with 12V solenoid valve and LCD2004 I2C module to Arduino board and use them as water flow meter/gauge. This project suitable to measure water consumption in your shower, bath, or other parts of the house.
Understanding the DS1307 Real Time Clock (RTC) module
You can read more about it here.
Understanding the LCD2004 I2C module
You can read more about it here.
Understanding the electromagnetic valve (solenoid valve)
You can read more about it here.
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 DS1307 Real Time Clock (RTC) module
GND - ground pin.
VCC - power supply pin 5V or 3.3V.
SDA - I2C interface data pin.
SCL - I2C interface clock pin.
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 LED
The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.
Signals and contacts of LCD 2004 I2C module
As you can see on the back of LCD 2004 I2C module there are 4 connections: GND (-), VCC (+5V), Serial Data Line (SDA),(Arduino SDA pin) and Serial Clock Line (SCL) (Arduino SCL pin).
Arduino boards I2C Pins:
Board SDA SCL
Uno A4 A5
Mega2560 20 21
Leonardo 2 3
Due 20 21
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 the rate of water flow once per second and date, time, day of the week.
- You will also see the flow rate in liters per minute, last reading in liters, total in liters, date, time and day of the week on LCD screen.
- The solenoid valve closes when flow rate will reach 10 ltrs. If you press button A it will reset the Last reading (0L).
- If you press button B it will reset the Total. If you press both buttons A and B it will reset all readings, system LED will be off.
Summary
We learnt how to connect DS1307 Real Time Clock module, water level sensor, 5V relay module with 12V solenoid valve and LCD2004 I2C module to Arduino board and use them as water flow meter/gauge.
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.
- Wire library included in your Arduino IDE.
Sketch:
- See attachment on the begining of this project
Other projects of Acoptex.com










Viewed: 4371 times