Skip to content

Theoklitos/chestfreezer

Repository files navigation

Chestfreezer

screenshot

A small python web application that is meant to be run in a raspberry-pi connected to a beer brewing system. This requires a raspberry with have 1 to 10 DS18B20 temperature sensor(s) and 2 relays connected to the GPIO pins. A rough guide on how this system was built can be found in my blog.

Overview

Two devices should be connected to the relays: A "heater" and a "freezer". This way our raspberry-pi becomes a thermostat. Temperatures are measured from the sensors, and target temperatures can be set by the user. The two relay devices can also be controlled directly.

The basic mechanism is the "instruction". An instruction is basically a desired temperature along two timestamps (start, end) that define the time interval in which we wish this temperature to be maintained.

Temperature Algorithm

The idea is to turn on the freezer if its warm, or turn on the cooler if its hot, with half a degrees as a buffer.

API

There are several resources one can call directly, values can be given either as a form or in JSON format:

  • GET /chestfrezer/api/temperature, in order to get all the readings so far. Query parameters start and end as unit timestamps can specify a range of readings.

  • GET /chestfrezer/api/temperature/target, for information about the current target temperature that is attempted to be maintained.

  • POST /chestfrezer/api/temperature/target in order to set a temperature directly (also referred to as an override).

  • GET /chestfrezer/api/instruction, to get all the instructions. Instructions can also be time filtered by a start and end timestamp query parameters. You can also use a now query parameter to get the active one.

  • POST /chestfrezer/api/instruction, to create a new instruction.

  • PUT /chestfrezer/api/instruction/{id}, to update an existing instruction, and

  • DELETE /chestfrezer/api/instruction/{id}, to delete it.

  • GET /chestfrezer/api/temperature/probe, to get all the existing temperature sensors. A temp. sensor has an unique hardware-bound ID and a settable name, and also a "master" boolean value that determines which is the probe that defines the actual tempetarure.

  • PUT /chestfrezer/api/temperature/probe/{id}, to modify an existing probe's data.

  • GET /chestfrezer/api/temperature/device, to get the state of the freezer and the cooler.

  • POST /chestfrezer/api/temperature/device/{device_name} in order to switch the freezer or cooler on/off.

  • GET /chestfreezer/api/beer, to get a list of all the beers.

  • POST /chestfreezer/api/beer, to create a new beer - only the name is required.

  • PUT /chestfreezer/api/beer{id}, to modify the beer with the given id.

Access control is a single username/password in the config file that is matched to the Basic auth header.

Frontend

A small javascript single page app that uses requirejs, bootstrap and handlebars and some canvasjs graphs polls the server for temperature updates and also controls the devices. One can compile/minify all the javascript with r.js, by the command

node r.js -o build.js
This will generate the chestfreezer-built.js file which is significantly smaller and faster to run.

Configuration

Start the script with bin/chestfreezer.py. A sample 'configuration' file is included with all the options. Also, there exist some development-handy CL parameters:

  • 'skip-gpio-test', to skip the relay on/off test
  • 'drop', to drop (and re-create) all the DB tables at startup
  • 'insert-test-data', to insert many dummy temperature sensor readings in the database.

About

Controller app for a raspberry connected to a beer brewing system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published