liquor / wine dispenser with flow meter

Hi All,

I am building a liquor / wine dispenser.
wine is pouring with food grade gas.
i would like to use smallest flow meter along with solenoid shut off valve which will stop pouring after flowmeter send signal 30ML or 60 ML pour is done with flowmeter reading.
Idea is to set 2 or 3 pour size like first touch would pour 30ML or 1 OZ and 2nd 89, 3rd 147ML.
Is there anyway to find coding for flowmeter to pour desired pour and stop with arduino or raspberry pi ?

Thank You

Hi,
Welcome to the forum.

google coffee pod machine flow sensor

They are capable of those sort of low volumes and have to be food grade.

Tom.. :slight_smile:

You can use cheap hall effect flow sensors for this and simply set Arduino to count the pulses, as flow rate is not an issue. A sensor with 3mm pipe should be the sort of thing you need.

TomGeorge:
Hi,
Welcome to the forum.

google coffee pod machine flow sensor

They are capable of those sort of low volumes and have to be food grade.

Tom.. :slight_smile:

Hi Tom, Thanks for reply!! i ordered 1/8 solenoid shut off valve also Coffee Flow Sensor Switch Control Flowmeter Meter Counter 0.3-6L/min from ebay which should arrive in couple days.

Nick_Pyner:
You can use cheap hall effect flow sensors for this and simply set Arduino to count the pulses, as flow rate is not an issue. A sensor with 3mm pipe should be the sort of thing you need.

Hi Nick,
Thanks for your reply. would you mind sharing any code which will read flowmeter than stop shut off valve ?

click on button to pour ( which will turn on solenoid valve)
wait for flowmeter to read assigned liquid ( like 30ML)
flowmeter detect 30 ML poured.
stop shut off valve.

Thank You
Paul

Even trickier would be to calculate the rate of flow and shut off the solenoid so that only 30ml gets dispensed.

If you wait till you have counted too 30ml to turn off, your likely going to overshoot some.

onlinegill:
Thanks for your reply. would you mind sharing any code

Any pulse counter should suffice. I work with rate of flow, which would be more than you need. You may need two solenoids, the second with restricted flow to finish off the dose - rather like a petrol pump..

Slumpert:
Even trickier would be to calculate the rate of flow and shut off the solenoid so that only 30ml gets dispensed.

If you wait till you have counted too 30ml to turn off, your likely going to overshoot some.

You aren't calculating rate of flow, you are just measuring the volume. so as @Nick_Pyner said, just a pulse counter.
Thanks.. Tom.. :slight_smile:

I am sorry i am confused between pulse counter and flow meter ? are they same or where i can get pulse counter?

so far i am using raspberry pi python script (found online) to start pouring with button press but script work only 1 time i need to keep it in loop. can anyone help me about this while i will be working on flow meter or pulse counter ?

from gpiozero import LED, Button
from time import sleep
from signal import pause
# Setup the output pins
output = LED(17)

# Setup the button
button = Button(18)

# Wait for the button to be pressed
button.wait_for_press()

# Do the stuff you want done after the button is pressed here
output.on()

# Wait for 5 sec
sleep(5)


# Assuming you want the signals to return to 0 V at the end
output.off()

pause()

A flow meter delivers pulses, Arduino counts them. That is all you need - the count equals quantity. If you add time to the equation, you get rate. That involves more code. It is not what you need.

is there any basic coding for reading pulse and stop attached solenoid valve ?
push button to start pour
wait for flowmeter to send pulse.
stop solenoid on desired pulse.

Thank You

Raspberry pi python code
I was playing around with codes and its working as i wanted. here is time based code.
following script will turn on led on pin 17 for 5 second ( you can modify as you want sleep(5) to whatever time you need than it will be off until you press button again and led will be on again for 5 seconds. it will run in loop.

import  RPi.GPIO as GPIO
import time
from gpiozero import LED, Button
from time import sleep

output = LED(17)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN,pull_up_down=GPIO.PUD_UP)


while True:
    inputValue = GPIO.input(18)
    if (inputValue == False):
        output.on()
        sleep(5)
        output.off()

Meantime i am still looking same script for ardunio

Hi,
Are you building your project with a Raspberry Pi?

Tom... :slight_smile:

Here's an Arduino equivalent:

const byte inputPin = 4;
const byte solenoidPin = 5;

void setup()
{
pinMode(inputPin,INPUT_PULLUP);
pinMode(solenoidPin,OUTPUT);
}

void loop()
{
if(digitalRead(inputPin)==LOW)
  {
  digitalWrite(solenoidPin,HIGH);
  delay(5000);
  digitalWrite(solenoidPin,LOW);
  }
}

Compiled, not tested. Note randomly chosen pins and assumption that holding an output high will energize your solenoid.

TomGeorge:
Hi,
Are you building your project with a Raspberry Pi?

Tom... :slight_smile:

Tom,
I am working on both same time and keep whatever has more options but so far i am little ahead with raspberry pi as it has more options such as running commands etc also for future like adding bar code reader and than pour with bar code or RFID card.i have so many idea's so i am open for anything to achieve them. i would love to use Ardunio if it can give me same outputs.
today i tested flowmeter with Rassberry Pi where i can read pulses with following codes and its gives 24 pulses for 30ML. next i need to modify these codes like when i get 24 pulses it will stop pouring / solenoid on pin 17. i know you might be going to say i should be on pi forum lol.

import RPi.GPIO as GPIO
import time, sys

FLOW_SENSOR = 23

GPIO.setmode(GPIO.BCM)
GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down = GPIO.PUD_UP)

global count
count = 0

def countPulse(channel):
   global count
   count = count+1
   print(count);
GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback=countPulse)

while True:
    try:
        time.sleep(1)
    except KeyboardInterrupt:
        print('\ncaught keyboard interrupt!, bye')
        GPIO.cleanup()
        sys.exit()

wildbill:
Here's an Arduino equivalent:

const byte inputPin = 4;

const byte solenoidPin = 5;

void setup()
{
pinMode(inputPin,INPUT_PULLUP);
pinMode(solenoidPin,OUTPUT);
}

void loop()
{
if(digitalRead(inputPin)==LOW)
 {
 digitalWrite(solenoidPin,HIGH);
 delay(5000);
 digitalWrite(solenoidPin,LOW);
 }
}



Compiled, not tested. Note randomly chosen pins and assumption that holding an output high will energize your solenoid.

Thank you for your reply and time to write codes. i will test them and let you know.

Hi all,
With help of Paddy at pi forum i am able to use following script on raspberry pi but i would like to use it on arduino as well to see if it can work better than pi.
if someone can convert to ardunio code would be great.

from gpiozero import Button, LED
from signal import pause
from time import sleep
import threading
import time
pulse = Button(23)
button_small = Button(18) # first button to  pour small
button_medium = Button(21) # 2nd  button to pour medium
button_big = Button(22) # 3rd  button to pour big
solenoid = LED(17)
clean = LED(25)

GAS_PAUSE = 0.05
TIME_OUT = 10.0

MEASURE_SMALL = 80
MEASURE_MEDIUM = 130
MEASURE_BIG = 200


def pour_small():
    start_pour(MEASURE_SMALL)

def pour_medium():
    start_pour(MEASURE_MEDIUM)

def pour_big():
    start_pour(MEASURE_BIG)

def kill_loop():
    global kill_time
    while True:
        if time.time() > kill_time:
            solenoid.off()
        time.sleep(1.0)
kill_time = 0.0
t = threading.Thread(target=kill_loop)
t.daemon = True
t.start()
def start_pour(amount):
    global count, count_cut_off, kill_time
    count_cut_off = amount
    count = 0
    solenoid.on()
    kill_time = time.time() + TIME_OUT
def count_pulse():
    global count, count_cut_off
    count  += 1
    if count >= count_cut_off:
        solenoid.off()
        clean.on() # run flow meter cleaning solenoid with food grade gas
        sleep(GAS_PAUSE) #keep clean mode for 2 second
        clean.off() # turn off clean mode enjoy drink


pulse.when_released = count_pulse
button_small.when_pressed = pour_small
button_medium.when_pressed = pour_medium
button_big.when_pressed = pour_big

count = 0
count_cut_off = MEASURE_MEDIUM


import tkinter as tk
root = tk.Tk()
root.wm_title('By Gill')
button_frame = tk.Frame(root)

button_frame.pack(fill=tk.X, side=tk.BOTTOM)

small_button = tk.Button(button_frame, text='Pour Small', command=pour_small)
medium_button = tk.Button(button_frame, text='Pour Medium', command=pour_medium)
big_button = tk.Button(button_frame, text='Pour Full Glass', command=pour_big)

button_frame.columnconfigure(0, weight=1)
button_frame.columnconfigure(1, weight=1)
button_frame.columnconfigure(2, weight=1)

small_button.grid(row=0, column=0, sticky=tk.W+tk.E)
medium_button.grid(row=0, column=1, sticky=tk.W+tk.E)
big_button.grid(row=0, column=2, sticky=tk.W+tk.E)

root.mainloop() # do this instead of the pause() used in the gpiozero code

Provide a link to your thread on the pi forum. It is clear that you have there a more comprehensive requirements statement.

Hi,
Here is the link
https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=224850&sid=8529a6f9a852f4b6abdd1d7814655c3b

Not that straightforward to convert. It's more like a total rewrite what you're looking at.

There's a language translation (Python to C++), there's different libraries to be used, there's different hardware involved (at the very least the processor itself), and most likely a different way of interacting between the processor and the external hardware (I never used the Pi).