An automated pet feeder with ESP32 and servo motor is a brilliant weekend project for Indian pet owners who travel frequently or have irregular schedules. With cats and dogs increasingly becoming beloved household members across Indian cities, ensuring timely feeding when you’re stuck in traffic or on a business trip has real practical value. This project uses an ESP32 to control a servo motor that dispenses food on a schedule — all manageable from your smartphone.
Table of Contents
- Project Overview
- Components and Shopping List
- Mechanical Design and Food Hopper
- Wiring Diagram
- ESP32 Code with WiFi and Scheduling
- Blynk App Integration
- Home Assistant Integration
- Frequently Asked Questions
Project Overview
This automated pet feeder has several key features:
- Scheduled feeding times (up to 8 per day)
- Remote manual feed trigger via app
- Adjustable portion size via servo angle
- Low-food level sensor using ultrasonic distance measurement
- Feeding log with timestamps
- Optional camera for live pet monitoring
Total project cost: ₹1,200–₹2,000. Commercial auto-feeders in India cost ₹3,000–₹15,000.
Components and Shopping List
- ESP32 DevKit V1 (38-pin)
- MG995 or MG996R servo motor (high torque, 11 kg·cm)
- HC-SR04 ultrasonic sensor (food level detection)
- PVC pipe (75mm diameter, 300mm length) — food hopper
- 3D printed auger/dispenser wheel or plywood cutout
- 5V 3A power supply (servo draws significant current)
- DS3231 RTC module (for accurate time even without WiFi)
- Small OLED display (optional, 0.96″ I2C type)
- Project box or repurposed plastic container
Mechanical Design and Food Hopper
The dispensing mechanism is the most important part of the feeder. Two popular designs work well with Indian pet food (both dry kibble and pellets):
Auger Design (Most Reliable)
A spiral auger screw inside a tube rotates to push food forward and drop it into the bowl. Print the auger in PLA or PETG. The servo rotates the auger a fixed number of turns per feeding, giving consistent portion sizes. This design handles both small kibble and larger dog food pellets.
Rotating Disc Design (Simpler)
A disc with holes sits below the food hopper. Rotating the disc aligns a hole with the hopper outlet, dropping a measured portion. Simpler to build but less consistent for irregular-shaped food pieces.
Food Hopper
Use a 75mm PVC pipe (available at any hardware shop in India for ₹80–₹120 per metre) as the food hopper. A 300mm length holds approximately 500g of dry cat food or 300g of dog kibble. Seal one end with a PVC cap. Drill the hopper mounting holes to align with your auger tube.
Wiring Diagram
ESP32 Connections:
Servo Motor (MG995):
GPIO 13 (PWM) → Signal (Orange wire)
5V external → VCC (Red wire)
GND → GND (Brown wire)
HC-SR04 (Food Level):
GPIO 5 → Trig
GPIO 18 → Echo
3.3V → VCC (use voltage divider on Echo!)
GND → GND
DS3231 RTC:
GPIO 21 (SDA) → SDA
GPIO 22 (SCL) → SCL
3.3V → VCC
GND → GND
OLED Display:
GPIO 21 (SDA) → SDA
GPIO 22 (SCL) → SCL
3.3V → VCC
GND → GND
IMPORTANT: Power servo from external 5V supply,
not from ESP32's 5V pin — motor draws 500mA–2A!
ESP32 Code with WiFi and Scheduling
#include <WiFi.h>
#include <ESP32Servo.h>
#include <RTClib.h>
#include <Preferences.h>
const char* ssid = "YOUR_WIFI";
const char* password = "YOUR_PASS";
Servo feederServo;
RTC_DS3231 rtc;
Preferences prefs;
// Feeding schedule: hours and minutes (24h format)
int feedHours[] = {7, 13, 19}; // 7am, 1pm, 7pm
int feedMins[] = {0, 0, 0};
int numFeedings = 3;
int portionAngle = 180; // Servo angle for one portion
void dispenseFeed() {
Serial.println("Dispensing food!");
feederServo.write(portionAngle);
delay(1000);
feederServo.write(0);
delay(500);
// Log feeding time
DateTime now = rtc.now();
Serial.printf("Fed at %02d:%02dn", now.hour(), now.minute());
}
void checkSchedule() {
DateTime now = rtc.now();
for (int i = 0; i < numFeedings; i++) {
if (now.hour() == feedHours[i] &&
now.minute() == feedMins[i] &&
now.second() == 0) {
dispenseFeed();
}
}
}
void setup() {
Serial.begin(115200);
feederServo.attach(13);
feederServo.write(0);
rtc.begin();
WiFi.begin(ssid, password);
// Set up web server for manual trigger
// ... (web server code)
}
void loop() {
checkSchedule();
delay(1000);
}
Blynk App Integration
Blynk provides a quick way to create a smartphone interface for your pet feeder. The free tier allows up to 2 devices which is sufficient for this project.
- Create a Blynk account at blynk.cloud
- Add a new device and note your Auth Token
- In the app, create:
- A Button widget (Virtual Pin V0) — Manual Feed Now
- A Gauge widget (V1) — Food Level %
- A Value Display (V2) — Last fed timestamp
- A Time Input widget (V3, V4, V5) — Set feeding times
The Blynk library handles reconnection automatically, essential in India where WiFi connectivity can be intermittent. When WiFi is unavailable, the DS3231 RTC ensures scheduled feedings continue locally.
Home Assistant Integration
For more advanced users, integrate the pet feeder with Home Assistant using MQTT:
# configuration.yaml
switch:
- platform: mqtt
name: "Pet Feeder Manual"
command_topic: "petfeeder/feed"
payload_on: "FEED"
sensor:
- platform: mqtt
name: "Food Level"
state_topic: "petfeeder/level"
unit_of_measurement: "%"
# automation: Alert when food is low
alias: Low Food Alert
trigger:
- platform: numeric_state
entity_id: sensor.food_level
below: 20
action:
- service: notify.mobile_app
data:
message: "Pet feeder food level is low! Please refill."
Frequently Asked Questions
What type of pet food works best with a DIY auger feeder?
Dry kibble (8–12mm diameter) works best with both auger and rotating disc designs. Larger dog food (15mm+) may require a wider tube and auger diameter. Avoid wet food entirely — it will clog and harbour bacteria.
How do I calibrate portion size?
Run the servo through its full range and measure the amount dispensed at different angles. For example, 90° rotation might dispense 25g and 180° dispenses 50g. Mark these calibration values in your code for consistent feeding.
What happens if WiFi goes down?
The DS3231 RTC module maintains accurate time independently of WiFi. Your scheduled feedings continue even during internet outages. The device reconnects to WiFi automatically when it becomes available.
Can I add a camera to watch my pet?
Yes. Use an ESP32-CAM module mounted above the food bowl. Stream video to your phone via the ESP32’s built-in web server or integrate with Home Assistant’s camera entity. This lets you verify your pet is eating normally even when you’re away.
Is it safe to leave this running for 2–3 days while travelling?
Yes, with proper setup. Use a quality 5V power supply (not a cheap charger), ensure the food hopper has enough capacity, and test the system for 1–2 weeks before your trip. Consider adding a backup power notification to alert you if power goes out.
Add comment