Raspberry Pi automated fish feeder
Construction
In the solution I had in mind, the feed is provided by a small storage tower that drops the food from the top with a little help from gravity through an opening in the aquarium cover. You can build a feeder tower like this with parts from your local hardware store or order the materials online from craft stores. In my case, a desk pen holder served as a starting point; this part is readily available in many stores and are often made of transparent plastic, which is ideal for monitoring the fill level.
Now it's time to saw and drill holes. After that, I added the servo and the mechanical system. The whole thing was then mounted on a base plate, which also bears the Zero W and a small circuit board with a status LED and control buttons (Figure 3).
The feed outlet is operated by a specially developed mechanism. Depending on the direction of rotation of the servo, one of the two tubes of the pen holder opens. For this purpose, a straight shaft passes through both tubes, with a closure for each of the two openings sitting on the shaft.
Because of the angular offset, only one of the two shafts can open at any given time during a short left or right turn, and it is closed again automatically a short time later. Small paddles act as the closures to avoid a shaft remaining permanently open and ensure that the desired amount of feed is delivered (Figure 4).
The 160-liter aquarium with low fish stock levels does not need more than a heaped teaspoon of dry food every day. The supply in the vending machine will be fine for a three-week vacation. If you need a larger reserve, adjust the setup to your needs in terms of diameter and height of tubes.
Control
The feeding process starts automatically after applying the supply voltage. As specified in the Raspberry Pi crontab, the vending machine feeds the fish once a day. On Saturdays, feed is taken from the second shaft by rotating the servo at the same angle, but in the opposite direction. Once a minute the housing LED flashes a visual ready signal. To track all events on the device, the LED uses various flash codes (Table 1).
Table 1
LED Flash Codes
Signal | Status |
---|---|
1x long |
Live, flashed every minute |
1x medium |
Shaft 1 opening (plus photo) |
2x medium |
Shaft 2 opening (plus photo) |
3x short |
Single snapshot |
3x very short |
Shutting down |
What you can't see in the circuit diagram (Figure 5) are the two push buttons on the case, which are connected to the Zero W general purpose input output (GPIO) pins to trigger a feed in the first shaft and for a controlled system shutdown.
Because the feeder is on the local network, it can be maintained over the network, as well. To do so, log in to a terminal over SSH with:
ssh pi@feeder
You can then make changes to the crontab or control script. If needed, you can disable the automatic feeder by calling:
python3 /home/pi/scripts/feed.py 4
The 4
option tells the device to enter maintenance mode without any further actions.
Observations
One interesting and positive side effect is the ability to see whether the fish are getting any feed from the feeder. The control script triggers a snapshot through the aquarium glass with a delay of 10 seconds after operating the servomotor. The simple Pi Cam Rev 1.3 serves this function well. Because I only need to grab an image of a section of the front of the aquarium, image quality is secondary.
The connection from the vending machine on the top of the aquarium to the Pi cam on the front of the aquarium requires a long camera cable (about 30cm for my setup) that depends on the height of the aquarium cover. A narrow aluminum plate fixes the small camera housing a few centimeters in front of the screen.
To get sharp images, you need to set the shortest possible focal length on the Pi cam. To do this, turn the adjustment ring of the small lens very carefully with a tool and grab a few test images to check the setting.
The connection to the network is primarily designed to post the image grabbed after feeding, so I can check it online. It also opens up some possibilities for remote operation. This setup requires an HTTP server on the Zero W. The installation of the lean lighttpd web server [2] and PHP on the Raspberry Pi is well documented online, so I will not go into further detail here.
The feeder's web page (Figure 6), where you can check the last feeding image and trigger a feeding along with a snapshot with three buttons, is implemented in PHP and resides in the Raspberry Pi's www
directory. The code for this and the Python script to control the feeder is on the project's GitHub page [3], and an English version is on the Linux Magazine download site [4].
To access the web interface on the local network, simply enter the local IP address of the Zero W in a web browser. To monitor the system remotely while on vacation, you need to enable the server on the Zero W in your router for the web and assign a permanent IP. However, if you already use a website with FTP access, you can alternatively upload the current feeding image to your own web space and view it there.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.