New Giveaway - Wort Monster Conical Fermenter!

Home Brew Forums > Home Brewing Beer > DIY Projects > Temperature Monitoring and Control with Arduino




Reply
 
LinkBack Thread Tools Display Modes
Old 01-06-2010, 02:10 AM   #1
erock2112
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2009
Location: Chapel Hill, NC
Posts: 301
Liked 1 Times on 1 Posts

Default Temperature Monitoring and Control with Arduino

Hey guys. I just got my Arduino Duamilanove in the mail, and I've put together a few temperature probes using thermistors to monitor fermentation temperatures. I'm in the process of building a probe in which to put a more accurate LM34 sensor for monitoring mash temperatures. The design for the thermistor probe comes from: http://home.chattanooga.net/~cdp/thermis/thermist.htm

Parts:

3 x 10KOhm Thermistor
1 x LM34 sensor
3 x 10K Resistor
1 x Arduino USB
1 x 3/8 OD 24 inch copper tubing (cut into 3 x 8" lengths)
1 x 3/8 OD 12-inch copper tubing
Wires - I used some speaker wire which fit nicely inside the copper tubing
Silicone Sealant
Solder, shrink tubing etc

Thermistors, LM34 and copper tubing (sorry for the cell phone pics):


Arduino!


Thermistors and LM34 soldered


Completed thermistor probes, sealed with silicone. I'm using an "Electronic Project Lab" for its breadboard - disregard that and the half adder assembled on the left part of the breadboard. At this point, the probes are connected through basic voltage divider circuits with 10K resistors to the Arduino's analog inputs.


I also now have the LM34 hooked up, but it's not yet housed. The output from the Arduino onto my screen:



__________________
HomeBrew Blog

Last edited by erock2112; 01-06-2010 at 02:15 AM.
erock2112 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 02:15 AM   #2
erock2112
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2009
Location: Chapel Hill, NC
Posts: 301
Liked 1 Times on 1 Posts

Default

My code for the arduino sketch (this is copied and adapted from a couple of different tutorials):

Code:
#include <math.h>

double Thermistor(float RawADC) {
 // Inputs ADC Value from Thermistor and outputs Temperature in Celsius
 //  requires: include <math.h>
 // Utilizes the Steinhart-Hart Thermistor Equation:
 //    Temperature in Kelvin = 1 / {A + B[ln(R)] + C[ln(R)]^3}
 //    where A = 0.001129148, B = 0.000234125 and C = 8.76741E-08
 long Resistance;  
 double Temp;
 double Kelvin;
 double Celcius;
 double Farenheit;
 Resistance=((10240000/RawADC) - 10000);  // Assuming a 10k Thermistor.  Calculation is actually: Resistance = (1024/ADC)
 Temp = log(Resistance); // Saving the Log(resistance) so not to calculate it 4 times later. 
 Kelvin = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));  
 Celcius = Kelvin - 273.15;  // Convert Kelvin to Celsius                                   
 /*
 // BEGIN- Remove these lines for the function not to display anything
  Serial.print("ADC: "); Serial.print(RawADC); Serial.print("/1024");  // Print out RAW ADC Number
  Serial.print(", Volts: "); printDouble(((RawADC*4.860)/1024.0),3);   // 4.860 volts is what my USB Port outputs.
  Serial.print(", Resistance: "); Serial.print(Resistance); Serial.print("ohms");
 // END- Remove these lines for the function not to display anything
 */
 // Uncomment this line for the function to return Fahrenheit instead.
 Farenheit = (Celcius * 9.0)/ 5.0 + 32.0;
 return Farenheit;  // Return the Temperature
}

void printDouble(double val, byte precision) {
  // prints val with number of decimal places determine by precision
  // precision is a number from 0 to 6 indicating the desired decimal places
  // example: printDouble(3.1415, 2); // prints 3.14 (two decimal places)
  Serial.print (int(val));  //prints the int part
  if( precision > 0) {
    Serial.print("."); // print the decimal point
    unsigned long frac, mult = 1;
    byte padding = precision -1;
    while(precision--) mult *=10;
    if(val >= 0) frac = (val - int(val)) * mult; else frac = (int(val) - val) * mult;
    unsigned long frac1 = frac;
    while(frac1 /= 10) padding--;
    while(padding--) Serial.print("0");
    Serial.print(frac,DEC) ;
  }
}

void setup() {
 Serial.begin(9600); //115200);
}

#define LM34PIN 0          // Analog Pin 0
#define Thermistor1PIN 1   // Analog Pin 1
#define Thermistor2PIN 2   // Analog Pin 2
#define Thermistor3PIN 3   // Analog Pin 3

double lm34;
double thrm1;
double thrm2;
double thrm3;

void loop() {
 lm34 = analogRead(LM34PIN); 
 thrm1=Thermistor(analogRead(Thermistor1PIN));           // read ADC and convert it to Celsius
 thrm2=Thermistor(analogRead(Thermistor2PIN));
 thrm3=Thermistor(analogRead(Thermistor3PIN));
 
 lm34 = (lm34 * 5.0 / 1024.0) * 100.0; 
 
 Serial.print("LM34: "); Serial.print(lm34);
 Serial.print(" Thermistors: 1: "); printDouble(thrm1,1);  // display Fahrenheit
 Serial.print(" 2: "); printDouble(thrm2,1);
 Serial.print(" 3: "); printDouble(thrm3,1);
 
 Serial.println("");                                 
 delay(10000);                                           
}
I'm not sure if the LM34 or the thermistors require more calibration. As is shown on the output, the LM34 is reading a good degree lower than the thermistors. Any ideas?

I'm also wondering how to house my LM34 probe. I want it to go in the mash tun, and was considering drilling through the side of my water cooler, but I'm not all that sure about it...


__________________
HomeBrew Blog
erock2112 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 02:20 AM   #3
erock2112
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2009
Location: Chapel Hill, NC
Posts: 301
Liked 1 Times on 1 Posts

Default

Next up is to write a program to chart these numbers. Eventually I'll build a housing for the arduino with detachable plugs for the temperature probes. I'm hoping to install a water heater element in my mash tun for temperature control as well. Either a temperature control circuit would be included or I'd take care of it on the software side. Any ideas on mounting the LM34 probe in a mash tun?

__________________
HomeBrew Blog
erock2112 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 03:36 AM   #4
jpc
HBT_LIFETIMESUPPORTER.png
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jan 2009
Location: Santa Clara, CA
Posts: 1,864
Liked 42 Times on 35 Posts

Default

One comment... From what I've read, copper is not the best thing to use for a thermowell when fermenting. Something about off-flavors and/or poisoning of the yeast?

__________________
jpc is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 04:15 AM   #5
erock2112
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2009
Location: Chapel Hill, NC
Posts: 301
Liked 1 Times on 1 Posts

Default

Yikes. I just found some articles confirming that. Looks like I'll need to rebuild using stainless. Thanks for the heads up!

__________________
HomeBrew Blog
erock2112 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 02:27 PM   #6
jpalarchio
Feedback Score: 1 reviews
Recipes 
 
Join Date: Jan 2009
Location: Holly, MI
Posts: 473
Liked 33 Times on 27 Posts
Likes Given: 10

Default

Quote:
Originally Posted by erock2112 View Post
Yikes. I just found some articles confirming that. Looks like I'll need to rebuild using stainless. Thanks for the heads up!
Check out Derrin's temperature probes if you haven't done so.

Highly recommended: http://www.brewershardware.com/probeEnds.htm
__________________
jpalarchio is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 06:45 PM   #7
dozer4412
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2009
Location: Madison WI
Posts: 61
Default

Very cool, nice work!

Quote:
Any ideas on mounting the LM34 probe in a mash tun?
Once you build the housing out of SS, maybe just use a compression fitting about 3 or 4 inches up the probe and screw it into the mash tun.


One question, you commented on using a detachable plug for the temp probe at some point. Many I ask what you plan to use to do this? I've heard some people use headphone jacks, but I was hoping there was something cleaner out there to accomplish this. Some kind of mountable two or three wire plug specifically designed for this kind of thing. Anyway if you find such an item please let me know.

The hardware side of this all still confuses me, I just want to get to the programming.
__________________
dozer4412 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 07:00 PM   #8
jpalarchio
Feedback Score: 1 reviews
Recipes 
 
Join Date: Jan 2009
Location: Holly, MI
Posts: 473
Liked 33 Times on 27 Posts
Likes Given: 10

Default

Quote:
Originally Posted by dozer4412 View Post
One question, you commented on using a detachable plug for the temp probe at some point. Many I ask what you plan to use to do this? I've heard some people use headphone jacks, but I was hoping there was something cleaner out there to accomplish this. Some kind of mountable two or three wire plug specifically designed for this kind of thing. Anyway if you find such an item please let me know.
I used RJ45 connectors on mine (primarily because I had the crimping tool) along with surface mount jacks and it's worked out quite well.

__________________
jpalarchio is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 07:16 PM   #9
erock2112
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2009
Location: Chapel Hill, NC
Posts: 301
Liked 1 Times on 1 Posts

Default

Quote:
Originally Posted by jpalarchio View Post
Check out Derrin's temperature probes if you haven't done so.

Highly recommended: http://www.brewershardware.com/probeEnds.htm
Those look really nice, but my sensors, once soldered to the heavy-guage wires I used, were a tight fit in the 3/8 OD copper tubing. Those probes are 1/4 OD and I worry that my sensors wouldn't fit at all...

I just ordered 3 feet of 3/8 OD SS tubing. Probes will be rebuilt once it arrives.

Quote:
Originally Posted by dozer4412 View Post
One question, you commented on using a detachable plug for the temp probe at some point. Many I ask what you plan to use to do this? I've heard some people use headphone jacks, but I was hoping there was something cleaner out there to accomplish this. Some kind of mountable two or three wire plug specifically designed for this kind of thing. Anyway if you find such an item please let me know.

The hardware side of this all still confuses me, I just want to get to the programming.
I was going to ask the same question. It'd be really nice to have everything built into one three-pin plug.

The hardware is actually a lot simpler than it looks. The Arduino has 6 analog inputs, a power supply and a ground. The LM34 connects directly to these three. The thermistors are just a bit more complicated. They use a voltage divider circuit: http://en.wikipedia.org/wiki/Voltage_divider with the thermistor as one of the resistors and a 10K resistor as the other. This circuit is then attached in the same way as the LM34 to the arduino. The arduino itself holds a program which interprets the voltage value and converts it into a temperature. I'm going to move most of this code off of the arduino and onto the computer, so that the raw voltage value is sent to the computer, which will allow the user to select what type of sensor is attached to each input, and the program will interpret accordingly.

EDIT:
Quote:
Originally Posted by jpalarchio
I used RJ45 connectors on mine (primarily because I had the crimping tool) along with surface mount jacks and it's worked out quite well.
I hadn't thought of that... would a TRRS plug work?
__________________
HomeBrew Blog

Last edited by erock2112; 01-06-2010 at 07:29 PM.
erock2112 is offline
 
Reply With Quote Quick reply to this message
Old 01-06-2010, 07:36 PM   #10
dozer4412
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2009
Location: Madison WI
Posts: 61
Default

Quote:
I used RJ45 connectors on mine (primarily because I had the crimping tool) along with surface mount jacks and it's worked out quite well.
Ok, I kind of understand, but am hardware retarded so could you explain a little more how one takes a standard two or three wire sensor, like a temp probe, and converts that to RJ45? Do you just splice open the cable, connect your two or three wires to whatever wire in the cable you like, then attach a standard RJ45 end to the other side?

Anyway I’m not very hardware savvy, but are you just using standard CAT5 as the cable then? I guess I’ve never looked at the voltage allowance for CAT5, but is it sufficient to carry 5v?

Quote:
The arduino itself holds a program which interprets the voltage value and converts it into a temperature. I'm going to move most of this code off of the arduino and onto the computer, so that the raw voltage value is sent to the computer, which will allow the user to select what type of sensor is attached to each input, and the program will interpret accordingly.
Yea, I plan to use something like the labjack to get all my raw voltage values back. Once I can get a double value into any .Net language I should be all set. It's just the process of actually getting those double values that's going to kill me.

Thanks for taking the time to explain this, I really appreciate it.


__________________
dozer4412 is offline
 
Reply With Quote Quick reply to this message
Reply


Quick Reply
Message:
Options
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arduino Stir Plate (digital speed control) Yuri_Rage DIY Projects 13 01-28-2013 11:58 PM
Arduino for kegerator temperature control. Orfy DIY Projects 19 04-21-2010 12:18 PM
Monitoring fermentation temperature. Octang Beginners Beer Brewing Forum 4 07-10-2009 04:49 PM
Monitoring temperature in plastic MLT mroberts1204 All Grain & Partial Mash Brewing 5 06-15-2009 07:01 AM
My arduino fridge control build. simpleton DIY Projects 4 01-09-2009 04:40 PM