Anyone who knows me knows that I love a good beer but I also enjoy making my own and I’m slowly making my home brew setup automatic.

Currently I have an all-electric brew setup with a chugger pumpheating element for my boil, and a RIM Rocket for my mash. (RIM stands for Recirculating Immersion Mash). I hooked the heating element and RIM Rocket up to a PID (Proportional, Integral, Derivative) which allows me to monitor and set the temperature of the RIM Rocket.

In order to automate a multi step mash I replaced the PID with a BBB (Beaglebone Black).  I’m hooking up a PT100 which is a three-wire, waterproof temperature probe that is currently hooked up to the PID. The reason I chose to use a BBB and not a Raspberry PI is because the PI does not have analog in/out.

Now let’s get started.

The end program and circuit is going to turn on an LED based on the temperature reading from the PT100.

What you will need:
  • PT100
  • TL317
  • 100ohm resistor
  • 1 micro farad capacitor
  • LED
  • 560ohm resistor
Wiring diagram:

Wiring PT100:
  • Plug P9-01 into ground of the bread board (bb).
  • Plug P9-03 into power of the bb. This is 3.3v out from BBB.
  • Plug the Capacitor from TL317 input pin to the ground of the bb.
  • Plug power from bb to the input pin of the TL317.
  • Plug the 100ohm resistor from the TL317 output pin to the TL317 adjustment pin.
  • Plug the TL317 output pin to both of the red wires from the PT100
  • Plug P9-40 to both of the red wires from the PT100. P9-40 is analog in this will be the pin we read.
  • Plug the blue wire from the PT100 to ground of the bb.
  • Plug P9-34 to ground of the bb.
Wiring LED:
  • Plug P9-45 to non-used ground (opposite side) of the bb.
  • Plug P9-41 to non-used power (opposite side) of the bb.
  • Plug One end of the LED to the ground.
  • Plug the other end of the LED to the 530ohm resistor.
  • Plug the other end of the resistor to the power.
Program Goals:
  1. Be able to read the voltage coming from the temperature gauge.
  2. Figure out the voltage to temperature reading.
  3. Based on the temperature, turn on and off the LED.
Reading Program:

I’m doing this in JS using the supplied bonescript.js library to read the pins on the BBB. The analog reader class I wrote looks like this and is saved in analogRead.js:

var b = require('bonescript');

var analogRead = function(inputPin){
    this.mV = 0;

    function readMiliVolts(){
        var reading = b.analogRead(inputPin);
        var mV = reading * 1800; // 1.8V reference = 1800 mV

        return mV;
    }

    this.readVoltageXTimes = function(x){
        var mvAve = 0;

        for(var i=1; i <= x; i++){
            var results = readMiliVolts ();

            mvAve += results;
        }

        this.mV = (mvAve / x).toFixed(2);

        return this.mV;
    }
}

module.exports = analogReader;
To use the class:
var analogReader = require('./analogRead.js');

var inputPin = "P9_40";

var analogVoltage = new analogReader(inputPin);

var mV = analogVoltage.readVoltageXTimes(4);

console.log("mV: " + mV);

Ok now we have a program that will show us the voltage readings from the PT100.

Run the program:
pt100BBB=> node runAnalogRead.js

mV: 1.44

Woohoo, it worked!

Now let’s figure out the mV to Temp for a 3.3v supplied voltage.

I did this by using the the PID to set a temperature. Once the water reaches the specified temperature, take a few readings with the PT100 BBB setup, calculate the average, and then increase by 5 degrees. Repeat these steps 5 or so times. From the data gathered plot them on a graph and if it is a nice line you don’t need to do anymore readings. If not, keep repeating the steps till you have a line you like. Using that line, generate a formula where X is the mV and Y is the temp.

We have our Volts-to-Temp formula. Now let’s create another .js library that will tell us the temperature at the probe:

var b = require('bonescript');

var tmpReader = function(inputPin){
    function getTempF(){
        var reading = b.analogRead(inputPin);
        var mv = reading * 1800; // 1.8V reference = 1800 mV
        var tempF = (2/3) * mv + 1; //formula from graphed line (this is a made up formula)

        return tempF;
    }

    this.readTempXTimes = function(x){
        var tempAveF = 0;

        for(var i=1; i <= x; i++){
            tempAveF += getTempF();
        }

        return (tempAveF / x).toFixed(2);
    }

}

module.exports = tmpReader;
To use this temp reading library:
var tmpReader = require('./tempReader.js');

var inputPin = "P9_40";

var temp = new tmpReader(inputPin);

var tempF = temp.readTempXTimes(4);

console.log(tempF);

Now let’s turn on that LED based on the reading:

var b = require('bonescript');
var tmpReader = require('./tempReader.js');

var ledPin = "P9_41";
var tempPin = "P9_40";

b.pinMode(led, 'out');

var temp = new tmpReader(tempPin);

turnLedOn = function(){
    b.digitalWrite(led, 1);
}

turnLedOff = function(){
    b.digitalWrite(led, 0);
}

readTemp = function(){
    var tempF = temp.readTempXTimes(4);

    console.log(tempF);

    if(tempF > 100) turnLedOn();
    else turnLedOff();

    setTimeout(function(){
        readTemp();
    }, 1000);
}

readTemp();

This program will check every second to see if the temp is above 100F and if so turn the LED on.

I have to give credit to my father, Ed Folz, for creating the circuit for reading the PT100 and all his knowledge of the electrical world.


Leave a Reply

Your email address will not be published. Required fields are marked *