ESP32 Automatic Cat Feeder

  • Author: Ioana-Denisa Popescu
  • Email: ioana.popescu1905@stud.acs.pub.ro
  • Master: SRIC

Introduction

The ESP32 Automatic Cat Feeder is a smart, IoT-enabled system designed to reliably automate pet feeding by dispensing food according to a customizable schedule. Whether the owner is away or simply wishes to automate daily pet care, the feeder — powered by an ESP32 microcontroller — ensures the cat is fed on time and receives the correct portion sizes to prevent overfeeding.

Context and General Description

Block Diagram The system uses an ESP32 microcontroller as its central processing unit, taking advantage of its built-in Wi-Fi capabilities to enable remote monitoring and control via the Blynk mobile application, along with optional integration with Google Home for voice-activated commands. The main goal of the project is to ensure reliable, portion-controlled food dispensing based on customizable schedules or proximity detection, while enabling remote access to support efficient and flexible pet care management.

When it comes to hardware, essential elements include a servo motor for triggering the food dispensing mechanism, an ultrasonic distance sensor for detecting the cat’s proximity and an LED indicator to show the general system status. The servo motor operates for a fixed duration to ensure consistent and portion-controlled food delivery.

The system operates in two main modes, which can be adjusted remotely via the Blynk mobile application or web dashboard:

  • Proximity-Based Feeding (V0): When enabled, the distance sensor monitors for movement within a predefined range (<10 cm). If the cooldown period has passed, the system automatically activates the servo to dispense food when the cat is nearby. Proximity-based feeding can be enabled or disabled within the Blynk architecture.
  • Manual Feeding via Mobile App / Web Dashboard (V1): Users can trigger the feeder remotely by using the Blynk app or web dashboard. This mode allows feeding on demand, regardless of proximity and is definitely useful when the user is away from home.

Hardware

Hardware Components

  • ESP-WROOM-32 ESP32
  • LED
  • Wires, Breadboard
  • SG90 Servo Motor
  • HC-SR04 Ultrasonic Sensor

Hardware Circuit

Connecting Components

Ultrasonic Sensor HC-SR04 Measures the distance to a detected object by calculating the time between sending and receiving the reflected ultrasonic signal, multiplying it by the speed of sound. It is used to detect the movement of the cat.

  • GND → GND
  • VCC → 5V
  • Trig (sends the pulse) → G27
  • Echo (receives the reflected signal) → G13

SG90 Servo Motor Required to move the built dispenser mechanism by 90 degrees to release the food.

  • GND → GND
  • VCC → 5V
  • PWM → G14

LED Used to show state of system and functioning modes.

  • Anode (+) → G12
  • Cathode (-) → GND

Physical Circuit (Initial Version)

At this stage, the hardware components were connected and part of the code was tested to check basic functionalities. However, for the final version of the system, the component placement was slightly adjusted to eliminate redundant wiring.

Software Design

For the software development, the ESP32 platform was programmed using the Arduino IDE with the following libraries:

  • ESP32Servo.h for servo motor control
  • WiFi.h for managing Wi-Fi connectivity
  • BlynkSimpleEsp32.h for integration with the Blynk IoT platform

Workflow Description

The system uses the Blynk platform to remotely control and monitor the automatic cat feeder via virtual pins. The key interaction points are two virtual pins:

  • V0 controls whether the automatic proximity feeding mode is enabled or disabled
  • V1 is a manual trigger to start feeding immediately from the app.

The Automatic Cat Feeder system functions according to the logic shown in the following diagram:

After initializations such as connecting to Wi-Fi, pins, servo motor and Blynk configurations in setup(), it is important to distinguish between operating modes, under currentAction:

  • NONE - at first, check whether proximity is enabled. Additionally, if cat motion is detected by the sensor, move servo to enable feeding, light led and set currentAction to PROXIMITY. Finally, set virtual pin V1 0 (which is in charge of proximity), so the value can be further sent to the Blynk app/dashboard.
  • PROXIMITY - stop servo to disable feeding, stop led and reset currentAction to NONE
  • CATFEEDER - same actions as PROXIMITY, but also set virtual pin V0 0 (which is in charge of servo), so the value can be further sent to the Blynk app/dashboard.

The code also handles the timing of each feeding action using millis() for non-blocking delays. This makes sure the system remains responsive to both sensor data and user inputs. A cooldown mechanism prevents overfeeding or other conflicting actions in the system. Moreover, two particularly important functions in this code are BLYNK_WRITE(V0) and BLYNK_WRITE(V1), which respond to input from the Blynk app:

/**
 * @brief Handles updates to the virtual pin V0 from the Blynk application
 * @param param Value sent from Blynk app. Expected to be 1 (enable) or 0 (disable).
 */
BLYNK_WRITE(V0) {
  proximityV0 = param.asInt();
  Serial.print("proximityV0 mode: ");
  Serial.println(proximityV0 ? "ENABLED" : "DISABLED");
}
/**
 * @brief Handles manual feeding requests from the Blynk app via virtual pin V1.
 * @param param The value received from Blynk, typically 1 (trigger) or 0 (off/reset).
 */
BLYNK_WRITE(V1) {
  if (param.asInt() &&  (currentAction == NONE)){
    Serial.println("catFeederV1 triggered!");
    
    feederServo.write(90);
    digitalWrite(LED_PIN, HIGH);
    actionStartTime = millis();
    currentAction = CATFEEDER;
    actionActive = true;
  }

  catFeederV1 = param.asInt();
  Serial.print("catFeederV1 mode: ");
  Serial.println(catFeederV1 ? "ENABLED" : "DISABLED");
}

Challenges

One of the main challenges was integrating and configuring the device with Blynk. Beyond just authentication, some interesting steps included creating dashboards for both web and mobile, as well as setting up the synchronized data streams, specifically the virtual pins V0 and V1.

Additionally, I was able to implement several automations, such as notifications when motion is detected by the cat or scheduling feedings at specific time intervals.

Finally, the coolest challenge was definitely configuring a voice assistant to control the feeding commands via Google Home. For this, I used the IFTTT applet and integrated it with Google Home over Wi-Fi. This setup allows me to trigger the automatic feeder simply by speaking, which adds a great level of convenience and modernizes the system significantly. It was fascinating to connect cloud-based voice commands with my local IoT device, creating a seamless interaction between smart home technology and pet care.

Results

Final Product

Demo

ESP32 Automatic Cat Feeder

Conclusions

The ESP32 Automatic Cat Feeder project successfully demonstrates how IoT technology can enhance everyday pet care by combining hardware control with cloud-based connectivity. Through the integration of sensors, actuators, and the Blynk platform, the system provides flexible, remote and automated feeding options. The addition of voice assistant control further elevates the user experience by enabling hands-free operation.

Overall, this project highlights the potential of smart devices to create more connected and responsive environments, making pet care easier and more efficient for owners.

Download

The source code can be downloaded here: automaticcatfeeder_popescu_denisa.zip

References

iothings/proiecte/2025sric/automatic_cat_feeder.txt · Last modified: 2025/05/29 11:08 by ioana.popescu1905
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0