Making a fish feeder based on Arduino and ultrasonic sensors

The working principle of the automatic fish feeder is very simple. Below, we connect the feeding device to the shaft of a stepper motor, which is activated when the ultrasonic sensor detects an obstacle, so the feeding device moves and drops food particles into the tank.

The device can be attached to almost any type of aquarium for fish keeping pets and the size of the feeder can be expanded as per the requirement, having said that, let's start looking at what materials are required to make this feeder.

Component List

Arduino Uno × 1
Stepper Motor × 1
Stepper motor driver × 1
Ultrasonic distance sensor × 1
Jumper cables × 1
Glass bottle (can be used in an aquarium) × 1
Ties × Several
Small box to hold the glass (not needed if you are using it in an aquarium) × 1
3D printer and PLA supplies × 1
Arduino IDE and cable × 1

3D Printed Components

The feed tray is 3D printed. This design structure allows you to control the feeding precision and avoid was  

base.stl  Downlosd    
feeder_mechanism  Download 

 

The choice of PLA material color is up to you, in my opinion this color looks great, you can refer to the images in the steps above to see the exact settings I followed when printing this model.

This design is for a 28BYJ-48 stepper motor and cannot be mounted directly to other motors unless you make some modifications to the final design.

Once we have the 3D printed parts, we can start building the circuitry for this hardware.

Circuit diagram and program


Here we can divide the circuit into two parts, the first part is the stepper motor and the second part is the ultrasonic sensor part.

Connect the stepper motor to the driver and connect the pins of the driver to the Arduino as shown below.

In1 Connect the D2 pin of the Arduino.

In2 Connect the D3 pin of the Arduino.

In3 Connect the D4 pin of the Arduino.

In4 Connects to the D5 pin of the Arduino.

The + and - pins are connected to the Arduino's 5v and GND pins.

The ultrasonic sensor has 4 pins, Vcc, Gnd, Trig, and Echo, which are connected as follows:

Vcc connects to the Arduino's 3v pin.

Gnd connects to the Arduino's Gnd pin.

Gnd to the Gnd pin of the Arduino. Trig to the D9 pin of the Arduino.

Trig to Arduino pin D9 and Echo to Arduino pin D10.

This completes the circuit, now connect the Arduino to the computer via the USB cable.
Open the Arduino IDE and use the program below, make sure you select the correct port and board type and then click the upload button, once done our circuit is partially complete and we can proceed further.

The code can also be downloaded from the file repository:

arduino_fish_feeder_project Download

 

Assembly

This is the very simple but most important part, first glue the stepper motor and the bottom of the tray in place with hot melt glue Tim, then assemble the base of the 3D printed grid and press firmly.

Once the glue is completely dry, we can reinforce the top of the tray with hot melt glue to ensure good strength.

Here you can mount the base in an area opposite to where the stepper motor wiring is, which will help later when putting the feeder into the tank.

Another thing here is to make sure that the gap between the base and the rotating part is very small, which in another case could lead to food leaks.

Finishing

To make the feeder look nice I will use a 3D printed frame for the ultrasonic transducer, as you can already see the project is perfect.

To mount the stepper motor to the aquarium I will be using tie wraps as the type of aquarium is round and this is the best way to do it, if you are using a square type I would recommend using a clip type bracket.

Use enough cable ties to hold it in place and cut off the excess. For the sensors I used hot melt glue to secure them.

How to use

Add fish feed pellets to each slot that needs to be dispensed and after all the slots are filled with food, make sure that the ultrasonic transducer is not obscured by any obstacles.

Power up the Arduino and now when you place your hand in front of the transducer, the food will fall into the water so that the fish can get some food!