Eric Ditter.com

Pet Feeder

A simple python class that controls a petfeeder. Features include:

See the full writeup at Hackster.io

If you want to use Alexa app or view data via the web site sign up here https://onlineservicehub.azurewebsites.net/ (beta)

https://github.com/editter/PetFeeder/

TOKEN = "<Token>"
DEVICE_ID = "<Device-Id>"
DEVICE_KEY = "<Device-Key>"
FEEDER = PetFeeder(TOKEN,
           {"SERVO": 18,
            "BUTTON": 19,
            "DISTANCE_IN": 23,
            "DISTANCE_OUT": 24})

FEEDER.init_schedule()
FEEDER.init_listener(DEVICE_ID, DEVICE_KEY)
FEEDER.loop_forever()

API

__init__

Default constructor

get_config

Gets the current configuration information

path

Folder relative to running directory

run_servo

Runs a servo for a specified amount of time

Time the servo will run (default) = 5

check_dish

Check”s how full the dish is. Comparison is done by looking at config[“FULL_DISH_IMAGE”] and config[“COMPARE_DISH_IMAGE”]

Returns - number Percent of how full the dish is

update_hopper

Check the hoppers current percent full

Returns - number Percent of how full the hopper is

update_server

Sends an update to the server

Arguments that will be passed to the server

Image of the dish that will be uploaded

receive_message_callback

Callback from IOT Hub event trigger

JSON string containing command instructions

Time the servo will run (default) = 5

init_listener

Initiates a connection to receive messages from the web site

Device Id that was created via the web site sign up

Device Key that was created via the web site sign up

init_schedule

Initiates a the schedule that the feeder will automatically feed

run_events

Check if anything is happening such as button presses, schedules, etc. and run those features

loop_forever

Will keep the application running indefinately and call run_events()