---
title: How to Build a Smart Automatic Feeder for Your Dog Using a Raspberry Pi
siteUrl: https://logzly.com/petfeederpro
author: petfeederpro (PetFeeder Pro)
date: 2026-06-19T04:04:50.693112
tags: [pettech, diy, raspberrypi]
url: https://logzly.com/petfeederpro/how-to-build-a-smart-automatic-feeder-for-your-dog-using-a-raspberry-pi
---


**Disclosure: We are reader supported, and earn affiliate commissions when you buy through us.**


Ever stare at your dog waiting for breakfast while you’re stuck in a [Zoom call](https://www.amazon.com/s?k=Zoom+call&tag=organizationtip101-20)? That tug‑of‑war between work and [pet care](https://www.amazon.com/s?k=pet+care&tag=organizationtip101-20) is real, and a DIY smart feeder can end the drama. I built one for Max last winter, and the whole process was as satisfying as watching him gobble his first bowl on schedule. Below is a step‑by‑step guide that anyone with a bit of curiosity can follow.

## What You’ll Need

Before you dive in, gather these parts. Most of them are cheap and easy to find online or at a local electronics store.

- **[Raspberry Pi](https://www.amazon.com/s?k=Raspberry+Pi&tag=organizationtip101-20)** (any model with GPIO pins; I used a Pi 4)
- **Micro‑[SD card](https://www.amazon.com/s?k=SD+card&tag=organizationtip101-20)** (8 GB or larger, pre‑loaded with Raspberry Pi OS)
- **5 V DC motor** with a small gear box (enough torque to push a kibble cup)
- **Motor driver board** (L298N works well)
- **Breadboard and jumper wires**
- **[Power supply](https://www.amazon.com/s?k=power+supply&tag=organizationtip101-20)** for the Pi (5 V / 3 A)
- **Food container** (a simple plastic tub works)
- **Servo or stepper motor** (optional, for a rotating cup design)
- **Miniature LCD screen** (optional, for on‑board status)
- **Screwdriver, [zip ties](https://www.amazon.com/s?k=Zip+Ties&tag=organizationtip101-20), and a bit of [hot glue](https://www.amazon.com/s?k=hot+glue&tag=organizationtip101-20)**

If you’re missing a tool, improvise. I used an old coffee can as the food hopper and a cheap hobby servo for the dispensing arm. For a version tailored to smaller breeds, see our [budget‑friendly smart feeder guide](/petfeederpro/stepbystep-guide-to-building-a-budgetfriendly-smart-feeder-for-small-dogs).

## Setting Up the Raspberry Pi

### Install the OS

1. Download Raspberry Pi OS Lite from the official site.
2. Flash it onto the micro‑SD card using a tool like Balena Etcher.
3. Insert the card, plug in the power, and let the Pi boot.

### Enable SSH and GPIO

Open a terminal on the Pi (or connect via SSH from your laptop) and run:

```
sudo raspi-config
```

- Navigate to **Interface Options → SSH** and enable it.
- Go to **Interface Options → GPIO** and turn it on.
- Finish and reboot.

Now you can control the Pi’s pins from any computer on the same network.

## Wiring the Motor

### Understanding GPIO

GPIO stands for General‑Purpose Input/Output. Think of them as tiny switches that let the Pi talk to the outside world. We’ll use a few pins to tell the motor when to turn.

### Connect the Motor Driver

1. Plug the L298N board into the breadboard.
2. Connect the motor’s two wires to the driver’s **OUT1** and **OUT2** terminals.
3. Wire the driver’s **IN1** and **IN2** pins to two GPIO pins on the Pi (e.g., GPIO 17 and GPIO 27).
4. Connect the driver’s **GND** to the Pi’s ground and the **+5 V** to the motor’s [power source](https://www.amazon.com/s?k=power+source&tag=organizationtip101-20).
5. Add a small capacitor (100 µF) across the motor’s power leads to smooth out spikes.

### Test the Motor

Run a quick Python script to spin the motor forward for two seconds, then reverse:

```python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
IN1 = 17
IN2 = 27
GPIO.setup(IN1, GPIO.OUT)
GPIO.setup(IN2, GPIO.OUT)

def forward():
    GPIO.output(IN1, GPIO.HIGH)
    GPIO.output(IN2, GPIO.LOW)

def reverse():
    GPIO.output(IN1, GPIO.LOW)
    GPIO.output(IN2, GPIO.HIGH)

forward()
time.sleep(2)
reverse()
time.sleep(2)
GPIO.cleanup()
```

If the motor whirs as expected, you’re good to go.

## Programming the Scheduler

### Why Not Use Cron?

You could schedule feeds with Linux’s cron, but a small Python script gives more flexibility—like adjusting portions based on the day of the week.

### The Feeding Script

Create a file called `feeder.py`:

```python
import RPi.GPIO as GPIO
import time
import datetime

GPIO.setmode(GPIO.BCM)
IN1 = 17
IN2 = 27
GPIO.setup(IN1, GPIO.OUT)
GPIO.setup(IN2, GPIO.OUT)

def dispense():
    # Spin motor forward for 0.8 seconds (adjust for your cup size)
    GPIO.output(IN1, GPIO.HIGH)
    GPIO.output(IN2, GPIO.LOW)
    time.sleep(0.8)
    GPIO.output(IN1, GPIO.LOW)
    GPIO.output(IN2, GPIO.LOW)

# Define [feeding times](https://www.amazon.com/s?k=feeding+times&tag=organizationtip101-20) (24‑hour format)
schedule = {
    "07:00": "morning",
    "12:00": "noon",
    "18:00": "evening"
}

try:
    while True:
        now = datetime.datetime.now().strftime("%H:%M")
        if now in schedule:
            print(f"Feeding {schedule[now]} at {now}")
            dispense()
            # Wait a minute so we don’t feed twice in the same minute
            time.sleep(60)
        time.sleep(10)
except KeyboardInterrupt:
    GPIO.cleanup()
```

Run it with `python3 feeder.py`. The script checks the clock every ten seconds and triggers the motor at the times you set. Adjust the `schedule` dictionary to match your dog’s routine.

If you want to add Wi‑Fi control and more precise portioning, the [DIY Smart Pet Feeder guide](/petfeederpro/diy-smart-pet-feeder-a-stepbystep-guide-to-building-a-wifi-controlled-feeder-for-precise-portion-control) shows how to integrate MQTT and a web dashboard.

### Running on Boot

To make the feeder start automatically after a power loss, add a line to `/etc/rc.local` before `exit 0`:

```
python3 /home/pi/feeder.py &
```

Now the Pi will launch the feeder script each time it boots.

## Testing and Tweaking

### Dry Run

Fill the hopper with a few kibble pieces and watch the motor dispense. If the portion is too big, shorten the `time.sleep(0.8)` in the `dispense()` function. Too small? Lengthen it a bit.

### Real‑World Test

Leave the feeder running for a day while you’re at work. Check the leftover kibble in the morning—if it’s consistent, you’ve nailed the timing. If Max seems hungry, add a second dispense call for that meal.

### Adding a LCD

If you want a visual cue, hook a 16×2 LCD to the Pi’s I2C pins (GPIO 2 and GPIO 3). A quick library like `lcd` lets you print “Next feed: 12:00” on the screen. It’s a nice touch for the tech‑curious [pet parent](https://www.amazon.com/s?k=pet+parent&tag=organizationtip101-20).

## Safety Tips

- **Secure the wiring.** Loose wires can short out and damage the Pi.
- **Use a fuse** on the motor’s power line to protect against overload.
- **Keep the hopper sealed** when you’re not feeding; pests love [dry kibble](https://www.amazon.com/s?k=dry+kibble&tag=organizationtip101-20).
- **Never leave the Pi unattended** if you’re testing new code. A stray command could spin the motor forever.

## Wrap‑Up

Building a smart feeder with a Raspberry Pi is a rewarding weekend project that saves you from juggling bowls and meetings. The core idea is simple: a tiny computer, a motor, and a bit of code. From there, you can add Wi‑Fi alerts, [voice control](https://www.amazon.com/s?k=voice+control&tag=organizationtip101-20), or even a camera to watch Max’s happy face as he eats.

I hope this guide gets you feeding on autopilot. When you see your dog wag his tail at the exact moment the motor clicks, you’ll know the effort was worth it.
