Monday, December 21, 2015

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


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.


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:


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. 


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 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...

TreatMaster V-1 - Remote Dog Treat Dispenser powered by Raspberry Pi


I designed a Treat Machine (TreatMaster V-1) between March to May, 2013. It is a Remote Dog Treat Dispenser that you allows you to trigger it via email. It is powered by Raspberry Pi. Read on if you wanna know more. I also made an upgraded version TreatMaster V-2. It is a lot more polished and allows you to control remotely through an iPhone App. Go here for more about TreatMaster2.


It started from reading online that there is a gadget that runs a full unix operating system. It is basically a complete computer at the size of a deck of playing cards. It is called the Raspberry Pi. It caught my attention with the potential, and being so small and neat. I had to have one to play around with. I bought it from Adafruit along with some electronic start up kits. As soon as I got it, I wasted no time to try it out. It was pretty simple to setup, and I was having fun playing around with it for the next 2 weeks. 

I was trying to think about what I could make, and came across this post (Judd-Treat-Machine). It was pretty straight forward and I thought it would be something that I could make for my dog. So I started work to build a Treat Machine for my tiny 4 legged buddy "Mac".


I used the code from the link above as a starting point. Python was rather new to me but it was not that bad, it just took some time to get used to the syntax and stuff.... but I figured it out after all. I added a few more features and security into the script. So basically:
  1. It polls Mac's Gmail to look for new email. 
  2. If a valid email is intended to give Mac a treat, it will
    • Play a recorded Audio to get Mac's attention.
    • Dispense some treats for Mac.
    • Take a photo of Mac while he is enjoying his treats.
    • Send the photo back to the sender who gave a treat to Mac.
  3. I also added a few other security features, like:
    1. No treat is allowed during night time. It will resume and give Mac a treat in the morning.
    2. Limited treat are allowed during the day. I didn't want Mac to have any health issues :).
    3. Limited treats are allowed by the same user, I didn't wanna get email spam.
This is an email example of response that you get after Mac gets his treat. You get a thank you email from Mac along with a photo of him eating the treat.


This part is slightly different from the Judd-Machine. I can't really do what he did. After some research, I decided to go with Auger Conveyor approach. It is a mechanism that uses a rotating helical screw blade that allows you to move granular materials. All I needed was a big enough Auger Bit that fit the size of Mac's treat and a high torque low RPM motor. 

This may have been overkill, but I found a really high torque 6RPM gearhead motor (12V DC) for $18.95 from eBay. It is so strong that I can't stop the rotation with my fingers.


Auger bit for $12 from HomeDepot.

At this point, I was glad that I studied 2 years of Electrical Engineering. At the least I know how to look at circuits and play with breadboard and components. I was surprised how much I remembered from my school days, and that I was able to put it to good use again!

I was playing with the GPIO (general purpose input/output) for the past few days and have a pretty good idea how to use them. The motor runs with 12V but the GPIO produces only 5V, so I needed a way to run a motor with a switch. I started to look at the relay switch circuit. I bought all the components from Fry's and hooked it up. It worked just fine. 

Once everything was tested working, It was time to solder it into the board. It could have been done a little more professionally but I was pretty happy with the end result. 

I took a container from a Dollar Store and converted it into my treat dispenser container. 

All of that looked very clunky but it did its job. It was pushing out treats, and I was able to program it to dispense a full meal. Mac was enjoying his treats while I was testing it. It was funny to see Mac as initially he was scared of the motor's sound, but after seeing what he would get, he got so excited. As soon as the motor started, he was right in front of the treat machine hoping that something dropped. The flaw of this machine is that I can't really control the consistent amount of treats to be dispensed. Sometime it has a few dispensed but occasionally it has none. Poor dog.


Finally, I found a cheap container rack and stuck everything in to it. and it looked like this:

So I really had a lot of fun making this, and learnt a few things along the way. Unfortunately, I didn't proceed to make the updated version until 2 years later :). Please check out my TreatMaster V-2. It is way smarter than this.

Monday, June 8, 2015

JMeter Dashboard - Realtime monitoring of your JMeter load test.

Date: 06/05/2015

JMeter is a great tool! I used it as a load testing tool for analyzing and measuring the performance of our web application & RESTful APIs. I replaced the "LoadRunner tool" from HP with JMeter, as it was much more cost effective. Since we were the only people in the company to use LoadRunner, it didn't make sense to keep it around.

Of course, commercial products have their values, but for the amount of testing that we do, JMeter is more than sufficient and most importantly... it is FREE!

One of the nice features in LoadRunner is the ability to see a real-time report. It gives you an early indication on how your tests are doing. Based on that information, you may choose to stop it or proceed with it. This is something that you don't quite get in JMeter. Yeah... yeah.... they have listeners.... But listeners are heavy consumers of resources. Each report require a different listener, you might easily end up with multiple listeners in your test plan. It helps when you just try to do basic testing and debugging, but doesn't work well in heavy load. I kept hitting out of resource error when I tried to load tests for a longer period of time even with only 1 listener. I don't know about you... but I also feel that JMeter reports are unattractive. All that said... it is still FREE.

So I was looking for tools that would give me an instantaneous result but I couldn't find any. The closest is from a company called "Blazemeter", where they help to run JMeter scripts from their cloud servers. They have pretty nice real-time reports. They also created an open source tool called "Taurus" which consolidates and automates your JMeter script testing, but I haven't had a chance to work on that yet.

All the tools I found either generate the reports after you have completed the test (example: from "" - acquired by Blazemeter recently) or require you to pay for it (example: Blazemeter). Being the cheapskate that I am, I tried to create it myself. It is not the best thing on earth, but it is definitely a good start.

I called it "JMeterDashboard: Mac-Monitor" (Mac is my dog, I use his name everywhere since I can :) ). This tool is a Windows-based application created with WPF Framework C#.Net. I am using the WPF Toolkit, mainly chartingToolkit. It reads the 'jtl' file while your JMeter Scripts are running, and produces reports. There are some limitations on using the free toolkit for chart creating, but it does the job.

I am putting it in Github so you may download it and use it. Please refer to the Disclaimers, I am sure there are still plenty of bugs in there but hopefully you may be able to help contribute to it. You will have access to all the code and able to see how I calculate the reports. There are many approaches that you can take to analyze your tests and I hope to get some feedb ack from this.

Here are some screen shots:
Real-time monitoring

Summary Report

Saturday, March 14, 2015

Mac-Man Arcade: 6. 03/14/2015 - The Pi Day

Finally - 03/14/2015
The Pi day, I put everything together. Anyway...It is just a coincidence that it was Pi day, I am not that nerdy.

Ready for assembly:

It looked great! It shouldn't take that long to complete, I was a bit slack in finishing this project, but today...I call it done. "2 Player Bartop Arcade Machine powered by Raspberry Pi".

Finished product:

It does bring back great childhood memories. Not sure how long my excitement will last, I give it 2 weeks :)

Until the next project. will probably write something on my previous projects.

Related Posts for 2 Player Bartop Arcade Machine:

Getting Started
My Arcade Cabinet
Mac-Man / Machinko (Marquee Artwork)
03/14/2015 - The Pi Day

Saturday, February 28, 2015

Mac-Man Arcade: 5. Mac-Man / Machinko (Marquee Artwork)

Marquee Artwork

This is the part that you can incorporate some of your creativity. Shane and I came up with the overall concept and Shane helped to put the concept into the artwork. It was done to scale professionally using Adobe Illustrator.


We wanted to put Mac in there somewhere and we did, I think it looked great. I found online and they seemed to be able to print it cheaply. We chose the backlit-glossy finished. It ends up the shipping is more expensive than the actual artwork! For the size of it, 18"w 11"h, we made 2 different Marquee artworks. One of it called "Mac-Man" originated from the classic "Pac-Man" and the other one has a bit more Japanese Pachinko influence called "Machinko". The Top Gun inspired concept didn't make the cut.

Finished Artwork ready for printing:

I used 2 pieces of custom cut perspex to sandwich the printed artwork so that I can interchange them easily without any glue. I used an L shape bracket to hold them together, painted it black and it looked great. Ends up, don't really need 2 Perspex. 1 is good enough to hold it as the printing was able to hold up by itself.

We printed it ourself just to see how it looks on the arcade machine.

Thursday, January 22, 2015

Mac-Man Arcade: 4. My Arcade Cabinet

My Arcade Cabinet

This is the part that I was not very confident in doing. I don't have a wood working bone in my body. My unskilled hands refused to work with my mind. I suffered from blisters and cuts throughout this part of the project but I got through it eventually. Also, I don't have a workshop, so everything was done on the living room floor!

I bought my Arcade Cabinet kit from eBay. It was plywood and was pretty rough around the edges and relatively heavy. It was so far the cheapest that I saw for the size that I liked.

It required a lot of sanding. As I previously mentioned, the pre-drilled holes didn't fit the push buttons that I bought. I wasn't sure it was meant for a different size of buttons. I had to buy a hole-saw to enlarge the existing hole. It did burr the edges a bit but I was able to save the surface by using some wood filler. Also the side holes were too close to the Joystick Control Panel. It just didn't fit well and I had to give up the side buttons on the Arcade Cabinet.

It wasn't as bad as I thought... just need to measure things correctly and everything turned out pretty well. The wood filler really works well in filling up holes and dents. After that, more sanding....

I used Veneer Edging to cover up the plywood edges. It was pretty straight forward. All I needed was to use a hot iron to iron it in. The hot iron melted the glue on the back of the veneer and stuck it to the plywood. It is not the perfect solution but was a cheap way to do it. I would have liked the colorful T-Molding plastic trim where it gives it a cool finish, but that would have required routing a groove, which was more tools and skill than I have! I trimmed off the excess Veneer Edging and then use more wood filler and more sanding. It looked great after that.

Painting: 2 layers of primer, followed by many layers of actual paint. It takes a while to dry.

Related Posts for 2 Player Bartop Arcade Machine:

Getting Started
My Arcade Cabinet
Mac-Man / Machinko (Marquee Artwork)
03/14/2015 - The Pi Day