Flow meter/sensor lots of help needed!

Hi guys,

I’m new here and very new to Arduino in general. I’m a homebrewer and I’d like to build an Arduino based flow sensor/meter with an electric solenoid valve that would shut off the flow once a target volume is reached. I have the following components:

  • Arduino Uno R3
  • 16x2 Sainsmart LCD shield (however, I’d like to bypass the 6 on-board buttons altogether and simply add 2 momentary push buttons (SPST-NO) to act as a “menu” and “exit” buttons)
  • KY-040 Rotary encoder module
  • YF-S201 Hall Effect water flow counter
  • 12V DC N/C 0-0.8MPa electric solenoid valve
  • 5V 1 channel relay module board
  • Piezo buzzer
  • DS18B20 temperature probes

I want the main screen to display the following information: Target volume, Current volume, and % of target volume reached.

Besides the flow meter functionality and solenoid valve triggering once a target volume is reached, I’d like to use a rotary encoder to do things like:

  • Toggle the units being displayed (chose between litres or gallons);
  • Change the target volume;
  • Display temperatures (toggle between F or C);
  • Display flow rates (gallons/hour or litres/hour);
  • Turn piezo buzzer function on/off with a visual display of that action (i.e. icon on main screen)

I would like the piezo buzzer to be triggered to sound once 90% of target volume is reached, increasing the frequency as the volume approaches 100% of target. Once target is reached, display a message (i.e. something like “VALVE CLOSED. TARGET REACHED”).

I realize that some of my components will need to be calibrated in order to be used properly and I can manage that calibration once the code is written.

Is there a good source for help on how to program this? I have no idea where to start!! I’m willing to learn step by step or function by function, but I’m overwhelmed on the amount of information out there and how to compile it all together into one project.

Thanks ahead of time!

Cheers.

I’m overwhelmed on the amount of information out there and how to compile it all together into one project.

How do you eat an elephant? One bite at a time. You are overwhelmed because you are trying to eat the entire zoo at once.

Pick something basic, like reading the temperature. Focus on getting that to work. Don’t worry about the fact that the temperature you are measuring is that of the top of your desk. When the temperature sensor is properly installed, the code won’t change.

Pick another something basic, like making the solenoid open and close at regular intervals, like blinking an LED. Don’t worry about the fact that the solenoid is laying on your desk. When the solenoid is properly installed, the code won’t change.

Get all the basic pieces working. Accept that fact that initially, you will need to make code changes to change the fill amount or the temperature at which something happens. If you structure your code correctly, that is changing the value of one const variable or one #define statement (no, I’m not going to argue which is better).

When the system works the way you want, THEN add the complexity of a menu system. By then, it will either be obvious what you need to do or you will be sick of the project.

Here's a link for the encoder: http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/keyes-ky-040-arduino-rotary-encoder-user-manual/

And a canned sketch for the flow sensor:

/*
   YF-S201 Hall Effect Water Flow Meter / Sensor
   http://www.hobbytronics.co.uk/yf-s201-water-flow-meter
   
   Read Water Flow Meter and output reading in litres/hour

*/

volatile int  flow_frequency;  // Measures flow meter pulses
unsigned int  l_hour;          // Calculated litres/hour                      
unsigned char flowmeter = 2;  // Flow Meter Pin number
unsigned long currentTime;
unsigned long cloopTime;

void flow ()                  // Interrupt function
{ 
   flow_frequency++;
} 

void setup()
{ 
   pinMode(flowmeter, INPUT);
   Serial.begin(9600); 
   attachInterrupt(0, flow, RISING); // Setup Interrupt 
                                     // see http://arduino.cc/en/Reference/attachInterrupt
   sei();                            // Enable interrupts  
   currentTime = millis();
   cloopTime = currentTime;
} 

void loop ()    
{
   currentTime = millis();
   // Every second, calculate and print litres/hour
   if(currentTime >= (cloopTime + 1000))
   {     
      cloopTime = currentTime;              // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min. (Results in +/- 3% range)
      l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flow rate in L/hour 
      flow_frequency = 0;                   // Reset Counter
      Serial.print(l_hour, DEC);            // Print litres/hour
      Serial.println(" L/hour");
   }
}

http://www.freetronics.com.au/pages/jaycar-water-flow-gauge

Thank you very much everyone for your quick and very helpful advice and links.

Truly appreciated!

I might have bitten off more than I can chew...but I'm willing to learn!

I'll be back soon...I'm sure!

Cheers.