Digital Liquid Dispenser Using Arduino UNO, Flow Meter and Solenoid Valve

Materials

  • Electrical box of an appropriate size
  • Arduino UNO or similar
  • Flow meter – hall effect type, 3 wire, brass body ideally
  • Hose barbs of whatever sizes and plumbers tape
  • Solenoid valve – 24v DC, semi-direct (so can operate at 0 pressure)
  • 24v DC adapter
  • 24v to 5v USB converter
  • 5v relay
  • Various wires, connectors, push switches, resistors, LEDs and so on
  • Electrical tools, plus a drill, various drill bits

Assembly

I 3D printed a frame to mount the 24v – 5v converter, Arduino UNO, relay and some electrical connectors to. You can see it in the photo below – the black frame bolted into the grey box. This ensures the components are held securely and appropriately positioned. It also allows for wires to be routed below the boards, which when working within a relatively small container is helpful.

The photo below also shows the preliminary wiring. The connector block to the bottom right will eventually connect to the solenoid valve, and the main 24v input will be wired into the blue connector on the USB voltage converter (to left of image). The relay is connected to 5V and GND from the Arduino, as well as taking a feed from one of the digital pins.

Arduino-based electronics

Next up the flow meter and solenoid valve are positioned in the box and a hole drilled for the inlet hose. The liquid flow is from left to right across the width of the box.

The solenoid valve and flow meter are fitted with hose barbs and joined with some clear hose. I used jubilee clips to secure the joints later on, as well as plumbers tape to keep the joints water tight. There’s very little pressure in this system so the chance of a leak is minimal, but it’s best to be sure!

Solenoid valve and flow meter

With the hardware positioned I carried on with the wiring. The box lid has a series of buttons on it, one for each volume of liquid required (shown further down), as well as a button to cancel the dispensing process should a problem arise.

This image shows more of the wiring, including the main 24v DC barrel jack input secured into the top of the box, the USB cable from the 24v – 5v converter into the Arduino and the coloured wires which run out of shot to the control buttons. The control buttons are wired down to the Arduino’s GND.

Wiring everything up

Once all this was in place I 3D printed a bracket for the solenoid valve. It is quite heavy and I wanted to ensure it was securely mounted into the box. I had to experiment with the design to get it to fit correctly as the shape of the solenoid housing was quite complex. In the end I produced 4 variants – the first 3 are shown below:

3D printing

The bracket needed to be mounted flush to the front edge of the box, and allow for the lid to close. These boxes have a lip to facilitate a water tight seal, so I had to account for this within the design of the bracket, which you can see in the image below.

The bracket is bolted into the box using an M5 bolt, nut and washers. The solenoid valve is held in place with a few cable ties, which make it easy to remove it in the future should it need replacing or servicing.

Securing the solenoid valve

In the image above you can also see the outlet spout. This is a right angled hose barb which is mounted through a hole in the side of the box. Neat!

Below you can see the finished assembly with all the wiring and hardware in place within the box:

The finished system

The front of the box isn’t very glamorous, but it serves a purpose. This is a prototype machine, afterall. The cancel button is clearly marked and red, making it easy to spot should there be a problem. The cancel button is connected to the Arduino’s reset pin, so when pressed performs a hardware reset which immediately turns the relay off, stopping the flow of liquid through the solenoid.

The white LED shows that the system has electrical power. The red LED lights up when the machine is dispensing liquid. The black buttons represent different volumes of liquid, as identified by the values written above each one:

Buttons for different volumes of liquid

See It In Action

Video showing it in action

Arduino Code

I’m not an expert at writing C++ so if you spot any issues with this feel free to point them out.

Jack Barber, freelance web developer based in Whitby, UK

Written By

I'm a freelance web developer based in Whitby, UK. I built my first website using GeoCities, and learned to write HTML and CSS using Notepad. Web technology has come a long way since then, as have my web development skills!

These days I love helping my clients make the most of the internet. I provide design, development, marketing and IT support services, forming long-term partnerships with my clients.

Connect With Me

Posted in Arduino, Industrial Design, Projects