I make mistakes, very often. Build this on your own risk.
NOTE NOTE NOTE: If you do a "git pull" 2018-05-04 or later, on a system that has been installed before, you will have to run "./setup.sh" again, to resolve the new dependencies of the migration from the Slim2 to Slim3 php framework.
#--- upgrade from Slim2 to Slim3
cd ~/rpi-sous-vide
rm -rf vendor
./setup.sh
rpi-sous-vide is a Raspberry pi based PID controller for a home built sous vide machinery, a home built smoker (to smoke meat, fish, etc), a greenhouse, or anything else that you need to control depending on the current temperature, and a setpoint temperature that you wish to reach. The basic principle is the same. I even use it to control the solar heating for my pool. You measure the media (water or air), and decide to turn on or off a heating element or a pump. Currently it supports two output relays, to control a heating element and a motor to stir water.
The basic idea is to:
The application, as seen on a mobile device:
Dasboard in grafana:
This was a "one day project" that turned into a weekend project, that turned into... It is not really in a state to be used by anyone else than me at the moment, but the basic idea is to have a web-gui based on:
lighttpd -> php -> php slim
The web gui is useful for monitoring and setting constants and setpoints.
One of my design criterias is to separate the problem domain on the low level to three "daemons":
This is an overview of the API (input/output/interactions) between the systems components.
+------------------------------+ +----------+ +----------------------+
| web gui | | rest api | | LCD/Display, buttons |
+------------------------------+ +----------+ +----------------------+
| | |
+--------------------------------+
| app api |
| (bin/functions) |
+--------+-----------------------+
| ^
+---------+ | |
| logger |-> i.e influx | |
+---------+ | |
^ | |
| | |
+----+-----------------)----+------+--+
| | | |
| V | |
| tmp/setpoint |
18B20 | | |
| | V |
+-------+ | +---------+ | +--------+
| input | -> tmp/temperature -> | control | -> tmp/heaterDuty -> | output |
+-------+ +---------+ +--------+
|
V
Relay ---> Boiler/Heater/Pump
Separating the components in that way, I can play around with different ways of implementing the different components. I.e:
This matrix show which versions of raspbian that works. Please try and use the "newest" possible, as I am not testing backwards compatibility properly.
Raspbian Distribution | lite | GUI | PHP |
---|---|---|---|
Stretch | :white_check_mark: | :white_check_mark: | 7.0 |
Jessie | :white_check_mark: | :no_entry: | 5.6 |
Older | :grey_question: | :grey_question: | :grey_question: |
Reaally old | :no_entry: | :no_entry: | :no_entry: |
On the raspberry pi:
sudo apt-get update
sudo apt-get -y install git
git clone https://github.com/maglub/rpi-sous-vide.git
cd rpi-sous-vide
#--- if you need en_US.UTF-8
# piLoggerLocale=true ./setup.sh
./setup.sh
./setup-influxdb.sh
./setup-grafana.sh
sudo shutdown -r now
After the reboot, the 1wire interface is enabled and you should be able to see your devices. You should give your sensors names in the conf/aliases.conf file now.
#--- if you set up a greenhouse, change the application_type to "greenhouse" in conf/app.conf
cd rpi-sous-vide
./bin/genAliases | tee conf/aliases.conf
Start the input, control, and output processes in the web GUI. You can also do it on the command line:
bin/wrapper startProcesses
Set a target temperature:
bin/wrapper setSetpoint 65
Note, the installation of influxdb and grafana will take a while. I only show the installation for Raspberry Pi 3 (or newer), since it does not make sense to install it on the older ones.
./setup-influxdb.sh
./setup-grafana.sh
git pull
./setup.sh
The way the system figures out which input/control/output script to use, is set by symbolic links in ./bin, where the default symlinks are set as follows:
bin/control -> control-available/pid.enhanced
bin/input -> input-available/input-18b20
bin/output -> output-available/heaterOutput
bin/logging-enabled/none -> logging-available/none
For control, input, and output you can only link to one script. For logging, any symlink in bin/logging-enabled will be executed, hence you can log to multiple destinations if you like.
You can copy these scripts and adapt them in any way you like. In particular the input script might need different setup on your Raspberry Pi, and the setup script will try and satisfy this by calling the input script with the "--setup" parameter.
bin/input --setup
So if you have some esoteric hardware that need special configuration (like the 1wire sensors), you can put that in your input file in the doSetup() function.
If you have an influxdb server available, you can redirect the logging to it and create a new database for it. Update the influxdb variables in conf/app.conf, and symlink the logging script. In the influxdb script, there is an exampla curl call to create the database. There are three values logged at the moment:
cd bin
ln -sf logging-available/influxdb logging
ls -l logging
lrwxrwxrwx 1 pi pi 26 Jul 8 19:35 logging -> logging-available/influxdb
Influxdb examples:
curl -G http://192.168.4.55:8086/query --data-urlencode "q=CREATE DATABASE smoker"
curl -G 'http://192.168.4.55:8086/query?pretty=true' --data-urlencode "db=smoker" --data-urlencode "q=SELECT * FROM sensor_data"
Most things are hidden in the "functions" file. There is a wrapper that can be used to list the functions, and control them from outside the scripts.
bin/wrapper --list
bin/wrapper setSetpoint 65
svBin=/home/pi/rpi-sous-vide/bin
alias off='$svBin/wrapper setHeaterDuty 0 ; $svBin/wrapper setSetpoint 0 ; $svBin/wrapper setHeater off; $svBin/wrapper setPump off'
off
Ca cost for a Raspberry Pi 3 based system:
Total (ca) in CHF: ca 110.00 chf
Start the three programs:
Program | Description | Input | Output |
---|---|---|---|
bin/input | Symlinked to the input of choice in input-available. | Thermometer. 18B20 | /var/lib/rpi-sous-vide/tmp/temperature |
bin/control | Symlinked to the control program of choice in control-available. | /var/lib/rpi-sous-vide/tmp/{temperature, setpoint} | /var/lib/rpi-sous-vide/tmp/heaterDuty |
bin/output | Symlinked to the output program of choice in output-available. | /var/lib/rpi-sous-vide/tmp/heaterDuty | Solid state relay over GPIO |
Every now and then I will create a new release tag. Mostly "master" is considered to be stable, so just "follow master" to be up to date.
If you rather follow tagged releases, please check the "Releases" page. https://github.com/maglub/rpi-sous-vide/releases
Please provide any bug reports, feature requests, vulnerabilities, or other feedback in the Issue tracker here in this project. I happily receive contributions!
If you would like to contribute code, the process is simple.
Currently I am very relaxed when it comes to coding standards, but there are a couple of things to keep in mind:
Main inspiration: https://learn.adafruit.com/sous-vide-powered-by-arduino-the-sous-viduino/pid
Arduino PID library: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
Adafruit tutorial for 1wire 18b20: https://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/hardware
DS18b20 datasheet: https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
https://socomponents.co.uk/raspberry-pi-ds18b20-temperature-sensing/
http://www.reuk.co.uk/wordpress/raspberry-pi/ds18b20-temperature-sensor-with-raspberry-pi/
https://developer-blog.net/wp-content/uploads/2013/09/raspberry-pi-rev2-gpio-pinout.jpg
http://pdf1.alldatasheet.com/datasheet-pdf/view/228064/ONSEMI/MPSA05.html
Solid state relay: http://www.fotek.com.hk/solid/SSR-1.htm
http://www.instructables.com/id/Raspberry-Pi-Sous-Vide/?ALLSTEPS
https://github.com/drewhavard/rasp-sous-vide/blob/master/get_temp.pl
Heat sinking the solid state relay: http://www.scienceprog.com/considering-solid-state-relays-ssr-for-your-projects/
Now you will be able to browse your new dashboard on: