Raspberry Pi Python app for scheduled 😸 cat feeder 😸
This is designed for Raspberry Pi with the hardware below available via its GPIO;
- Continuous rotation servo
- Piezo buzzer
- LED
- Button
The physical setup could be something like a food dispsenser releasing dry food through a funnel with rate of dispersal controlled by a paddle which is then connected to the servo. For example:
+ +
| |
| |
| |
| |
| |
| |
| |
X XX
XXX XX
XX XX
+
+---+
+ + +
| |
+----------------+
The continuous rotation servo rotates for a given length of time to deliver a determined amount of food into a bowl below.
It supports multiple feeds per day at specified times or at ad-hoc intevals via the attached button however, you cannot feed the cat more than the permitted number of times per day. When a feed is triggered a buzzer will be sounded to inform the cat and induce regular behaviour of associating the buzzer with feeding time.
- Python 2.x
- PIP
- Virtualenv - manage Python environments
- RPi.GPIO - to run on Raspberry Pi
$ mkvirtualenv cat_bot
//
$ workon cat_bot
$ pip install -r requirements.txt
$ pip freeze > requirements.txt
Configuration manifests are in config
directory. There are the following options available:
logging_config
- Path to the logging configuration (see below)io_adapter
- The classname of IO adapter. Supports {LoggingIO|RaspberryPi} - LoggingIO can be used for dev testing where there is no GPIO.feeds
- An array ofFeed
objects (see below)observers
- An array of objects to be configured as observers of cat_bot state change (See below)
The configuration file used can be set by the APP_ENV
Environment variable, this supports the following values {development|production}. The default is development
if not provided.
Two logging configs suited for development and running on the Pi - logging-dev.yaml
and logging-prod.yaml
.
TODO: more logging info
A Feed
is a meal for the cat. There can be many per day and given times, you cannot feed the cat more than the permitted number of feeds.
A Feed
can be configured with the following properites:
name
- The name of the feed, eg "morning"hour
- The hour of the day at which to feed in 24 hour formatminute
- The minute of the day at which to feedquantity
- TODO The quantity of food to be served aka the servo rotation time in secs
An observer will get notified when the events below occur and can do something on either if required.
startup
- When application startsheartbeat
- For each internal tick or heartbeatfeeding
- When a feed occurs
Each observer in configuration should specify what it needs to be instantiated (eg Api key), the configuration will build this. The observer class should just respond to the notify
method with the single argument of event
. This will method will be called when the event occurs in a non-main thread.
With a valid configuration both of connected GPIO devices and internal configuration the application can be run by executing the wrapper in the bin/
folder:
$ bin/cat_bot
# or
$ APP_ENV=production bin/cat_bot