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.
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.
| 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 |
#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);
}
}