Fish feeder
A servo or auger releases a small amount of food at set times.
Build it step by step
0 of 7 doneTest the servo
Move between two angles.
Make the cup
Measure one portion of food.
Mount the hopper
Food falls into the cup by gravity.
Add the clock
Set the DS3231.
Add the schedule
8 am and 6 pm.
Add the daily limit
At most three feeds.
Watch for a week
Adjust the portion.
How do you build a fish feeder?
A servo or auger releases a small amount of food at set times. You need Arduino Nano, SG90 Micro Servo, DS3231 RTC module and Tactile push button 6 mm. It takes 7 steps and about 90 minutes.
- Level
- Beginner
- Time
- About 90 min
- Parts
- 4
Parts list
- Development BoardsBuyArduino Nano × 1
- Motors & ActuatorsBuySG90 Micro Servo × 1
- SensorsBuy
- SwitchesBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Servo signal | Nano D9 | Feeder motion |
| Servo plus and minus | Nano 5V and GND | Power |
| RTC SDA and SCL | Nano A4 and A5 | Clock |
| Manual button | Nano D2 to ground | Extra feed |
Code
A small servo carries a measuring cup from a hopper opening to a spot over the tank, so each feed is the same amount of food. Most fish should be fed only what they finish in a couple of minutes, and overfeeding fouls the water faster than underfeeding harms the fish, so the sketch allows at most three feeds a day, whatever the button does. Count total feeds in EEPROM so you can see usage. Set the DS3231 clock once with the RTClib example. Mount the hopper dry and away from water splashes, keep humidity off the Nano, and for a holiday of more than a few days ask someone to check the tank as well, since an automatic feeder cannot notice a failing filter or heater. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Fish feeder: a servo turns a measuring cup twice a day. Libraries: Servo, RTClib, EEPROM. Board: Arduino Nano.
#include <Servo.h>
#include <Wire.h>
#include <RTClib.h>
#include <EEPROM.h>
Servo cup;
RTC_DS3231 rtc;
const int BTN = 2;
const int FEED_HOUR[2] = {8, 18};
const int MAX_PER_DAY = 3;
int fedToday = 0, lastDay = -1;
unsigned int totalFeeds;
void feed() {
if (fedToday >= MAX_PER_DAY) return; // stops accidental overfeeding
cup.write(160); delay(900); // tip the cup over the water
cup.write(10); delay(900); // back to refill from the hopper
fedToday++; totalFeeds++;
EEPROM.put(0, totalFeeds);
}
void setup() {
pinMode(BTN, INPUT_PULLUP);
cup.attach(9); cup.write(10);
rtc.begin();
EEPROM.get(0, totalFeeds);
if (totalFeeds == 0xFFFF) totalFeeds = 0;
}
void loop() {
DateTime now = rtc.now();
if (now.day() != lastDay) { lastDay = now.day(); fedToday = 0; }
static int doneHour = -1;
for (int i = 0; i < 2; i++)
if (now.hour() == FEED_HOUR[i] && now.minute() == 0 && doneHour != now.hour()) { doneHour = now.hour(); feed(); }
if (now.minute() == 1) doneHour = -1;
if (digitalRead(BTN) == LOW) { feed(); delay(1000); }
delay(500);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| 8:00 | One portion is released |
| 18:00 | Another portion |
| Button | Extra feed up to the daily limit |
| Fourth feed in a day | Refused |
If it does not work
Food jams
Use dry flakes and widen the hopper opening.
Servo buzzes
Check the end angles do not hit the stops.
Wrong times
Reset the clock.
No feed
Check the schedule hour matches the clock.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the fish feeder?
Arduino Nano, SG90 Micro Servo, DS3231 RTC module and Tactile push button 6 mm.
How long does the fish feeder take to build?
About 90 minutes for a beginner maker, in 7 steps.
How do I know the fish feeder works?
8:00: One portion is released. 18:00: Another portion. Button: Extra feed up to the daily limit.
Food jams: what should I check?
Use dry flakes and widen the hopper opening.
Servo buzzes: what should I check?
Check the end angles do not hit the stops.
Wrong times: what should I check?
Reset the clock.
No feed: what should I check?
Check the schedule hour matches the clock.
