Description
What it is
The YF-G21 water flow sensor is a device that measures water flow and temperature. It is useful for electronic monitoring projects, such as automatic irrigation systems or water control systems.
Features
- Water flow sensor with temperature sensor
- Physical connection: G1/2 DN15
- New model YF-G21
What it is for
The sensor is usable for aquarium projects, water pumps, and water control systems. You can build an automatic irrigation system with Arduino by integrating this flow meter.
Tutorial: How to use YF-G21 Flow Meter
The YF-G21 flow meter measures water flow and fluid temperature. Useful for aquarium projects, water pumps, and water control systems.
What you need
- Arduino UNO or compatible
- Power cable
- Pull-up resistor (10kΩ)
- Ground wires
Steps
- 1. Assemble the flow meter in a G1/2 or DN15 bathroom pipe.
- 2. Connect the VCC pin to the 5V of the Arduino.
- 3. Connect the GND pin to the GND of the Arduino.
- 4. Connect the SIG pin to pin A0 of the Arduino.
- 5. Connect the pull-up resistor between VCC and SIG.
- 6. Connect the TOUT pin to pin A1 of the Arduino.
- 7. Check the datasheet for the correct supply voltage.
- 8. Load the Arduino code.
Example code
```void loop() {
int flow = analogRead(A0);
int temp = analogRead(A1);
Serial.print("Flow: ");
Serial.println(flow);
Serial.print("Temp: ");
Serial.println(temp);
delay(1000);
}```
Mini project
Build an automatic irrigation system with an Arduino, a flow meter, and a water pump.
Common mistakes
- Do not connect the pins correctly.
- Omit the pull-up resistor.
- Connect the pins in reverse.
- Do not check the supply voltage.
Recommended accessories
- Water pump
- 10kΩ resistor
- Power cable
- Arduino UNO
Frequently asked questions
How can I check the temperature?
Read the TOUT pin with `analogRead(A1)`.
Does the flow meter work with other types of fluid?
Check the datasheet for fluids other than water.
How long does the battery last?
The flow meter does not have a battery, it is powered directly by the Arduino.
Can I use the flow meter with Arduino Mega?
Yes, but make sure the pins are compatible.







Reviews
There are no reviews yet.