Posts: 33
Joined: Sun Dec 30, 2012 11:08 pm
Location: Midlands UK

RPi Cat feeder

Fri Mar 01, 2013 6:26 pm

Hi everyone,

Well since I received my rpi at Christmas I have been working on building a rpi cat feeder that I could use to feed my cat whist away or late home from work ( no cats were starved during this project).

With only every programming HTML, php, JavaScript and mysql I set out to learn Linux and python.

I am after a bit of help and also some input on what other features I could add.

So far I have :
-hosted a web page on my pi using apache2
- a webcam feed of the feeder and food bowl
- modified a motion activated sweet dispenser which is now activated by a python script from my web page with a motor driver controlling the pre existing motor in the sweet dispenser for a set duration
- all feed times and feeders name are stored in a MySQL dB and visible on the web page in feed history
- feed count stored to allow me to set a daily feed limit
- last feed time shown under webcam which updates using JavaScript once feed
- option to take a webcam screenshot and email to an inputted email address
- crontab running every 12 hours that emails me my external ip address so if I'm away from home and my adsl router decides to reboot I'm never left not being able to connect
- I have just brought an adafruit pir motion sensor. At the moment I have it connected to an input gpio. I would like this to trigger the email script above to send me a pic when the cat is at the bowl.

The last point is where I need some help if possible and your thoughts.
The pir sensor is going to be mounted on the front to detect the cat. The hurdle I can see is that it's going to be activated when the cat is feed as the food comes out just below the pir.
I thought maybe use sw to overcome this . Maybe something like using the pir/ email pic script to check the last feed time from MySQL and if the email script is activated within x number of seconds of the last feed then it escapes the script.
This is going to be a challenge for me as I'm rubbish at deducting times with scripts and also my feed motor is driven by python , the pir input gpio is monitored by python and my email script is php :?

Any contributions to my project would be appreciated. I don't want this project to come to an end and need more ideas.
The code & gpio pin parts have been tested separately so now I need to hard wire the motor to gpio and the pir sensor to the sweet dispenser.
I have brought 2 pcb mounted rj45 sockets. Was hoping I could fix one inside the sweet machine and use an rj45 cable to connect pi to sweet machine and mount another to a cobbler .

I'm using gnd, +5 and a trigger for the motor and the same for the pir so need six cables from pi to sweet machine. Not sure how good catv cable will take the 5v.

Any inputs appreciated. Thanks.

Posts: 6
Joined: Fri Jan 25, 2013 8:39 pm

Re: RPi Cat feeder

Sat Mar 02, 2013 8:00 am


why do it in sript?

why not just do it in sql something like

select case when your_sql_time > dateadd(ss,getdate(), - ?? secs) then 1 else 0 end as check_pir from your_table where your_sql_time = (select max(your_sql_time) from your_sql_table)

something like that

thenyou can just use 1 or 0 to stop the script


Posts: 11
Joined: Sun Jan 27, 2013 6:39 pm

Re: RPi Cat feeder

Sat Mar 02, 2013 8:53 pm


some Ideas for you:

You could use "motion" for your webcam and config it so, that it sends you an E-Mail, when the webcam-picture changes. No need for a motion sensor. You can also use for streaming your cam.

I build a machine for my dog, so he has to pull on a rope or push a putton, when a special sound rings. When he did a good job he gets a treat by the machine. It's very exciting for him.
Maybe something like that would be intersting for your catfeeding machine? I build this with an arduino but later also experimented to connect it to my pi and and controll it via web interface.

Edit: Ah, and you could use a dynDNS service, that you don't have to email you your ip-adress.

Posts: 33
Joined: Sun Dec 30, 2012 11:08 pm
Location: Midlands UK

Re: RPi Cat feeder

Sun Mar 03, 2013 5:47 pm

Hi ,

Thank you both for the help and ideas.

I have not ha much time on it the last few days but will take a look soon.

I will try this mysql idea.

I did try motion software when i first started the project but found it did a lot more than i initially needed that is why i went for mjpg-streamer.

I guess dogs are a little more intelligent than cats. Sounds a great idea. Did it take long for your dog to get the idea. I'm sure if I changed mine to make the cat press a button to get a treat he would be out the cat flap and away looking for an alternative dinner option.

Thanks again

User avatar
Posts: 24
Joined: Fri Oct 19, 2012 6:26 pm

Re: RPi Cat feeder

Fri Mar 15, 2013 10:39 am

Here's one I made earlier:
I used a small servo from a radio controlled helicopter = £3 and a cereal box. For the script I used some C, crontab and php for a web interface. Much fun but the wifi was too flakey :(

Posts: 4
Joined: Wed Mar 13, 2013 7:30 pm
Location: Cape Town, South Africa
Contact: Website

Re: RPi Cat feeder

Fri Mar 15, 2013 12:51 pm

Have you looked at SimpleCV? It runs nicely on RPi and you can do some really cool stuff with your exisitng Webcam feed like color and shape (there may be exisitng algorithms for cats) matching, overlays onto the cam feed etc quite easily. And it's in python.

I'm planning to use it on a robot to map rooms and recognise where it is by looking for familiar shapes. Finding faces and chasing people etc. Very exciting stuff. :D

User avatar
Posts: 24
Joined: Fri Oct 19, 2012 6:26 pm

Re: RPi Cat feeder

Fri Mar 15, 2013 12:57 pm

lol.. That makes me think of some kind of attack of the killer robots but with cats and pi's.. I'll check out SimpleCV, sounds like fun :)

Return to “Automation, sensing and robotics”