RasPiBrew Vessel Temperature Controller

RasPiBrew using Bootstrap

This system is an inexpensive and flexible wireless web based controller for brewing, Sous Vide and similar applications. With homebrewing it was originally targeted for electric brew in a bag (eBIAB), batch sparging in a cooler and extract methods but has recently been expanded on the desktop to multi-vessel and pump/stirrer control. So, if you already have a propane system and looking to go electric or starting from scratch and looking for a way to control your setup this is an alternative. The most recent updates for this application are found on the RasPiBrew project page on Github.

Using the Android Smart Phone App or a Firefox web browser the temperature of a vessel can be controlled with a Raspberry Pi . All status information including heat output percentage and current temperature are constantly sent back to the controller. A very simple and inexpensive electronics hardware setup plus ease of use are the main goals of this project. No custom made boards that are specific for this project are needed. Also, using a web interface the level of customization is endless.

Download Software for Raspberry Pi Web Server. Also, Control and Monitor your vessel temperature and heat output with an Android app. Compatible with smartphones only.

New Version 1.1.4 of Android App: RasPiBrew Android on Google Play

Hardware and Software Setup Instructions

Hardware

Parts List:

The Jeelabs circuit board is connected to a temperature sensor and a solid state relay to control a heating element. The setup is shown in the following schematic:

 ---------      ------- 
| 1-Wire  |    | Relay |
| Sensor  |    |       | 
| + - GND |    |  + -  |
 ---------      -------
  | |  |          | |           (Optional SSR Connections)
  ---------------------          -----------   ---------
 | Jeelabs Thermo Plug |        |  Relay 2 |  | Relay 3 | ...
 | PWR +3V GND AIO DIO |        |  +  -    |  |  +  -   |
  ---------------------          ----------    ---------     
    |   |   |   |   |             5V  |         5V  | 
  ------------------------            |             |
 | 5V  5V  GND  P4 P17    |     ---------------------------
 |                     5V |---| VCC   P0            P1 ... |
 |  Raspberry Pi/      GND|---| GND   Optional             |
 |  Adafruit Plate kit SDA|---| DIO   Jeelabs Output Plug  | 
 |                     SCL|---| AI0                        |
 |      5V GND TX         |    ----------------------------
  ------------------------
         |  |   |
      --------------   
     | 20x4 LCD and |
     | LCD117 kit   |
      --------------

Only the printed circuit board of the Jeelabs Thermo Plug is needed and solder:

Next, solder headers and connect everything together using wire jumpers according to the above schematic.

Note: The DS18B20 temp sensor can be connected to 3.3V or 5V on the Raspberry Pi. DS18B20 DataSheet

Software

Load Operating System onto SDCard

Download the raspberry pi operating system: Raspberry Pi Downloads Use Win32DiskImager to install onto SDCARD.

In terminal type: sudo raspi-config

Expand File System and set Internationalization options

Note: If using LCD go into Advanced Options and disable kernel messages on the serial connection

In terminal type:

sudo apt-get update
sudo apt-get upgrade

Beginner’s Guide

Follow the RasPi beginners guide to get up and running:

Run sudo setupcon once manually after the keyboard is setup otherwise you may have long boot times.

Wireless Setup

Lookup Compatible USB wifi devices and install the drivers:

To set up a static ip address use the following in /etc/network/interfaces:

auto lo

iface lo inet loopback
iface eth0 inet static

auto wlan0
iface wlan0 inet static
address 192.168.1.103
netmask 255.255.255.0
gateway 192.168.1.1

If no wireless password use:

wireless-essid linksys

Otherwise use the following:

wpa-ssid "ssid"
wpa-psk "wireless_key_passphrase" 

with the correct ssid (router name) and wireless_key_passphrase.

Tutorial on setting up a static IP address Tutorial on setting up wifi device on linux

Manual Installation

Python Modules: Install pip (package installer): 'sudo apt-get install python-setuptools' 'sudo easy_install pip'

Install PySerial: sudo pip install pyserial PySerial Info

Install Python i2c and smbus: 'sudo apt-get install python-smbus' smbus info

Install Flask: 'sudo apt-get install python-dev' 'sudo apt-get install libpcre3-dev' 'sudo pip install Flask' Flask Info

In Raspberry Pi terminal window: 'sudo bash' 'cd /var' 'mkdir www'

Copy software to /var/www preserving the directory structure.

At the command prompt type: 'sudo nano /boot/config.txt' At the bottom of the file add the line: 'dtoverlay=w1-gpio' Save the file and then reboot.

Replace the temp sensor id in config.xml with the id of your DS18B20 temperature sensor found in the /sys/bus/w1/devices/ directory on the Raspberry Pi.

Start Putty on Windows and type login name and password. Program must be run as superuser: Type sudo bash Start program by typing: python raspibrew Next, start the web browser on a computer on your network. If ip address of the Raspberry Pi is 192.168.1.3 then point the browser to http://192.168.1.3:5000

How to Start RasPiBrew on Boot up:

Create a new file: /etc/init.d/raspibrew as superuser and insert the following script:

#! /bin/sh
# /etc/init.d/raspibrew

### BEGIN INIT INFO
# Provides:          raspibrew
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script from www.stuffaboutcode.com which will start / st$
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
    start)
        echo "Starting RasPiBrew"
        # run application you want to start
        python /var/www/raspibrew.py
    ;;
    stop)
        echo "Stopping RasPiBrew"
        # kill application you want to stop
        killall python
        python /var/www/cleanupGPIO.py
    ;;
*)
    echo "Usage: /etc/init.d/raspibrew {start|stop}"
    exit 1
    ;;
esac

exit 0

Make script executable: sudo chmod 755 /etc/init.d/raspibrew

Register script to be run at start-up: sudo update-rc.d raspibrew defaults

To Remove script from start-up: sudo update-rc.d -f raspibrew remove

To test starting the program: sudo /etc/init.d/raspibrew start

To test stopping the program: sudo /etc/init.d/raspibrew stop

Run RasPi Program at Start Up Info

IDE for Development:

Create root password on Raspberry Pi: sudo passwd root Enter new UNIX password: raspberry

Install Aptana Studio 3 for IDE on your computer:

This is used for programming in Python, Javascript, web page design and 1-click synchronization with Raspberry Pi

After creating a project and adding all source files, right click on project name. Select Publish and then Run Web Development Wizard... Select FTP/SFTP/FTPS and fill out the form as shown: Everytime files are saved on your computer they are automatically sent over to the Raspberry Pi.

Technical Details

The language for the server side software is Python for rapid development. The web server/framework is web.py. Multiple processes connected with pipes to communicate between them are used. For instance, one process can only get the temperature while another turns a heating element on and off. A third parent temp control process can control the heating process with information from the temp process and relay the information back to the web server.

On the client side jQuery and various plugins can be used to display data such as line charts and gauges. Mouse overs on the temperature plot will show the time and temp for the individual points. It is currently working in a Firefox Browser.

jQuery and two jQuery plugins (jsGauge and Flot) are used in the client: http://jquery.com http://code.google.com/p/jsgauge/ http://code.google.com/p/flot/

The PID algorithm was translated from C code to Python. The C code was from “PID Controller Calculus with full C source source code” by Emile van de Logt An explanation on how to tune it is from the following web site: http://www.vandelogt.nl/nl_regelen_pid.php

The PID can be tuned very simply via the Ziegler-Nichols open loop method. Just follow the directions in the controller interface screen, highlight the sloped line in the temperature plot and the parameters are automatically calculated. After tuning with the Ziegler-Nichols method the parameters still needed adjustment because there was an overshoot of about 2 degrees in my system. I did not want the temperature to go past the setpoint since it takes a long time to come back down. Therefore, the parameters were adjusted to eliminate the overshoot. For this particular system the Ti term was more than doubled and the Td parameter was set to about a quarter of the open loop calculated value. Also a simple moving average was used on the temperature data that was fed to the PID controller to help improve performance. Tuning the parameters via the Integral of Time weighted Absolute Error (ITAE-Load) would provide the best results as described on van de Logt’s website above.

Brewing Equipment

Brewing Hardware Links

The electric brewery web site has great information on brewing hardware setup: http://www.theelectricbrewery.com/ The following sites are good sources for parts: bargainfittings.com, brewhardware.com and brewershardware.com.

My Setup

First, a GFCI protected outlet is needed as well as the correct wiring gauge for the amperage used. An electrician should inspect the wiring. The following schematic (from PJ on homebrewtalk.com) is what I followed for my system which uses a 15.5 gallon vessel. I replaced the Auberin PID with the RasPiBrew setup and the pump is not used. Instead, an ice cream maker motor attached to a stainless steel dry wall mixer is used to constantly stir the water or wort in the brew kettle. Otherwise, a temperature differential will occur above and below heating element. The pump or stirrer can be added to RasPibrew control with some software modifications and using the optional jeelabs output plug which can control up to 8 relays. Since I just turn it on and let it run, I didn’t think it was needed. I use both the Brew in a Bag (BIAB) and batch sparging in a cooler brewing methods.