Temperature Monitoring
December 31st 2010 08:25 pm
I recently bought a used chest freezer on craigslist to store a lot of beef. I went in on half a cow with a co-worker. It seemed like every time I walked past the freezer the compressor was on and I became concerned that I might have gotten a bad freezer. I did what any self respecting geek would do and took some measurements.
In comes the arduino in about 15 minutes I’d found code to output temps from my DS18S20 temp sensor. I breadboarded up the sensor and threw it into the freezer. It was outputting the temp every minute or so.
I then hacked my way through my first processing sketch to take the incoming value and append the date / time to it. This created me a nice little csv file I could open in excel and make a pretty graph. The graph shows that the compressor is on nearly 50% of the time. I think this is due in part to the freezer only being about 1/5 full. I’m going to add some more stuff in there to give it some more thermal mass and see if that helps.
Below are all sketches I used and the graph I created. Thanks to all who contributed to the arduino / processing playground. I couldn’t have whipped this together so fast without your help. I tried to leave credits in the code wherever I found it. If I missed something please let me know! I only wrote about 5% of this code.
I should have done a better job labeling my axis, but I have since deleted the files…The vertical axis is temp in F and horizontal is time.
Arduino Sketch:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into pin 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire devices //(not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); void setup(void) { // start serial port Serial.begin(9600); //Serial.println("Dallas Temperature IC Control Library Demo"); // Start up the library sensors.begin(); } void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus //Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures //Serial.println("DONE"); //Serial.print("Temperature for Device 1 is: "); //Serial.print(","); Serial.println(DallasTemperature::toFahrenheit(sensors.getTempCByIndex(0))); delay(5000); } float printTemperature(DeviceAddress deviceAddress) { float tempC = sensors.getTempC(deviceAddress); //Serial.print("Temp C: "); //Serial.print(tempC); //Serial.print(" Temp F: "); //Serial.print(DallasTemperature::toFahrenheit(tempC)); return tempC; } Processing Sketch: // Serial Example by Tom Igoe import processing.serial.*; PrintWriter output; int lf = 10; // Linefeed in ASCII String myString = null; Serial myPort; // The serial port void setup() { // List all the available serial ports println(Serial.list()); // I know that the first port in the serial list on my mac // is always my Keyspan adaptor, so I open Serial.list()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[0], 9600); myPort.clear(); // Throw out the first reading, in case we started reading // in the middle of a string from the sender. myString = myPort.readStringUntil(lf); myString = null; // size(200, 200); // Create a new file in the sketch directory output = createWriter("/Users/jim/Documents/temps.txt"); frameRate(12); } void draw() { while (myPort.available() > 0) { myString = myPort.readStringUntil(lf); if (myString != null) { println(myString); output.print(hour()); output.print(":"); output.print(minute()); output.print(":"); output.print(second()); output.print(","); output.print(myString); } } } void keyPressed() { // Press a key to save the data output.flush(); // Write the remaining data output.close(); // Finish the file exit(); // Stop the program } |
Tags: arduino, DS18S20, excel, freezer, graph, processing, serial, temp

Valuable info. Lucky me I found your site by accident, I bookmarked it.
Beneficial info and excellent design you got here! I want to thank you for sharing your ideas and putting the time into the stuff you publish! Great work!
pretty helpful material, overall I consider this is well worth a bookmark, thanks
Nice topic – respect!
Weeeee, what a quick and easy soultion.