Raspberry Pi automated fish feeder
Fish Food
![© Lead Image © alexpokusay, 123RF.com © Lead Image © alexpokusay, 123RF.com](/var/linux_magazin/storage/images/issues/2023/268/automatic-fish-feeder/123rf_123653834_steampunk-fish_alexpokusay_resized.png/817156-1-eng-US/123rf_123653834_Steampunk-fish_alexpokusay_resized.png_medium.png)
© Lead Image © alexpokusay, 123RF.com
Whether at work or on vacation, every pet lover worries about how to take care of their little roommates in their absence. What aquarium owners need is an automatic feeder.
Aquarium feeders have been around for a long time, but after my recent research, none of the devices really seemed practical to my mind. Very few devices provide feedback about malfunctions, which could be a nasty surprise when you return home. I created this automatic feeder project for my aquarium for peace of mind.
A Raspberry Pi Zero is a good choice as a control center for a fish feeder: It comes with everything you need to control the mechanical system and to grab images with a Pi cam (Figure 1). It is also compact enough to fit in a small housing. Integrating a Pi Zero W with your wireless home network will allow you to post various captured images online while you are on the road.
The goal was a simple setup that was not prone to errors. Therefore, the mechanical control system only uses one small servomotor. The circuitry of the electronics is just as simple. A DIY control system ensures a certain level of convenience. Two feeders add variety and are quite sufficient to bridge an absence of time equivalent to a three-week vacation.
Getting Started
To get the Zero W up and running, you need to download a new Pi OS image and transfer it to a microSD card. After plugging in a screen and keyboard, you can configure the boot options and network settings. With no need for a desktop later, you can choose automatic login over the command-line interface (CLI) and enable the SSH server and the camera interface. After enabling SSH and with wireless access to your home network, you don't need to connect any peripherals to the Zero W, and you can access it right away from another computer on the network. All further settings can then be configured in a terminal window on the other computer.
The Pi needs a hostname that reflects its task; in this example, it is named feeder. The next step is to create a separate scripts/
folder for the project files in your home directory, where you will later put the feed.py
control script written in Python 3. Instead of loading it as a memory-resident program when the Zero W is started, it is called repeatedly at defined intervals by cron
.
All in Good Time
The schedule for the feedings is set in the Zero W's crontab (cron table), which is the file that manages scheduled task processing. The plan for the feeder is shown in Listing 1, which you can create with crontab -e
[1].
Listing 1
crontab
# m h dom mon dow command # Sunday till Friday 0:*17 * * 0-5 python3 /home/pi/scripts/feed.py 1 # Saturday 0:*17 * * 6 python3 /home/pi/scripts/feed.py 2 # Every minute */1 * * * * python3 /home/pi/scripts/feed.py 0
Crontab specifies feeding every day at 5pm. On Saturday, the script starts with the 2
option on the command line, which releases an alternative feed from the second slot of the vending machine once a week. The third entry in the cron table with option
starts the operation display (the on-board LED flashes once a minute) and is used to read remote control codes from the web – but more on that later.
What You Need
Commercial feeders often rely on relatively complicated mechanics, such as a carousel of loadable compartments. In contrast, I want this feeder system to be as simple as possible, with a view to the DIY system remaining manageable and working safely during periods of absence from home. That said, I did want a certain level of convenience, both in terms of operation and functionality and for the benefit of my stay-at-home pets. Therefore, at least two feeder tubes are available for different feeds (Figure 2).
![](/var/linux_magazin/storage/images/issues/2023/268/automatic-fish-feeder/figure-2/817162-1-eng-US/Figure-2_large.png)
Other considerations were how to ensure – from a distance – that my pets really were receiving their meals. Trouble-free operation from a computer perspective does not give you any feedback as to whether the feed is getting into the aquarium, so I got the idea to record the fish feeding with a camera and serve up a snapshot on the web.
The Zero W comes with on-board tools to accomplish this task, and you can connect a Pi camera to capture an image a short wait after feeding. All you need is a view of a section of the aquarium where the vending machine sits. For protection, the Raspberry Pi and camera are each housed in a small case. The number of other parts in the project is manageable (see the "Parts List" box).
Parts List
- Raspberry Pi Zero W (1/2)
- Pi camera rev 1.3 or higher
- Case for the Pi and Pi camera
- Camera connection cable
- Mini servo (MG90 or comparable)
- Prototyping breadboard (PCB breadboard)
- Two push buttons
- LED
- Various resistors
- DIY feeding tower
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.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.
-
SUSE Offers CentOS 7 Support with Liberty Linux Lite
SUSE's Liberty Linux support offering now includes CentOS 7, which means businesses won't be forced to migrate those servers for some time.
-
Ubuntu's App Center Finally Supports Local Installs Again
If you regularly download .deb files and would prefer a GUI method of installing, Ubuntu has your back.
-
AlmaLinux Now Supports Raspberry Pi 5
If you're looking to create with the Raspberry Pi 5 and want to use AlmaLinux as your OS, you're in luck because it's now possible.
-
Kubuntu Focus Releases New Iterations of Ir14 and Ir16 Laptops
If you're a fan of the Kubuntu Focus laptops or have been waiting for the right time to purchase one, that time might be now.
-
NixOS 24.05 Is Ready for Prime Time
The latest release of NixOS (Uakari) has arrived and offers its usual reproducible, declarative, and reliable goodness.
-
Linux Lite 7.0 Officially Released
Based on Ubuntu 24.04 and kernel 6.8, Linux Lite version 7 now offers more options than ever.
-
KaOS Linux 2024.05 Adds Bcachfs Support and More
With updates all around, KaOS Linux now includes support for the bcachefs file system.
-
TUXEDO Computers Unveils New Iteration of the Stellaris Laptop Line
The Stellaris Slim 15 is the 6th generation and includes either an AMD or Intel CPU