Automated Arduino Tap

by Blackbeltrider in Circuits > Arduino

7038 Views, 59 Favorites, 0 Comments

Automated Arduino Tap

Picture1.jpg
Automated Arduino Tap

This project was designed for my dog, who refuses to drink from a water bowl. She often sits by the tap for hours waiting for someone to pass and open it for her. So I built her this automatic tap that opens when it senses her and closes again when she's out of range.

The whole setup is centered around a 20L bucket. This allows it to stand even where there is no tap. It uses a Arduino Nano as a controller, a normally closed solenoid valve as a tap and a 12V battery as a power supply.

I created this tap as a solution to a problem that, while most people probably never experience it, was quite a problem to my family. Trust me, there is nothing sadder than a dog sitting for probably half an hour waiting for someone to see her and open the tap. And then to stand there and wait for her to finish before you can go about your business can also be a nuisance.

Supplies

12V solenoid valve
Arduino nano
HC-SR04 range sensor
10K resistor
Diode
MOFSET (I used a IRFZ24N)
12V battery
Jumper cables
Breadboard
Female spade terminals for the battery and solenoid valve
Heatshrink
A bucket
About a meter of twin flex
Epoxy glue
Some plumbing pieces the same diameter as your solenoid. I used 2 elbow joints and 2 connector pieces
A strip of flexible metal
Some rivets
Two small plastic containers to protect your components from the elements

Connecting the Circuit

Schematic.PNG

Connect everything together as shown in the schematic above and mount it onto a mini breadboard.
The DC motor in the schematic represents the solenoid.
The reason for the MOFSET is that the Arduino can't drive the 12V solenoid by itself. The Arduino's output is only 5V therefore the MOFSET allows the Adruino to still control the solenoid while the battery powers it. The battery also powers the board through the VIN pin.
It isn't recommended to omit the diode. The solenoid opens and closes by means of an electromagnet. The closing magnetic field can induce a backward flowing current that damages the board.

The Code

Code.PNG
int trigPin = 12;
int echoPin = 11;
int valvePin = 9;
long distance;
long duration;
void setup(){
  pinMode (9, OUTPUT);
  pinMode (trigPin, OUTPUT);
  pinMode (echoPin, INPUT);
  
  Serial.begin(9600);
}
void loop() {
  ultra();
   
  if(distance <= 25){
  digitalWrite (9, HIGH);
    Serial.print("Distance: ");
    Serial.println(distance);
  } 
  
  else {
    digitalWrite (9, LOW);
  }
  
}
void ultra(){ //the range sensor's code
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;
  }

The Bucket: Part 1

20201209_105153.jpg
20201209_104840.jpg

Drill a hole the diameter of your solenoid as close to the bottom of the bucket as possible.
Screw the pieces together as shown, then screw the elbow piece into the rest through the hole.

The Bucket: Part 2

20201209_105338.jpg
20201209_105328-2.jpg
20201210_095215.jpg

First, mark and drill holes for the range sensor into its container (the sensor box). Drill another hole on the top for the wires to come out.

Next, cut a strip of metal and rivet it onto the top of the bucket. On the other end, rivet the container.

Put the sensor inside. Pull the wires through the holes and connect them.

Assembly: Part 1

20201210_095355.jpg

Drill holes on the sides of the other container (control box). Place the breadboard inside and string the wires through the holes.

Manipulate any components so that they fit into the box.

Assembly: Part 2

20201210_095807-2.jpg
20201210_103819.jpg

Attach the solenoid's spade terminals to one end of two male-to-male jumper wires. Run the male ends through the control box's hole.

Wire the positive terminal of the battery to the VIN pin and the negative to the ground pin.

Assembly: Part 3

20201211_113725-2.jpg

Use the epoxy to glue the control box and the wires to the bucket.

Tidy up any other loose ends and you're done!

Testing Your Creation

Automated Arduino Tap

Finally, test your creation. Put the bucket on a stool or step or something, connect the battery and make sure everything works.

Teaching the Dog

Possibly the hardest step of all if your dog doesn't already drink from a tap. Luckily mine does and she quickly realised that she doesn't have to wait for anyone to open this tap. The video is of her on her first go. She took to it like a fish to water. This is proof that you really can teach an old dog new tricks.

Well that's it. I hope you, and your dog, enjoyed this instructable.