Kegerator

Here's the first shot of what is to become a temperature controlled refrigerator.

(obviously I'm missing the refrigerator, but I've tested it on a small peltier box)

I'm using a Diecimila board with a Maxim DS18B20 temperature sensor & Matrix Orbital LK204-25-PC LCD. I plan on switching a large relay to control the minifridge in a similar fashion to previous implementations (http://www.uchobby.com/index.php/2007/10/08/arduino-beer-thermostat/). The final product will also include a Java app that interfaces the Diecimila with rrdtool on a webserver.

Let me know if anyone wants code :) - I should publish everything when I'm finished as well.

Hi,

I'm just starting to play with electronics at all and so I got the Arduino Diecimila board and now just want to play around with it. I also purchase some DS18B20 temperature sensors from Maxim and want to know how they work.

Can you help me out a bit with this?

Thanks! ;D

Sure thing!

Here’s how I wired the sensor up:

By following the example at: http://www.arduino.cc/playground/Learning/OneWire, I was able to come up with this basic code:

#include <OneWire.h>

OneWire ds(10);  // on pin 10
long temperature = 0;
int Fract = 0;
int Whole = 0;

void setup()
{
  beginSerial(19200);
}


void loop()
{
  byte i;
  byte present = 0;
  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
  //  Serial.print("No more addresses.\n");
    ds.reset_search();
    return;
  }

 // Serial.print("R=");
  for( i = 0; i < 8; i++) {
 //   Serial.print(addr[i], HEX);
 //   Serial.print(" ");
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
  //  Serial.print("CRC is not valid!\n");
    return;
  }

  if ( addr[0] != 0x28) {
  //  Serial.print("Device is not a DS18S20 family device.\n");
    return;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

  present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE);         // Read Scratchpad

//  Serial.print("P=");
//  Serial.print(present,HEX);
//  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
 //   Serial.print(data[i], HEX);
 //   Serial.print(" ");
  }
 // Serial.print("CRC=");
 // Serial.print( OneWire::crc8( data, 8), HEX);
  Serial.println("Kegerator Ver. 0.1 ");
  Serial.println("   www.swilly.tk");
  Serial.print("Temperature: ");

 // ACTUAL TEMPERATURE PROCESSING
 // NOTE: outputs the temperature as a whole number
 // (multiplies the decimal by 10000) - Serial.print won't do decimals
  long temperature = (long)((((data[1] << 8 ) | data[0]) * 0.0625) * 10000);
 
 // Formats the output as a decimal
  Whole = temperature / 10000;
  Fract = temperature % 10000;
  Serial.print(Whole);
  Serial.print(".");
  Serial.print((int)(Fract / 1000)); // rounds to 10th's
  Serial.println("C");
}

I’m not sure if it works, because I’ve adapted a bit from my use. I also know that it is really sloppy, but I plan on going back and implementing some of the features in my Java app. (CRC checking, address selection, etc.) later.

Also, you’ll need to change the line:

  if ( addr[0] != 0x10) {

to:

  if ( addr[0] != 0x28) {

if you’re strictly going from the example.

I had originally typed up a more thorough explanation, but Firefox crashed on me and lost everything :slight_smile:

If you’re a bit more technical, you may want to check this out as well: http://www.maxim-ic.com.cn/pdfserv/en/ds/DS18B20.pdf. It helped me understand how the actual temperature conversion from the raw sensor values to Celsius was being performed.

Let me know if you need anything explained more in-depth… I was a bit more hasty in the second version of the post.

I’ve been fooling around a bit with data collection lately, and have created this:
http://swilly.tk:20001/kegerator/kegerator.php
The blue line is the temperature, and orange is the compressor status.

It’s a php generated svg (firefox, safari, … basically only ie doesn’t support it). It will eventually be accompanied by some javascript which dynamically polls an api and re-draws the image accordingly.

I’ll probably get around to finishing up the lcd and everything in a few weeks when exams are over. More pics to come.