Wednesday, April 16, 2014

DIY BrewPi Fermentation Controller Cheap

So, i will start this post by saying Elco and _mdma are amazing at what they have created with BrewPi and continue to develop for free.  Brewers are great in that they share nearly everything, and they are no different.

This post is in no means being created in an effort to hurt their sales at their BrewPi store( and the PCB's they have created, if your willing to spend the extra $$ you can get most of the hard circuitry done for you.  But all of this as you know comes with a price, and a prebuilt BrewPi from them can cost a good amount of money.

This is a post for how to piece together a basic relay driven circuit  using an Arduino  and a RPi for about $100 in such a way that it will interface with the amazing BrewPi software running on a RaspPi that gives you graphs like this

And to give you the precision of this because of its advanced dynamic PID algorithms, you can see over the 4 hours of this sample brew with the set point at 65F my temperature rarely moved .1F off of the set point.

Or this zoomed in snippet of the same brew during nearly 24 hours of constant temperature ramping, again almost rarely reaching .1F over its set point, in most cases its .05F-.07F.  Ignore the front panel showing 65.05C, its because they are Euro :tank: and BrewPi defaults to C, but i have it swapped to Fahrenheit in the settings but there are a few GUI bugs like that still that dont swap biggie doesnt effect the operation.

And hopefully for only about $100, or less depending on which route you take which will be explained below.  This assumes you have the basics, like a soldering iron and some way to strip wires.

So lets get a list of things that are needed


Arduino Uno - $18
  • Can get a Sainsmart Arduino Uno on amazon for $13, cheapest I have found it not buying a knockoff from China.

Webserver Host (PICK ONE)

RaspPi - $70

Any PC with USB

  • This is where you can save a ton of money, if you are like me and have any old spare PC’s laying around with old drives, you can install Debian Wheezy on it, Unix based OS's are great because they can run on the crappiest of PC's.  Doing this route makes the software installs a bit more manual but  its all very well documented line by line on the BrewPi Wiki. Instructions here 

SainSmart 2 Channel Relay Board - $10

DS18B20 Sensors x2

  • There are a lot of options here, you can buy pre-made ones, something like this
  • Just make sure if you get premade sensors that any sheathing is not greater than .305 inches or it wont fit in the listed thermowell.
  • Or you can buy just the sensors themselves and wire make cables yourself, you can get 4 wire cable by the foot at Lowes/HD for like 44c per foot.  If you think 1 Meter of cable is long enough for your implementation then the above are good...if you need a long run you may want to make your own..or splice some longer cable onto the premade ones…I think you can get 10 DS18B20 sensors on Amazon for about 8 bucks. Hooking them up is straight forward just follow the schematic.


  • Brewers Hardware sells these that i use, the width is wide enough to fit the premade sensors down.  You also need to figure out a way to get said thermowell in your fermenter.  For me using a bucket, i simply drilled another hole in my lid, bought another cheap rubber stopper with a hole drilled in it to fit that hole and the thermowell fits very snuggly in a standard drilled stopper.
  • You can alternatively just insulate it properly on the side of the fermenter, although this can give you more wild temperature swings and result in your cooling and heating coming on more often.

Power socket - $5?

  • Any 10-15A socket from HD/Lowes should work

Power cord 

  • The easiest thing to do is to harvest a PC power cord and cut off the power supply end and keep the socket plug in end.  Many people have boat loads of these laying around, the nice thing is you can harvest the cut end for good 14-16 gauge  wire to use for this project.  If you must, buy the shortest and cheapest 16 gauge extension cord you can find.  You may be able to find something to harvest at a store like GoodWill/Salvation army, they usually have piles of cables near their electronics for a few dollars each.  In the case of PC power cords you can cut the power supply end off, then cut some 6-12 inch sections off  as needed and pull the individual White/Green/Black cables out of the outer black sheathing.  These make great connections for the Relay side going to the Wall socket, which should use 14-16 gauge wire to be safe.  Use thinner wire if possible for the arduino connections, it will make it easier to solder onto the pads...or if you want you can  always use header pins and just plug directly into the arduino from the top.

Assorted bag of Twist on Wire nut style connectors

  • These can be used to make the connections more quickly and easy, optionally instead of using these you could twist the wires in the diagram together and solder them, but this makes it harder to disassemble if you hook something up wrong.


This is a very basic sketch i threw together with my amazing MS Paint skills.  The circles are the wire nuts.

You can view the larger image here

The wiring isn’t actually all that difficult and can be banged out in an hour or so once you have all of your wires cut and ready, i will note that you are playing with 120V mains voltage coming from your wall.  Be extremely careful when handling this when plugged in, always ensure that there is no power being supplied from the Arduino and the 120V plug hooked up to the SSR is not plugged in when  you are messing with the wiring.

I will note that the Sainsmart relay board comes with stupid male pins for the inputs instead of female to use easy jumper cables.  Because of this I and many others just pull the header pins out and solder wires to the pads or through the connector.


  • Hook Up Arduino to RPi via USB
  • Once you have the Arduino wired up properly to the relay board and Sensors, hook it up via USB to the RPi.
  • Install Raspian Wheezy - 
  • If you  bought the Canakit listed above, simply plug it into a monitor via HDMI and usb keyboard in with the MicroSD card in it...when it boots it will ask you what OS to install, select Raspian and leave takes a while to install.
  • If you didnt have the NoobSD card, install Raspbian Wheezy onto a MicroSD card following the Raspbian instructions.
  • If you are using a PC instead of an RPI, use the install Debian Wheezy on the hard drive(Dont use a Live DVD)

Install BrewPi

Update Arduino’s image

  • This may or may not be different now, i have not done a fresh install in quite a while.  It seems like now when you run an Install that one of the steps is to program automatically flash your Arduino via the above Install script.  You want the Uno RevC image.
  • If it does not pop up asking you this during the install then use the following instructions to upload the appropriate image to the Arduino, you want to save the brewpi-uno-revc.hex image to your local machine by right clicking on it and saving it to a file.  You then go to your BrewPi interface at [url]http://brewpi/[/url] on your local network(or goto the IP address of your RPI) You will then use that file in these instructions

Setup Devices

  • We are almost there! You should have have a brewpi web interface if you open up a web browser and go to http://brewpi
  • The final step is to tell it about your sensors, this is where you will find out if something is not wired properly in your Arduino circuit.
  • First check the top right, it should say that the Script is running.  If it is not, try clicking the button the start the script and wait 30 seconds to see if it starts.  If it still wont work, this means the script on your Arduino is not properly running and you may need to try reflashing it with the image, you cant set the settings below until  it shows the Script is running.
  • Under the Maintenence Panel, select Device Configuration
  • Check Read Values, and press the Refresh Select Device button
  • When you do so a big list of devices will show up under Detected Devices.  Scroll through the list and you should see TWO that are detected as a Temp Sensor with a value(probably in Celcius).  If you do NOT see two sensors reporting back a temperature, check your circuitry.
  • When both are detected,  set each one to Chamber 1 and Beer 1, and hit apply, you need to determine which sensor your going to use for which temperature and set the Function dropdown accordingly to either Chamber Temp(sensor that just sits in your thermal chamber), or Beer  Temp(the one that is on the side of your fermenter or in a thermowell), we dont care about the Room temperature.  Be sure to hit Apply for each device  after you’ve set them up properly.
  • You should also have two  device types of “Switch Actuator”, one on Arduino Pin 5(Act2) and one on Arduino Pin 6(Act 1).  
  • Set them to Chamber 1, and Chamber Device(not Beer 1) for their assigned values.  You also need to set the Pin Type to inverted if you followed my wiring diagram and used the left and middle pins of the Relay output.  Also make sure to hit apply for each device after you have set them up properly.
  • Your now done!

After that, you should have a functioning BrewPi, take whatever steps you want to make it pretty by putting it in a box to protect the electronics.  I recommend testing it and your  electrical socket wiring with a fan or light of some sort and watch the BrewPi interface to see if it thinks it is heating or cooling or idle, and that it is indeed doing that by powering the appropriate outlet or none(idle).

The brewpi LCD interface in the top left by default updates every 10s, you can press the refresh graph button to update the graph, or just reload the page.

Lets keep the banter about doing everything on a RPi to a minimum, there are reasons that they have chosen to go this route, mostly due to the innate stability of the Arduino, and the general unstability of Raspbian and the RPi.  If the RPi was to crash, the Arduino would still has everything it needs to maintain its temperature until you fix the problem. But a micro controller like the Arduino crashing is generally unheard of, although i guess in theory it could happen it should reset itself.  And honestly the Arduino Uno at this point is so cheap it doesnt matter if you did it strictly on a RPI, your not  really saving much money.

Lastly if you made it this far you can take a look at my BrewPi graph and play with it, i altered the page so that the settings are all gone so people cant mess with my ferm chamber, but you can still see the graph and play with  it if you want.  You can turn on and off the various graphs on the right, zoom in time or temperature, etc.

Finally there is a post on HomeBrewTalk where there are plenty of users creating this that can help troubleshoot issues along with myself if you have issues!

Wednesday, February 13, 2013

Arduino Real Time Fermentation Temperature Monitoring For Cheap!

So this will be my first real big blog post, and it will be discussing the creation of an automated Arduino based fermentation monitoring system that can be built for around $60-70 USD.

It makes use of the Arduino, an Ethernet shield, and the free COSM service that  we will push our temperature data too for easily web accessible graphing and monitoring.

At the end of this project you will have a project that should output the data to COSM and be capable of creating graphs like this real time COSM graph of my Fermentation and Ambient temperatures. COSM is a very powerful tool for free, you can use it to get real time data of your temperatures anywhere you have internet access, and can even set up triggers to tweet/email you when certain things happen.  For example i have it setup to email me if my fermentation temperatures ever gets outside the optimum range for the yeast I am using, which allows me to fix the problem ASAP.
Also side note, it should tweet/email me should my house catch fire and the ambient gets greater than 110!

Note: This is REAL time, the image is built by COSM when you request it.  The image you are seeing is  what my setup is reading as of when you loaded this web page and the image loaded.  If you reload the page it will give you a new graph with the updated data.  The graphs are currently showing the last 24 hour period.  There may or may not be some dips or other weird values showing as its not hooked up if i am not brewing.

You get most of the  data from going to the actual feed below, but can also  have it export some pretty nifty graphs to see long term graphs at a glance.

This is the feed

Equipment Needed

  • Arduino Uno
  • Wiznet 5100 Ethernet Shield
  • 2 x DS18B20 Temperature Sensors
  • Wire
  • Solder
  • Soldering Iron
  • 2 x 4.7K Resistors
  • 5V Power Supply OR Smart Phone USB Wall Charger(come with most smart phones now)

It should be noted that you can set this up with a single DS18B20 for fermentation if you are not interested in ambient or  another sensor, so adjust your  quantities of the sensors and resistors above accordingly.

A good place to get the UNO and Wiznet  Ethernet shield is DealExtreme, for those not familiar with it, they produce cheap Chinese knockoffs of stuff.  But because Arduino is an open source project revolving around a  single chip, there should be no fear in buying from them.  The only downside is it can take upwards of 3-4+ weeks from ordering to get your products in the US.  Take that into consideration, you can get the Uno and Wiznet Ethernet shield from other outlets, but at a much higher cost.  Some people may be against the idea of supporting Chinese manufacturing, or just don't want to wait over a month to get everything...just make sure you get the Wiznet 5100 and not another Ethernet shield or the code here probably wont work.

Arduino UNO - $15.20

Wiznet 5100 Ethernet Shield - $13.99

2 x Maxim DS18B20+ Temperature Sensors - ~$2.50 each. 

You can find these at sites like Digikey or other electronics stores online, hunt around and you can find them at decent rates.  I bought a bundle of 10 off Ebay for $20 dollars.  Can also be bought if you go through DealExtreme.


I bought some cheap 4 wire flexible thermostat wire from Lowe's for 33c/foot.  Its nice and thin and will fit down a thermowell but yet remain can use any wiring you want as long as it will fit in your thermowell.  Home phone wiring may be good since its flexible and fairly narrow, some Ethernet cables may work as well if thin  enough, but again it needs to be able to fit down your thermowell.  You only need 3 wires, so i just cut one(the white one) off.

Thermowell - $14

You can use any you want, just make sure its not too long to fit into your bucket or carboy but to get a fair ways into your wort when its at the 5G marker.  This one ended up actually being too tall for my 8 gallon bucket, so mine is just JBWeld'd in the bucket lid with a few inches out the top of the bucket.  I'd prefer to have to have it flush but whatever works!

Food Safe  Heat Shrink Tubing - $3

Another option besides using a thermowell is to use some food safe heat shrink tubing, and to wrap your sensor in it.  I personally havent tried this, but someone commented on it on Reddit and i dont see why it wouldnt work.  Would likely work best if you could source one of the stainless steel caps that Adafruit uses on their premade DS18B20 probes.

4.7k Resistor - Cheap?

The DS18B20's require that you have a 4.7k resistor between the Data  and Power pins in order to function.

5V Power supply $1-2

$1-2 dollars at any Goodwill/Salvation army, free if you have extra wall warts laying around that are 5V. 
Phone charger USB connectors work as well, such as the standard one that comes with the iPhone or the Androids

The USB connectors allow you to plug right into the USB port of the Arduino to get power.  Otherwise for the 5v connector you need to plug in the jack, or cut the supply and solder it directly into the 5V and Ground connections on the Arduino, this allows you to pass their voltage regulator which IMO gets too hot for my liking.


Start by wiring up the DS18B0's to your length of Thermostat or other wiring.  Below is a crude circuit diagram of how it should all be hooked up.

You need to wire your 4.7k resistor across the Data and Voltage pins of the Arduino.  In this case if you are using two sensors, the easiest way is to just solder the 4.7k resistor across the pins directly on the Arduino on the bottom side of the board.  You can also directly solder your wires  to the bottom if you want a more permanent attachment than plugging it in to the headers, which i had problems with falling out with just a slight bump from a cat or vacuum.

Because the DS18B20's use OneWire, you need to ensure that both of your 'sensor cables' are soldered together in some fashion.  The Gnd to Gnd, Power to Power, and Data to data.  I found just twisting the  two ends together  with a third piece of wire(thats going to plug into the Arduino) and soldering them together worked quite well.  You could probably even get away with cable twist connectors if your wire gauge is thick enough.  Once you have the cables with sensors on them, its a good idea to somehow protect the DS18B20 leads so they dont touch.  I found using a bit of hot glue works great, not to mention if you coat the sensor itself in a small layer of hot glue you can essentially make it water proof.  Just dont put so much on you cant get it into your thermowell, ask me how i know!

Update 3/3/13
I  recently have redone my setup a bit to make it a bit more 'professional' at the end.   I have wired my two sensors up to a  single cat5e cable(pins 1-6), and then wired my arduino with a single 4.7k resistor across Digital 3 and 5V with wires then being direct soldered to the arduino and hooked up to a Cat5E Wall jack.
The goal is to mount a Cat5E wall plate in a Radioshack project box, and have a nicer looking final product with double(for future growth!) cat5e jacks i can plug and unplug the sensor cables into.

Ignore the 2 resistors shown, this was a trial  that i went to just using 1 resistor using the above schematic, other than that the basic setup is the same.

End Update

The next step is to install the Arduino development software off of their site, and connect your arduino via the supplied USB cable to your computer and make sure it all gets detected and installed properly.

Hook your probe(s) up as follows to the Arduino
DS18B20 - Arduino
Data(Pin 2) - Digital Pin 3
Power(Pin 3) - 5V
Ground(Pin 1) - GND

Now close the Arduino software and download the One Wire Library here
And the DallasTemperature Library
And the COSM Client

Extract these into folders in the Arduino/Libraries you should have a Arduino/Libraries/OneWire, etc.

Next open the Arduino software, in the settings make sure you set the Serial port the Uno USB drivers installed onto(Check device manager) and the device type to the Arduino UNO.  These can be found under the tools->board drop down and tools->Serial port drop down.

Copy and paste this code in bold into the window
// This sketch looks for 1-wire devices and
// prints their addresses (serial number) to
// the UART, in a format that is useful in Arduino sketches
// Tutorial:

#include <OneWire.h>

OneWire  ds(3);  // Connect your 1-wire device to pin 3

void setup(void) {

void discoverOneWireDevices(void) {
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];
  Serial.print("Looking for 1-Wire devices...\n\r");
  while( {
    Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
    for( i = 0; i < 8; i++) {
      if (addr[i] < 16) {
      Serial.print(addr[i], HEX);
      if (i < 7) {
        Serial.print(", ");
    if ( OneWire::crc8( addr, 7) != addr[7]) {
        Serial.print("CRC is not valid!\n");
  Serial.print("\n\r\n\rThat's it.\r\n");

void loop(void) {
  // nothing to see here

Save it, and with your Arduino all plugged in(don't need Ethernet at this point) and with sensors and lit up, hit upload and make sure that it gets uploaded properly with no compile errors.

When it is complete, from the Tools menu in the Arduino software select the Serial Monitor option.  A new window will pop up and within a second or two it should print some text containing the Address's for any Sensors that are plugged in.  If it pops up and shows no addresses, your sensors are not plugged in properly.  Ensure all connections on both sides are right, use a Multimeter to help debug if you have one.  Because the DS18B20's leads are so small it can be a pain to get them soldered without bridging between leads.  You should see a seperate address for EACH sensor plugged in, so if you have two, and only see one you need to check your  connections until this displays  one address for each sensor.

Write down the addresses it gives you, these are the addresses you need to use in the later program for it to address your sensors on the OneWire bus.

Next create a new program in Arduino, and paste in this
#include <Cosm.h>
#include <CosmClient.h>
#include <CosmDatastream.h>
#include <CosmFeed.h>
#include <CountingStream.h>

#include <b64.h>
#include <HttpClient.h>

#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Ethernet.h>

//Defines for DS18B20
#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress Sensor1 = {
0x28, 0xA9, 0x31, 0x98, 0x03, 0x00, 0x00, 0x84};
DeviceAddress Sensor2 = {
0x28, 0xA5, 0x0C, 0x74, 0x03, 0x00, 0x00, 0xCA};
//End Defines for DS18B20

//Defines for COSM Ethernet
char cosmKey[] = "IBSjU3xY6SybgOjdyns3F3kdofiSAKxLRzZNOVRoWU1SZz0g";
byte mac[] = {
  0x00, 0x1D, 0x0D, 0x2C, 0x55, 0x3D};

EthernetClient client;
CosmClient cosmclient(client);

//End Defines for COSM Ethernet
double s1 = 0;
double s2 = 0;

#define MYDELAY 5000
char sensor1Id[] = "FermSensor1";
char sensor2Id[] = "Ambient";

CosmDatastream datastreams[] = {
  CosmDatastream(sensor1Id, strlen(sensor1Id), DATASTREAM_FLOAT),
  CosmDatastream(sensor2Id, strlen(sensor2Id), DATASTREAM_FLOAT)};

CosmFeed feed(83208, datastreams, 2);

void setup(void)
  // start serial port

  while (Ethernet.begin(mac) != 1)
    Serial.println("Error getting IP address via DHCP, trying again...");

void SetupSensors()
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(Sensor1, 12);
  sensors.setResolution(Sensor2, 12);

float getTemperature(DeviceAddress deviceAddress)
  //Get temperature, convert to Fahrenheit, and return
  return DallasTemperature::toFahrenheit(sensors.getTempC(deviceAddress));

void loop(void)

void SensorLoopAndSend()
  s1 = getTemperature(Sensor1);
  s2 = getTemperature(Sensor2);
  Serial.print("S1: ");
  Serial.print("S2: ");
  if((s1 != 185) && (s2 != 185) && (s1 != 32) &&  (s2 != 32))
    int ret = cosmclient.put(feed, cosmKey);

I think the code is pretty easy to read and straight forward
First replace your Device Addresses with the ones i have in my code, you can add more sensors if you wish as well.

Next make an account on and when logged on COSM create a Feed by pushing the blue +Device/Feed button in the top right.  Next in your Keys section(top right) you should be given an API Key, find the COSMKey variable in the code above, and replace its value between the quotes with the API key they give you.

Next i don't think its necessary but not a bad idea, when the Ethernet plugged into the Arduino and linked, log into your router and find the mac address of your Wiznet module.  It should be fine to use my MAC address, but using your own wouldn't hurt if you know how to find it since its not printed on the module like it should be.

Next name your Sensors within the code, mine are just Ambient and FermSensor1, these names will be pushed to COSM automatically with your data so you don't need to make them within the COSM webpage.  Don't use spaces, and some special characters might not work so stick to basic characters.

Finally on this line
CosmFeed feed(INSERT FEED HERE, datastreams, 2);
Replace your Feed Number,  and the last number is how many feeds you are pushing.  So if you are using more than 2 sensors increase this number.  It should just be a integer, so no quotes need to be around the feed value.

That should be everything!  Save it and upload it and make sure it compiles, fix any errors you have or ask here if you have no clue what your doing. 

You can check the Serial Monitor to see if its reading your probes properly, if it is you should be seeing data on your COSM feed!

If you are not seeing data, use the Debug area(Top right menu) on COSM.  It will show you how many requests they are getting from you.  By default this code should have about 20 updates per minute which is well under their maximum of 100.  5 Seconds is already way fast for updates, but since they let you do it i don't see why not!  If you are on an ISP provider that has capped download/upload rates, you may want to adjust the MYDELAY to be higher so you don't use a lot of bandwidth.  The value is in milliseconds so the default is 5000 for 5 seconds.

There are an infinite number of ways that you can build this, i am just  documenting my own way i threw it together, at some point i would like to clean it up, but for now its functioning and needed for brewing so i don't want to break it!  I have thought about using phone/Ethernet jack plugs on the ends of my cables, so that i can put my Arduino in a box with a phone/Ethernet wall jack plate and easily plug and unplug sensors in.

Post any ingenious methods of building/connecting that you may have!
That's it! Feel free to post questions here if you have any ill do my best to help!

Tuesday, February 12, 2013

Welcome to the blog!

Welcome to my brewing blog!

I plan to use this blog to post a bunch of various DIY instructions on things i have created  to help me during my brew process, as well as document  some upcoming projects and brew topics.