An automated pet feeder powered by a Raspberry Pi. Schedule feedings, control portion sizes, and monitor activity through a web interface — all running on your local network.
- Schedule feeding times with configurable portion sizes (small, medium, large)
- Optional schedule randomization (±30 min) to mimic natural feeding patterns
- Web interface for managing schedules, triggering manual feedings, and viewing activity history
- Stepper motor control (DRV8825) with anti-jam agitation
- Simulation mode for development without hardware
- Systemd service for reliable, always-on operation
- Automatic daily schedule regeneration with fresh randomization
- Raspberry Pi (tested on Pi 3/4/5)
- DRV8825 stepper motor driver
- NEMA 17 stepper motor (or similar)
- Food hopper and dispensing mechanism
| Function | GPIO Pin |
|---|---|
| Direction | 13 |
| Step | 19 |
| Enable | 12 |
| Mode 1 | 16 |
| Mode 2 | 17 |
| Mode 3 | 20 |
-
Clone the repository on your Mac/PC:
git clone https://github.com/your-username/PetFeedr.git cd PetFeedr -
Configure the deploy script for your Pi (defaults shown):
export PI_HOST="pi@petfeedr.local" # your Pi user@hostname export PI_PATH="/home/pi/PetFeedr" # install path on Pi
-
Deploy to your Pi:
./deploy.sh
-
SSH into your Pi and run the one-time setup:
ssh pi@your-pi.local cd ~/PetFeedr ./setup-pi.sh
-
Access the web interface at
http://your-pi.local:5000
After making code changes, run:
./deploy.shThis will back up the current Pi installation, sync changed files, update dependencies, and restart the service. Backups are stored locally (last 10 kept).
For local development without a Pi:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 PetFeedr.pySimulation mode is enabled automatically when RPi.GPIO is not available. You can also force it:
PETFEEDR_SIMULATE=true python3 PetFeedr.pyIn simulation mode, no GPIO/hardware is touched — motor movements are logged but not executed, and the web interface works normally.
| Variable | Default | Description |
|---|---|---|
PI_HOST |
pi@petfeedr.local |
SSH target for deploy script |
PI_PATH |
/home/pi/PetFeedr |
Install path on Pi |
BACKUP_DIR |
$HOME/PetFeedr-backups |
Local backup directory |
PETFEEDR_PORT |
5000 |
Web interface port |
PETFEEDR_SIMULATE |
false |
Force simulation mode |
FLASK_SECRET_KEY |
(random) | Flask session secret key |
FLASK_DEBUG |
false |
Enable Flask debug mode |
If you prefer manual setup on the Pi:
-
Copy files to your Pi
-
Create a virtual environment:
cd ~/PetFeedr python3 -m venv venv source venv/bin/activate pip install -r requirements-pi.txt
-
Create the systemd service:
sudo nano /etc/systemd/system/petfeedr.service
[Unit] Description=PetFeedr Service After=multi-user.target [Service] Type=simple User=<your-user> WorkingDirectory=/home/<your-user>/PetFeedr ExecStart=/bin/bash -c 'source /home/<your-user>/PetFeedr/venv/bin/activate && python /home/<your-user>/PetFeedr/PetFeedr.py' Restart=always [Install] WantedBy=multi-user.target
-
Enable and start:
sudo systemctl daemon-reload sudo systemctl enable petfeedr.service sudo systemctl start petfeedr.service
- Access the web interface at
http://localhost:5000(orhttp://<pi-hostname>:5000) - Add feeding schedules with time, portion size, and optional randomization
- Use the manual feed button for on-demand feedings
- View recent activity in the feeding log
The web interface has no authentication and listens on all network interfaces (0.0.0.0). This is designed for use on a trusted local network. Do not expose it to the public internet without adding authentication and HTTPS.
sudo systemctl status petfeedr.service # Check status
sudo systemctl restart petfeedr.service # Restart
sudo journalctl -u petfeedr.service -f # View logsCopyright 2024 Jason Marsh
Licensed under the Apache License, Version 2.0. See LICENSE for details.