The CHONK feeder

March 2, 2025
Description
03/02/2025 UPDATE!!!
- After I started printing and assembling the feeder, several inconsistencies emerged in the assembly. The main problem was with the Shaft, so I updated its structure (2 blades instead of 4 and connection to the servo motor by a M2 screw).
- Another small change I made was to the Mechanism enclosure, I slightly enlarged the holes where the Shaft sits; now it is pressed in until it sits in place.
- I also decided to print the body itself in the opposite orientation than planned (I also updated the pictures in the instructions below).
- New pictures & videos of the project were added.
----------------------------------------------------------------------------------------------------------------
The CHONK is essentially an automated system that dispenses food when your pet comes close enough. The ultrasonic sensor detects the presence of your pet, and the servo motor controls the dispensing mechanism based on the proximity and timing logic in the code.
Hardware and Software Used:
Hardware:
- UNO R3/Micro/Nano ESP32/ESP32 microcontroller
- Ultrasonic sensor (HC-SR04)
- MG90 servo motor
- Breadboard and jumper wires
- M2 Screw
Software:
- Arduino IDE
- SolidWorks
- Bambu Studio
Wiring Diagram:
Ultrasonic Sensor:
- VCC -> 5V on ESP32
- GND -> GND on ESP32
- TRIG -> GPIO 23 on ESP32
- ECHO -> GPIO 22 on ESP32
Servo Motor:
- VCC -> 5V on ESP32 (or external power supply if needed)
- GND -> GND on ESP32
- Control -> GPIO 26 on ESP32
Code:
I tried to keep the code as simple as possible. This is the link to the site from which I downloaded the initial code: https://wokwi.com, but I improved it a bit with AI to make it more suitable for the purpose.
The code uses an ESP32 microcontroller to control a servo motor based on distance measurements from an ultrasonic sensor. When an object is detected within a specified distance threshold, the servo motor rotates to a certain angle, simulating the opening and closing of a door. The servo motor only opens the door when an object is detected within the specified distance, and there is a delay between subsequent activations to avoid continuous triggering.
#include <ESP32Servo.h>
#define TRIG_PIN 23 // ESP32 pin GPIO23 connected to Ultrasonic Sensor's TRIG pin
#define ECHO_PIN 22 // ESP32 pin GPIO22 connected to Ultrasonic Sensor's ECHO pin
#define SERVO_PIN 26 // ESP32 pin GPIO26 connected to Servo Motor's pin
#define DISTANCE_THRESHOLD 10 // Distance threshold in centimeters
Servo servo; // Create servo object to control the servo motor
// Variables for distance measurement and timing
float duration_us, distance_cm;
unsigned long lastActivatedTime = 0;
unsigned long delayPeriod = 10000; // Delay period of 10 seconds in milliseconds
void setup() {
Serial.begin(9600); // Initialize serial port
pinMode(TRIG_PIN, OUTPUT); // Set ESP32 pin as output for TRIG pin
pinMode(ECHO_PIN, INPUT); // Set ESP32 pin as input for ECHO pin
servo.attach(SERVO_PIN); // Attach the servo to pin 26
servo.write(0); // Initialize servo position to 0 degrees (closed door)
}
void loop() {
// Generate 10-microsecond pulse to TRIG pin
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// Measure duration of pulse from ECHO pin
duration_us = pulseIn(ECHO_PIN, HIGH);
// Calculate the distance in centimeters
distance_cm = 0.017 * duration_us;
unsigned long currentTime = millis();
// Check if the distance is below the threshold and the delay period has passed
if (distance_cm < DISTANCE_THRESHOLD && currentTime - lastActivatedTime >= delayPeriod) {
servo.write(90); // Rotate servo motor to 90 degrees (open door)
delay(1000); // Keep the door open for 1 second
servo.write(0); // Close the door
lastActivatedTime = currentTime; // Update the last activation time
}
// Print the measured distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500); // Wait for 500 milliseconds before taking another measurement
}
Printing Instructions:
All the printable parts files are already correctly oriented for convenient printing in STEP, STL & 3DM files with consideration for minimum supports.
1. Mechanism enclosure (bottom part): Supports are required in the marked areas below.
2. Food hopper (top part): Supports are required in the marked areas below.
3. Lid (for the food hopper): Supports are required in the marked areas below.
4. Shaft Updated 03/02/2025 (the part was updated bet the printing Instructions are still the same) (goes inside the Mechanism enclosure & connects to the MG90 servo motor with M2 screw): Supports are required (automatic).
5. Slot plug (two pcs required): Holds the Shaft in the Mechanism enclosure. No supports are required. (After an initial test, overall, it seems that the feeder works even without these parts.)
Assembly Instructions:
- Connect the Servo motor to the Shaft using M2 screw.
- Place the Servo motor & Shaft assembly in the slots of the food channel in the Mechanism enclosure.
- Insert the two Slot plugs in the slots of the food channel above the Servo motor & Shaft assembly until they sit firmly in the slots.
- Insert the Ultrasonic sensor into the dedicated holes in the Mechanism enclosure.
- In the Mechanism enclosure, there is plenty of room for all kinds of Arduino controllers; now is a good time to connect all the wires.
- Place the Food hoper over the Mechanism enclosure (lip & groove connection)
- Close the Food hoper with the Lid (lip & groove connection).
Follow up for the updates & the upcoming photos of the print!
Let me know what you think in the comments! Happy printing!