arduino lcd displays flow meter gpm and total price
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
I had a go at tidying it up so I could follow it. In breaking it down the frequency looks confusing (2 things at 40 hz isn"t really 80hz), but I wanted to see flowrate = freq / 0.2 in the code. Overall I can"t see a mistake except for the divide by 2 giving a bad GPM output. The gallons should be OK.
But, this code is definitely the wrong approach, every second it stops watching what"s going through the pipes so that it can tally up the total so far. The code as shown in the pause isn"t enough to explain the 13% error but maybe there is more stuff in there we haven"t been shown.
You really just need to count the total number of pulses to get the total volume. And sample the frequency if you want a live readout of the flow rate.
Waterproof, heat resistance, pressure resistance, cold resistance. Easy to install. Flow range:10-200L/min Sensor:Hall effect Maximum current:15 mA(DC 5V) Working voltage range:DC 5-18 V Load capacity:≤10 mA(DC 5V) Operating Temp:up to 80C,Operating...
The flow meter on the web page she listed in the OP says it"s a hall effect sensor, but you"re right about them not being super accurate. You have to have a pretty steady flow rate for them to have consistent readouts. If the application is to see how flow varies over time that might present difficulties.
Here is another example of flow meter code where the pulses are called out at the top instead of mid-code - this one I did not write myself, I don"t remember the name of the guy that helped me with it:
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
If you use interrupts to count the pulses then two pulses arriving at the same time will be handled sequentially. The interrupt flag indicating a pulse has arrived is set in hardware the moment the pulse arrives, and the CPU checks all the interrupt flags between instructions. Each flag is handled sequentially, the order determined by interrupt priority settings and a "natural" order determined by the internal wiring of the CPU.
However there is a better way on the ESP32, and that is the Pulse Counter peripheral. This is designed to count pulses like the signals from Hall Effect sensors.
You can just leave the Pulse Counter counting your pulses, then periodically read and reset the pulse count to see how much water has flowed in that period. It looks from the documentation that you can have two inputs both making the same counter increment, so it will do the aggregating for you.
When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.
Displays the flow total volume, flow rated and sensed temperature clearly; custom icons on the display indicate the controller working status at a glance
I am a 66 year old farmer that believes that if it can be imagined then it can be done. Not letting my complete lack of programming knowledge stand in my way I have proceeded to incorporate/borrow portions of Arduino sketches from all over the internet (Github, Youtube and this forum) in my attempt to write a sketch that takes impulses from two G3/4 hall effects flow meters and adds their outputs together to come up with a gallons per acre value on a sprayer. I am very appreciative of the generosity of others and this whole open source concept.
Version one using both an Arduino Uno and a 2560 Mega with the same results, was with Adafruit 16x2 LCD with USB+Serial backpack (product 782) that worked. I test it by blowing into the two flow meters and the lcd shows GPA and GPM data. The 16x2 display shows the following when at rest: (sorry couldn"t upload picture)
Wanting to have more lines of data to show more variables from more sensors (amount remaining in tank, possibly time and mph) I switched to Adafruit standard 20x4 lcd (product198) with i2c/SPI backpack (product 292). The test sketch for the 20x4 with the i2c backpack (Hello World) works and I can move it around the lcd at will by changing setCursor (X, X) location. I have left it in the void setup but turned off (//) so I can make sure the 20x4 is still working. I also ran the setCursor sketch from the examples in the i2c library and after editing it to 20x4 it works, so I’m pretty sure my wiring is correct.
My problem is when I add to the sketch’s void loop for the flow meters I get a blank LCD. All my setCursor and lcd.print commands are ignored in my void loop. I have gotten a lot of help/advice from a friend who has some computer science background but we may have reached his limits of Arduino experience.
In this post we are going to construct a digital water flow meter using Arduino and 16 x 2 LCD display. We will be taking a look at YF-S201 water flow sensor, its construction and working and how to interface with Arduino to extract some useful readings.
YF-S201 is a Hall Effect based water sensor. It has three terminals 5V (nominal working voltage), GND and output. The +5V is red coloured wire, the black one is GND and yellow one is output.
The sensor gives out frequency directly proportional to water flow. The YF-S201 sensor can measure from 1 litre / minute to 30 litre / minute. The water pressure should be less than or equal to 1.75 MPa.
The sensor may be placed after the main gate-valve of tank; if you want to measure the water flow in a network of water pipes or you can place just before a water tap to measure the water flow of single tap.
The sensor has a magnet and Hall Effect sensor; if we take a look at the sides of the water flow sensor, we can witness a plastic turbine in the path of water flow.
A round shaped magnet is embedded at the center of the turbine and the Hall Effect sensor is sealed and protected from moisture and placed above the magnet. The Hall Effect sensor produces a pulse for every revolution of the turbine.
We have blown air through the sensor to rotate the turbine as a test and the waveform generated is shown above. The denser waveform on left hand side represents higher frequency and faster rotation of turbine, the less dense waveform at right hand side signifies the vice versa.
The water flow sensor’s output pin is connected to A0 of Arduino. Use the 10K potentiometer for adjusting display contrast. Wire the Arduino and LCD display as per the above diagram.
If you have any questions regarding this digital water flow meter using Arduino, feel free to express in the comment section, you may receive a quick reply.
New: A brand-new, unused, unopened, undamaged item in its original packaging (where packaging is applicable). Packaging should be the same as what is found in a retail store, unless the item was packaged by the manufacturer in non-retail packaging, such as an unprinted box or plastic bag. See the seller"s listing for full details.See all condition definitionsopens in a new window or tab
This project was done for a Friend Of a Friend. He needs to monitor water flow rate and quantity for his solar heating projects. He is mainly interested in this two inch sensor but also sent along a small plastic hose bib type similar to the Adafruit 828. Both of these sensors are turbine types, water flow spins a plastic wheel which magnetically triggers a pulse output proportional to the speed at which the wheel is turning. There’s lots of these sensors made for irrigation and industrial processes. The display is sometimes called a “Totalizer”.
The electrical interface on the small flow meter has 3 wires, power, ground, and pulse output – relatively simple to connect to the microcontroller. But the large device has only 2 wires. It signals a pulse by shunting power to ground through a low resistance. The display must sense a pulse by looking for an increase in supply current. I designed an interface circuit that works with either unit by changing an option jumper. I constructed the interface circuit on a small piece of project board from Radio Shack (RIP). The positive supply feeds through a resistor which produces enough voltage drop when the large sensor is pulsing to trigger a digital low at the Arduino. The series resistor value is low enough that the power feed is still adequate for the small plastic sensor, so the option jumper just selects where to pick off the pulse signal. A series resistor and zener diode make sure the voltage ratings of the Arduino input pin are not exceeded. It’s a bad thing to overvolt an Arduino pin, please Don’t Ask Me How I Know This.
In this photo you can see the interface board soldered down near the front of the Altoids tin. I use “L” shaped bits cut from a paper clip, soldered to the board ground, and to the ground plane. The same technique anchors the Arduino board.
At first I worked up the circuit on a solderless bread board using code from the Adafruit web site. When satisfied with the results, I went ahead with building the Altoids tin prototype. The Arduino variant I used is a Sparkfun Pro Mini 5 Volt. It takes up little space and has a 5 volt regulator with enough capacity to run the 16×2 LCD. An LED and two push buttons protrude through the lid, these are regular 6mm square PCB buttons. I solder one side directly to the lid, the other side of the switch is supported by a bit of PCB material and a piece of paper clip wire.
This photo shows the LED and the Reset button. Note the bit of PC board on the high side of the switch has a groove filed across so the grounded paper clip is isolated from the signal connection.
This photo shows the Function switch. It’s hard to see, but there is a 0.05 ufd surface mount capacitor soldered between the signal side and ground. That capacitor is part of my debounce strategy.
The Liquid Crystal Display itself mounts on four 2-56 screws. The screw heads are soldered directly to the lid. I attached a 10k Pot for contrast adjustment to the back of the LCD and it’s legs are used as tie points for 5v and ground wiring to the rest of the display.
If I have to build another one of these, I might glue the Arduino board to the back of the LCD which will greatly reduce the wiring between lid and box.
There is a power jack for 9 or 12 volt DC input, and a 3 conductor phone jack to connect the turbine sensor. These are epoxyed to the box. Connection to the sensor plug is as follows:
Almost all of the turbine type flow sensors I looked at have two calibration factors specified: a “K” factor and an “offset”. During calibration the manufacturer measures the pulse rate outputs for a number of precise flow rates. These are plotted but since the turbine has some friction, the graph will not be linear especially at the low end and a linear regression is done to get a best fit straight line. The “K” factor represents the slope of the fitted line and has a dimension of pulses per unit volume moved. Offset represents the small amount of liquid flow required to start the turbine moving. You can assume that if any pulses are arriving at all, at least the offset volume of liquid is moving. The 228PV manual specifies:
In general, this formula applies to any measurement unit. It would be possible to convert a gallons display to liters by just scaling the K and offset factors by the constant liters/gallon. The Adafruit example sketch uses this method but measures pulse period in 1 millisecond increments which creates large gaps in the data if the pulse rate is over 100 Hz. At 200 Hz the pulse period will be 5 milliseconds, so a 1 millisecond period change is a 20 percent jump!
Adafruit states their sketch is just an example to verify their sensors functionality but I felt higher accuracy at large flow rates was essential. An internet search turned up several sketches using a direct interrupt to count pulses. The sensor pulse train is applied to pin 2 or 3, fires on the rising edge of a pulse and calls an Interrupt Service Routine like:
Can’t get much simpler than that. Run this for exactly one second and you have counted pulses per second. Apply to the above formula and get volume units transfered in that second. Accumulate that many units each second to find total volume transferred. So the code to actually calculate rate and volume is easy. I exorcised most of the Adafruit code and added my own formulas. I also added a line in the ISR to blink the LED along with the incoming pulses.
But this display needs to operate with multiple types of flow sensors. So I had to code an arrangement to set and permanently store K and Offset for whatever sensor was plugged in. That turned out to be the most complicated part of the sketch. I use the Function button to do this, taking advantage of the Arduino setup section which is only executed on a reboot. Holding Function down while resetting the processor starts set mode.
To make this a little easier, I added code to blink the LED if the button is held between 2 and 4 seconds, and turn on the LED solid if held more than 4 seconds. I hope this is no more annoying than setting a cheap digital watch.
This photo is the normal running display entered after exiting set mode, or on a processor reset. The first line records units moved per second, where units is in whatever the given K factor uses. Both the Adafruit sensors have factors specified in Liters/Second. The 228PV I’m working with uses units of Gallons per minute. The water meter on my house here measures in cubic feet. You have to consult the sensor data sheet.
I’ve constructed a second unit. This one is built in a nice looking Extruded Aluminum box from Adafruit. I thought the better enclosure would make construction easier. I was wrong. Because it can’t be opened you can’t reach in and solder anything, and you lose the convenience of soldering anything needing a ground directly to the tin box. That means wires have to be attached to every terminal, brought to a common point and spliced. I did try soldering the Pro Mini to the back of the LCD and that works but the contrast pot had to be wired out so the assembly didn’t save much wiring. This photo shows the completed display with K factor set to 1.0 and a 2000 Hz crystal controlled signal applied to the sense input:
Most of these flow sensors will have specified somewhere in the data sheet, a K factor and offset. What the manufacturer does is plot flow in output pulses per second (frequency) against flow volume through the sensor at a number of flow rates. Then they do a linear regression on the data to get a best fit straight line. An example is Fig 1 in http://www.hofferflow.com/datasheets/miniflow2.pdf.
There does not seem to be a standard for how K factor is presented. Sensors output a pulse stream at a frequency proportional to the flow volume as calibrated, this can be measured. With some sensors, you multiply the pulse frequency by the K factor to obtain a volume rate. Others however, require you to divide the pulse frequency by K.
In the sketch, I added a way to switch between these two methods by using the first character of the K factor. If this character is a “*”, the incoming pulse rate will be multiplied by the K factor, If the first character is “/” pulse rate will be divided by K. You may see a formula in the sensor data sheet like Freq = (Flowrate * K) – offset. Since we measure Frequency and need to display Flowrate, the formula is rearranged toFlowrate = (Freq + offset) / K and the K factor needs to be set to type “/”. Other sensors present Freq = (Flowrate / K) – offset. Rearranging that formula gives Flowrate = (Freq – offset) * K and you would set the K type to multiply, “*”. If the sensor documentation is not clear, just try it out. If the multiply/divide indicator is wrong, you will probably get totally unreasonable flows displayed. If so try changing the type indicator.