/kibble-bot

A 3D printed kibble/treat dispenser powered by a Raspberry Pi Pico. Give your pet a treat even if you're not home!

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

KibbleBot

A 3D printed kibble/treat dispenser powered by a Raspberry Pi Pico. Give your pet a treat even if you're not home!

Update 2024-04-10: Added a new version of the model which allows KibbleBot to be mounted to a wall and the hopper is now attached more securely using screws.

Features

  • Kibbles dispensed through the push of a button or remotely through a web app
  • Easy to print and build
  • Minimal electronics
  • Happy puppers

Build Instructions

Parts List

Before you get started, here are all the things you'll need to buy to build your very own KibbleBot. For reference I've included links to the products I purchased:

  1. Raspberry Pi Pico W
  2. Easy Driver Stepper Motor Controller
  3. NEMA 17 Stepper Motor (12V and 350mA)
  4. 12V Power Supply (I use one I had laying around)
  5. M2x5mm Screws
  6. M3x6mm Screws
  7. M3 Flat Washer
  8. M2x4mm Heat Set Nuts (3.2mm outer diameter)
  9. M3x4mm Heat Set Nuts (4.2mm outer diameter)
  10. 6x6x4.3mm TACT Switch Push Button
  11. 12V DC Barrel Connector (11mm outer diameter)
  12. Solder and wire
  13. Heat shrink tube
  14. Heat sinks (optional, but the Easy Driver can get pretty hot)

3D Printed Parts

Print all parts with 0.2mm layer height and 15% infill. I recommend printing both gears with 4 wall loops for some added strength.

I've included Bambu Studio Project file with all parts laid out on two build plates and configured.

Model Image Details
Base Bottom Rendering of the Base Bottom Base of the KibbleBot which the Base Top and Hopper rest on. It has two holes for each gear to rest in and a third for running the stepper motor wire through. It also contains the chute that kibbles come out of and the cut out for the electronics drawer on the side. Can be wall mounted using the holes on the back.

Print Orientation: Right side up
Quantity: 1
Supports: Yes
Base Top Rendering of the Base Top The Base Top sits inside the Base Bottom covering both gears. It has mounting holes in a 31mm pattern to mount the NEMA 17 stepper motor. You may need to drill out the holes with a small drill bit in order to fit the screws in.

Print Orientation: Side up down
Quantity: 1
Supports: No
Large Gear Wheel Rendering of the Large Gear Wheel The Large Gear Wheel is spun 180 degrees by the Small Gear Wheel allowing kibbles to fall through it and down the chute in the base bottom. It also has two holes for the optional Stir Sticks if you find that kibbles are getting stuck in the Hopper.

Print Orientation: Side up down
Quantity: 1
Supports: No
Small Gear Wheel Rendering of the Small Gear Wheel The Small Gear Wheel is connected to the stepper motor and turns the Large Gear Wheel.

Print Orientation: Side up down
Quantity: 1
Supports: No
Stir Stick (optional) Rendering of the Stir Stick Slots into the top of the Large Gear Wheel and can help with kibbles getting stuck in the Hopper and not flowing through.

Print Orientation: Vertical
Quantity: 2
Supports: Yes (brim)
Hopper Rendering of the Hopper The Hopper sits on top of the Base Bottom and holds kibbles to be dispensed. Contains a cut out so that it will fit over the stepper motor.

Print Orientation: Up side down
Quantity: 1
Supports: No
Lid Rendering of the Lid Sits on top of the Hopper to close it off.

Print Orientation: Up side down
Quantity: 1
Supports: No
Electronics Housing Rendering of the Electronics Housing Houses the Raspberry Pi Pico and the Easy Driver with four holes for the M2 heat set nuts to mount both boards. Also has cut outs for the barrel connector to pass through and to mount the button.

Print Orientation: Right side up
Quantity: 1
Supports: Yes
Key Cap Rendering of the Key Cap The Key Cap is glued on top of the TACT Button and fits inside of a recessed compartment in the Electronics Housing.

Print Orientation: Up side down
Quantity: 1
Supports: No

Assembly

Begin by setting the M3 heat set nuts into the three tabs in the Base Bottom which will hold the hopper in place.

Mount the stepper motor to the Base Top. Pass the ribbon cable through the holes in the Base Top and Base Bottom into the electronics drawer.

Then, assemble the rest of the 3D printed parts like so:

KibbleBot Exploded View

Screw three M3x6mm screws with flat washers through the holes in the Hopper to securely attach it to the Base Bottom.

Electronics

Since the Pico uses 3.3V logic, the first thing you should do is switch the Easy Driver to use 3.3V logic as well by soldering SJ2 closed (placing a small glob of solder on the two pads on the bottom left hand corner of the board where it's written "5V/3V"). You can confirm you've done this correctly by measuring the voltage across the +5V Output and GND, which should now be 3.3V.

Next, wire the Easy Driver to the Pico as follows:

  1. DIR -> GP15
  2. STEP -> GP14
  3. GND -> GND (Pin 18)
  4. SLP -> GP13

Connect one side of the TACT Button to GP10 and the other to ground (Pin 13). I used a little bit of CA glue on the back of the button to glue it to the electronics housing, as well as some glue on the back of the keycap to glue it to the TACT Button.

The Easy Driver has a 5V (3.3V) output which I'm taking advantage of to power the Pico. Wire the 5V (now 3.3V) output on the Easy Driver to VSYS on the Pico, and GND to GND.

Set the heat set nuts into their holes in the bottom of the housing, and mount both boards using the M2 screws.

Plug in your stepper motor, connect your 12V power supply to PWR IN on the Easy Driver, and you should be all set with the electronics!

Note: I've opted to solder headers to each board and make the connections using jumper wires. That being said, it's important to make sure the PWR IN and stepper motor connections are solid or you risk blowing up the Easy Driver. Always power off the Easy Driver before plugging/unplugging the stepper motor!

KibbleBot wiring diagram

Code

The KibbleBot software for the Pico is written in Micropython. Follow the instructions here to flash Micropython onto your board.

I also recommend setting up a Visual Studio project and installing the MicroPico extension to copy the code to the board.

You'll also need to have NodeJS and npm set up on your machine in order to build the web app.

main.py

This is the Micropython code which runs on the Pico and interfaces with the Easy Driver to turn the stepper motor and dispense kibbles. It first connects to WiFi and then listens for button presses and has a simple web server to listen for web requests.

To run the code on your Pico, first edit main.py and set the WiFi SSID and password. Then connect your Pico to your computer, and wait for VSCode to show "Pico Connected" in the bottom toolbar. Then right click on main.py and click "Upload current file to Pico".

Web App

I've created a simple Svelte app which main.py serves up and allows kibbles to be dispensed from a web browser. The web app is built into a single HTML file to make it easy for the Micropython code to serve up.

You'll need to build the web application and copy the resulting index.html to the Pico:

  1. Open up a terminal and set the working directory to /web
  2. Run npm install
  3. Run npm run build
  4. Open the resulting /web/dist/index.html file
  5. Right click on it and click "Upload current file to Pico"

In VSCode, click "Toggle Pico-W-FS" in the bottom toolbar. The "Pico (W) Remote Workspace" view should now show two files: main.py and index.html.

Screenshot of the Pico W FS view

With both files copied to your Pico, you're good to go! Unplug it from your computer and power everything up with the 12V supply. When the Pico shows a solid green LED it means it's connected to WiFi and ready to go. Navigate to the Pico's IP address in your browser and click "Dispense"!

Accessing KibbleBot remotely

If your home router supports running a VPN server, this is likely your easiest option for accessing the KibbleBot when not at home. Simply connect your phone/laptop to the VPN and browse to the local IP address of the Pico.

Another option is a Cloudflare Zero-Trust tunnel, but this requires you to run the Cloudflare client on another machine that's always powered on.

In my set up I've opted to use a Cloudflare tunnel as I already have the Cloudflare client running on my home server and several tunnels configured. This set up enables me to share the URL with friends and family so they can dispense kibbles too. I've included the Micropython code that I use (main_rate_limiting.py) which keeps track of the number of kibbles each user has dispensed and limits them to once per week.