Skip to content

Raspberry Pi Python app for scheduled cat feeder

License

Notifications You must be signed in to change notification settings

rob-murray/cat-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cat-bot

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.

Getting started

Dependencies

  • Python 2.x
  • PIP
  • Virtualenv - manage Python environments
  • RPi.GPIO - to run on Raspberry Pi
$ mkvirtualenv cat_bot
//
$ workon cat_bot

Install dependencies via pip

$ pip install -r requirements.txt

Save installed dependencies to pip

$ pip freeze > requirements.txt

Configuration

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

Logging

Two logging configs suited for development and running on the Pi - logging-dev.yaml and logging-prod.yaml.

TODO: more logging info

Feed

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 format
  • minute - The minute of the day at which to feed
  • quantity - TODO The quantity of food to be served aka the servo rotation time in secs

Observers

An observer will get notified when the events below occur and can do something on either if required.

  • startup - When application starts
  • heartbeat - For each internal tick or heartbeat
  • feeding - 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.

Running

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

About

Raspberry Pi Python app for scheduled cat feeder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published