🐟 Smart Automatic Fish Feeder (NodeMCU Offline with EEPROM) – Full Guide + Code + Circuit

 


If you ever forget to feed your fish or travel for a few days, an automatic fish feeder is the perfect solution. In this project, we’ll build a NodeMCU (ESP8266)-based automatic fish feeder that works completely offline — no Wi-Fi, no app, no cloud.

It uses a servo motor to release food twice a day and stores its schedule in EEPROM, so it can resume its timing even after a power loss.
This simple but smart project is ideal for pet owners, students, and IoT beginners looking to automate daily tasks.

⚙️ Components Required

ComponentDescription
NodeMCU ESP8266                   Main microcontroller
SG90 Servo Motor                    To dispense fish food
5V Power Supply                   Stable 1A recommended
Jumper Wires                   For connections
Breadboard                                                        Optional
Plastic Bottle or Hopper                   To hold fish food

🔌 Circuit Overview


📷 Photo: 




Wire it like this:

🛠 What You Need

Buy these parts (replace placeholders with your affiliate/shop links):
📌 NodeMCU ESP8266https://s.click.aliexpress.com/e/_c3iM1SaP
📌 SG90 Micro Servohttps://s.click.aliexpress.com/e/_c4CEEBA7
📌 5V Power Supplyhttps://s.click.aliexpress.com/e/_c3aUKoAX
📌 LED (optional)https://s.click.aliexpress.com/e/_c4tqHHzD
📌 Jumper Wireshttps://s.click.aliexpress.com/e/_c3p0y3pp
📌 Breadboard or PCBhttps://s.click.aliexpress.com/e/_c4bq0Taj

⚠️ Use an external 5 V supply for servo power if the servo draws more current than the NodeMCU can safely provide.

💻 Full Arduino Code

Upload this sketch to your NodeMCU using Arduino IDE:

#include <Servo.h> #include <EEPROM.h> #define SERVO_PIN D1 #define LED_PIN D2 Servo feeder; const int START_ANGLE = 0; const int DISPENSE_ANGLE = 150; const unsigned long DISPENSE_TIME = 1500; const unsigned long FEED_INTERVAL = 12UL*60UL*60UL*1000UL; unsigned long lastFeed = 0; const int EEPROM_ADDR = 0; void feedFish() { digitalWrite(LED_PIN,HIGH); feeder.write(DISPENSE_ANGLE); delay(DISPENSE_TIME); feeder.write(START_ANGLE); delay(200); digitalWrite(LED_PIN,LOW); unsigned long sec = millis()/1000; EEPROM.put(EEPROM_ADDR,sec); EEPROM.commit(); } void setup() { Serial.begin(115200); feeder.attach(SERVO_PIN); feeder.write(START_ANGLE); pinMode(LED_PIN,OUTPUT); EEPROM.begin(16); unsigned long savedSec = 0; EEPROM.get(EEPROM_ADDR,savedSec); lastFeed = savedSec*1000UL; } void loop() { unsigned long now = millis(); if(now - lastFeed >= FEED_INTERVAL) { feedFish(); lastFeed = now; } delay(50); }

This code:
✔ Feeds every 12 hours
✔ Uses EEPROM to remember last feed time
✔ Drives a servo to dispense food
✔ Uses an optional LED for status

💻 Code Explanation

The program uses EEPROM to save the last feed time. Every 12 hours, the servo rotates 150°, opens the feed container for 1.5 seconds, and returns to its original position. When it feeds, it stores the current timestamp in EEPROM so it continues from where it left off after a power outage.

The interval can be changed in the line:

const unsigned long FEED_INTERVAL = 12UL * 60UL * 60UL * 1000UL;

Change “12” to any number of hours you want between feedings.

🧠 How It Works

  1. When powered, the NodeMCU checks EEPROM for the last feed time.

  2. It uses its internal clock (millis()) to track time since the last feeding.

  3. Once 12 hours pass, it triggers the servo to dispense food.

  4. The last feed time is saved again in EEPROM.

  5. Even if the power goes off, it remembers when it last fed and continues automatically.


⚡ Advantages

  • ✅ Works offline — no Wi-Fi or app needed

  • ✅ Saves timing in EEPROM for reliability

  • ✅ Low power and easy to build

  • ✅ Fully automatic — perfect for daily feeding routines

This offline NodeMCU fish feeder is a practical IoT-style automation project you can sell or build for your own aquarium. It reduces maintenance, keeps your pets healthy, and teaches valuable embedded-systems skills.


automatic fish feeder project

nodeMCU offline feeder

esp8266 fish feeder

arduino servo fish feeder

eeprom schedule feeder

smart aquarium gadget

DIY pet feeder



Comments