An IoT Pet Treat Dispenser Using the Arduino Nano RP2040

by mikerobertgodfrey in Circuits > Arduino

2726 Views, 16 Favorites, 0 Comments

An IoT Pet Treat Dispenser Using the Arduino Nano RP2040

Building an IoT Pet Treat Dispenser

Project inspiration

One of our friends recently adopted a senior dog called Jelly who suffers from separation anxiety. To help with training him when he needs to be left on his own, they asked us to make a wireless treat dispenser to go with the pet camera they already own. In the video, we demonstrate the principle with the help of Timothy, our rabbit.


Overall design

This treat dispenser is designed to hang from a wall hook and is controlled wirelessly over WiFi, via an app on the user's phone. There are 8 slots for treats, dispensed using a servo. These compartments might be large enough to hold food for a couple of days for smaller pets, such as hamsters or fish, especially with modifications. However, for our purpose, we only wanted to hold a few small dog treats.


Instructable notes

The physical design of this project was based around materials we had left over from other projects. As such, the materials, dimensions, and manufacturing methods are explained as a rough guide rather than a comprehensive tutorial.

Supplies

Materials:

  • Assorted wood offcuts
  • Arduino Nano RP2040
  • Standard servo
  • MicroUSB cable
  • A5 Perspex sheet
  • Brass wire
  • Screws

Equipment:

  • Scroll saw
  • Sander
  • Lathe
  • Drill
  • Clamps
  • Wood glue
  • Steam bender
  • Computer
  • Soldering iron
  • Assorted hand tools (chisels, planes, screwdrivers etc.)

Making the Treat Compartments

Scroll saw rectangles.jpg
Planing.jpg
P9040174.JPG
Sanding disc.jpg
Sawing disc.jpg
Servo horn.jpg
Clamping fan.jpg
Mini steam bend.jpg

We cut the rectangular compartment dividers and a backing semicircle from thin plywood using a scroll saw, then trimmed them down using a hand plane and disc sander.

The central semicircle was marked out using a compass and cut out with the scroll saw. The radial notches were cut using a dovetail saw, just wide enough to fit the dividers. The servo horn was screwed onto the underside of this fan-shaped piece.

The inner wall was steam-bent from cherry, using a custom rig.

All of the parts were then assembled using clamps and wood glue.

Making the Base

P9040331.JPG
Big steam bend.jpg
P9040341.JPG
Nano slot.jpg

We used a rectangular block of oak for the back plate. We also cut a curved block for mounting the side guard, which prevents treats from falling out of the feeder. As before, the curved wall was steam-bent. These curved parts were glued together, then screwed onto the back plate.

Appropriate holes were cut in the back plate for fitting the Arduino and servo, using a combination of saws and chisels.

We used Danish oil to finish the wood.

Making the Front Screen

Machining pin.jpg
Drill screen.jpg
Machining handle.jpg
P9040303.JPG

The front screen is a roughly A5 sheet of clear perspex. This screen is mounted to the back plate using a custom hinge post, which we machined on a Myford lathe.

The handle was shaped on a smaller lathe using a half-round file.

Making the Mounting Bracket

Twist brass.jpg
Soldering brass.jpg
P9040332.JPG

We formed the mounting bracket from a piece of brass wire. We twisted the ends using a pair of round nose pliers, then soldered the loops for additional durability. The loops were then screwed into the back of the base plate.

Setting Up the Arduino

P9040307.JPG
P9040317.JPG
Soldering.jpg
Setting variables.jpg
Arrange widgets.jpg
Script.jpg

Arduino wiring:

The circuit in this project is very simple - connect the servo wires as follows:

  • Red = Vin
  • Brown/Black = GND
  • Yellow/White = D9

In our case, we soldered these through to the Arduino via a piece of stripboard.


On your computer:

Create an Arduino IoT Cloud account at https://create.arduino.cc/iot/ 

Create a new “Thing”.


In the Setup tab: 

Create the following 4 Cloud Variables:

  • bool drop_treat - Read & Write - On Change
  • int position - Read & Write - On Change
  • CloudColoredLight rgb_light - Read & Write - On Change
  • int treats_left - Read Only - On Change

Attach the Arduino Nano RP2040. If you haven’t used Arduino IoT Cloud before, you’ll need to follow the instructions to install the Create Agent software.

Set up your WiFi Name & Password.


In the Sketch tab:

Copy the script from https://github.com/ChronovaEngineering/NanoRP2040_Pet_Feeder/blob/main/IoTCloud_Sketch

Paste this into the script editor, replacing any existing code, then click on the tick icon in the top left to verify the script.


In the Dashboards tab:

Create a new dashboard & name it.

Check that you’re in edit mode (top left).

Click the Add button, then “Widgets” and create each of the following widgets, with the associated variable:

  • Push Button: drop_treat 
  • Slider: position (Value range: Min = 0, Max = 180)
  • Colored light: rgb_light
  • Gauge: treats_left (Value range: Min = 0, Max = 8)
  • [Optional] Sticky note for instructions

Rearrange the widgets as desired.


In Things -> Pet feeder -> Sketch:

Plug the Arduino Nano RP2040 Connect into your computer USB port and click the Upload button.


Feed Your Pet!

Press button.jpg
Timmo in petal rain.jpg
Timmo wow 2.jpg
P9040398.JPG

Installation:

Hang the treat dispenser in an appropriate location for dropping treats for your pet. Connect the Arduino to a power source using a MicroUSB cable.


On your phone or tablet:

Download the Arduino IoT Remote app & sign in to your account.

Open the Nano Pet Feeder Dashboard and test that each widget is working as expected.


How to use:

Press the "Drop treat" button to dispense a treat.

If a treat gets stuck, you can use the "Servo position" slider to manually rotate the servo.

The RGB light widget can be useful for debugging connection issues. It will change the colour of the LED on the Arduino to match whatever colour you select on the colour picker.


Test it out:

Find your nearest willing (hungry) volunteer and give it a go! In our case, our rabbit, Timmo, was our eager test subject, so we filled the device with petal forage mix and other rabbit-safe treats. Watch our video on YouTube to see it in action: https://youtu.be/oYoICSDV7eg