Monday, December 21, 2015

TreatMaster V-2 - Enhanced Remote Dog Treat Dispenser powered by Raspberry Pi

Introduction

This project was completed earlier in 2015, but I am only now blogging about it...I didn't want to wait till 2016 to get a post up!

I created TreatMaster V-2 during March 2015. It is a Remote Dog Treat Dispenser that you can control from your mobile phone. It is powered by Raspberry Pi. I wrote an iOS App for it as well. Read on if you wanna know more. If you want to see the demo, press play below. 


To watch a better quality video, please click here.


Inspiration

It all started with this post (Judd-Treat-Machine) that I saw online a few years back. It inspired me to start working on Raspberry Pi. What a nice idea to be able to give your dog a treat when he is all alone at home by himself, while you are out having a good time with your friends. A few days later, I bought myself my first Raspberry Pi Model B+ along with a bunch of components so I could start playing with it. 



I built the TreatMaster V-1 prototype (similar to Judd-Treat-Machine) earlier in 2015. The prototype was a bit ugly but it worked. They way it works was: 
  1. You send Mac an email (Yes, Mac has his personal Email) with the subject "Treat".
  2. The treat machine gets the email and will called out for Mac to get him all excited and come towards the machine. 
  3. The machine then dispense the treat, while Mac enjoys his treat, the web camera takes a photo of Mac and replies with a thank you email back to the sender. 
Pretty neat huh! It worked and I was having so much fun making it...Read up more if interested in looking at TreatMaster V-1. The end product looked like this.



After successfully creating that, I just couldn't get myself back to working on it again. 

Early this year, I completed the 2 player bartop Arcade Game Machine, and still with high momentum, I thought it will be a good time to build TreatMaster version 2. This time, I wanted to make it a lot better, where I would be able to see Mac live in action while he is taking the treat, and I want to be able to talk to Mac. So I begin to work. 

How do I start?

I tore down TreatMaster Version-1 to reuse some of the components. I did away with the web camera and got a Raspberry Pi Camera Board. The big chunky plastic container that I got from Walmart had to go. I went to Michael's and got a pretty good size box that I could modify to fit my use. I kept the relay circuit, motor, speaker and auger bit. I am pretty much good to go!

This is the TreatMaster V-2 Architecture:

Software 

Backend Service - RESTful API Server

Date: 11th April 2015, I installed 2015-02-16-raspbian-wheezy.img OS on Raspberry Pi.

Lets keep this high level, I won't go into much boring technical details. 

The first thing I focused on was software. I want to be able to remotely communicate with my raspberry pi that connects with the other hardware parts. What's better than running a RESTful API Server with Flask-RESTful that exposes APIs to control the raspberry pi. I wrote the API Services in Python, example of APIs are:
  • API to establish connection, once connected, security token is exchanged and all subsequent communication is done with the temporary token.
  • API to start/stop the video steaming. 
  • API to upload/play audio.
  • API to take photo.
  • API to dispense treats.



Note: The video streaming is actually recursive photos that kept refreshing on the webserver, it creates an illusion of video when you load it up on your browser. That was how old civilian cameras used to work (if I am not wrong).






Interested into more details? Here are the references to:

  • Install Audio
    • Command to bring up volumn configuration GUI: $ alsamizer
pi@raspberrypi ~ $ sudo apt-get install python-pip
    • After pip is installed, you can use it to install Flask and its dependencies:
pi@raspberrypi ~ $ sudo pip install flask

How does the machine dispense treats?

It uses an Auger Conveyor approach where a rotating helical screw blade moves granular materials, in this case...Mac's treat. This is the same item I used for my TreatMaster V-1. I used GPIO to trigger a relay switch that would rotate the blade for a specific duration to push some treats out of it's container.




Raspberry Pi has 17 GPIO pins (General Purpose Input / Output) that allows you to send Input or Output signal to the board. The pins are 3V3 and not 5V, they directly connected to the Broadcom chip. It has a good chance of frying your Pi if you send >3V down the pin.







This is the Relay Circuit that I used to control my Motor along with the components that I used.








Mobile App Client

Once I had all the API working, I started to design the app. I sketched it on a piece of paper before working on the User Interface. Here's my sketch.



I wrote the code in iOS since I have a MacBook and use an iPhone. Here are the progress and changes:

Initial development

Finally, I am satisfied with this version where it is clean and simple. 


Hardware

I am not a handy man for sure. This is the toughest part for me and took the most time. I tried my best to make it as neat as possible. But still, it could have been better. 



I measured it out and made a cardboard container just to see how it will turn out. It seems to fit well. So the idea is to put the small dog treats into the green container and the Auger bit will rotate and push the treat out. This part needs a bit more work at this moment, it is not working 100% smoothly as I wanted it to. Once I got the cardboard measurement right, I bought some cheap perspex and made a solid container.



The box I got from Michael's is slightly thin. It didn't look like it is able to hold my motor securely. As a result, I glued another piece of wood at the bottom so that it is lifted and thicker for me to screw and secure the motor. After that, more wood filler and sanding... and filler and sanding...


After about 10 times of wood filler and sanding.... I am finally satisfied with the result, so I start painting. I applied about 3 layers of white prime just to be sure (I know it is a bit over kill but I have way too much prime left), then I applied the paint that I have left over from the Arcade Machine. By this time...you would have thought I have master the skill of painting...I still struggle to get the paint spread evenly. I am blaming the paint brush for sure :)



So finally, after a few days of painting. I put all of them together and thought it could be better. With my skill and effort, I am satisfied with that. 



Mac got excited every time TreatMaster make a sound. He got a bit scared and unsure at first, but he is doing a lot better now and got used to this machine.

This is not the last of it. I do have plan to work on Version-3. I didn't really keep track of the cost since I am using the stuff that I already got but my guesstimate would be around $80. I could probably make it a lot cheaper. Who knows, I might be making this and selling it one of these days...

No comments:

Post a Comment