🌐 IoT 📡 ESP8266 Intermediate ⏱️ 6-8 Hours

WiFi-Enabled Pet Feeder

Never worry about your pet's mealtime again! Build a smart, WiFi-connected pet feeder that allows you to dispense food remotely via a web interface or schedule automatic feedings. Using an ESP8266 and a high-torque servo motor, you'll create a reliable mechanical feeding mechanism that can be controlled from anywhere.

💰
$25 - $35
📊
Intermediate
🧩
5 Parts
📝
Jan 2026

📖 Project Overview

This project combines mechanical design with IoT software. We use a Continuous Rotation Servo or a High-Torque Standard Servo (MG996R) to rotate a spiral auger or a trapdoor mechanism. The ESP8266 hosts a small web server that listens for a "Feed" command.

To make it robust, the hub also includes a manual feed button and an LED indicator to show WiFi status. This ensures that even if your internet is down, you can still feed your pet with a physical tap.

🧰 Components Required

Part Name Qty
ESP8266 NodeMCU 1
MG996R High Torque Servo 1
5V 2A Power Adapter 1
Tactile Push Button 1
Feeder Mechanism (PVC Pipe or 3D Printed) 1

🔌 Hardware Connections

🔍 Pin Mapping Guide

Component Pin ESP8266 Pin Notes
Servo Signal (Orange) D4 (GPIO 2) Internal pull-up safe
Servo VCC (Red) 5V (Ext Power) Do not use ESP8266 3.3V
Servo GND (Brown) GND Common GND with ESP
Push Button D3 (GPIO 0) Pulled HIGH by default

💻 ESP8266 Firmware

C++ (Arduino IDE)
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Servo.h>

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

ESP8266WebServer server(80);
Servo feederServo;

#define SERVO_PIN 2
#define BUTTON_PIN 0

void dispenseFood() {
  feederServo.attach(SERVO_PIN); // Attach servo here to avoid continuous buzzing
  feederServo.write(180); // Open/Rotate
  delay(1000);
  feederServo.write(90);  // Stop/Close
  feederServo.detach(); // Detach servo to save power and stop buzzing
}

void handleRoot() {
  String html = "<h1>Pet Feeder Control</h1><button onclick=\"location.href='/feed'\">Feed Now</button>";
  server.send(200, "text/html", html);
}

void handleFeed() {
  dispenseFood();
  server.send(200, "text/plain", "Feeding Complete!");
}

void setup() {
  Serial.begin(115200);
  // feederServo.attach(SERVO_PIN); // Moved to dispenseFood()
  feederServo.write(90); // Initial position (only if attached)
  
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) { delay(500); }
  
  server.on("/", handleRoot);
  server.on("/feed", handleFeed);
  server.begin();
}

void loop() {
  server.handleClient();
  if (digitalRead(BUTTON_PIN) == LOW) {
    dispenseFood();
    delay(500);
  }
}
← Back to All Projects