Sunday, February 5, 2012

Arduino Fridge Temperature Monitor

The poor old fridge didn’t seem to be keeping things as long as it had used to, so I wanted to find out what temperature it was actually running at inside. A perfect opportunity for a small and practical Arduino project:

Goals:

  1. Arduino Controller.
  2. Dallas One Wire temp sensors to monitor temperature inside the fridge.
  3. LCD display showing temperature.
  4. Logging of temperature to an SD card.
  5. Real Time Clock, so data is logged with a time stamp.
  6. Ethernet connection, so data can be viewed remotely. (Missed)

Main Material:

  1. EtherTen
  2. 5pcs DS18B20 1-Wire Digital Thermometer Dallas DS1820
  3. RTC I2C Chip  (PCF8583T I2C Clock/Calender IC)

Construction:

The one wire sensor was mounted onto a small piece of strip board. The Dallas one wire can run with only 2 wires, but it sounded as though this would be a bit of messing about and I only had a short run, so decided to go with 3 wires. Power, ground and signal. Two female 4 pin headers and a male header were added to the board to allow connection to and from the board with different pin types. The male header was on the outside, but should have been on the inside to minimize risk of shorting. Hot glue was applied to the base of the board to remove the risk of shorts.  

I stripped some wire out of a cat5 cable to connect the sensors up.
My home made RTC stamp (Post to come) was utilized again. The LCD was just plugged into a breadboard. A LCD I2C backpack is on the to do list to make it easier to deploy an LCD in future.

A battery pack was used to run the unit on the fridge. I really need to get a small A/C supply. Whilst there are lots of small plug packs kicking round, they all seem to be unregulated, so a small regulator stamp is on the to do list also. With good batteries (NiMH) the pack lasted about 8 hours. I left the back light off and I’m sure leaving the LCD off would add a lot of life.

Three sensors were daisy chained. One on top, outside, of the fridge. One at the bottom inside and one near the top inside. The one wire sensor bus (middle pin) was connected to pin 2 on the Arduino, along with a 4.7k pull up resistor (connected to 5v). I found that if a 5th sensor was added to the network the 4.7k value was too high. You can have up to 127 sensors on the one bus, so not sure what value pull up you’d need with a full bus!

Data was logged to the SD card on the Etherten. There was not sufficient memory to add the Ethernet port, so that goal was dropped.

The code from Arduino site was used to interrogate the sensors and get each serial number.  My final sketch then had the serial numbers coded into an array so the sketch can scan each sensor.

The procedure to get the temperature is to address a sensor and ask it to perform a temp conversion, which is dumped into it’s scratch pad. Then we reset the bus, address the sensor again and read the scratch pad. The conversion takes ~750ms, which means scanning 3 sensors takes ~2.5 seconds. With parasite power you can’t do anything else on the bus whilst a conversion is in process. As I have power and sense I think I could ask all three sensors to perform the conversion, wait 750ms, then scan all three. I might be able to scan all three in under a second. To be tried out.

The data logged to the SD card was pulled out via the serial port display, then copied and pasted into Libre Calc so that a chart of the temperature change over the lat 24 hours can be created. I logged the temp to the SD once a minute. The LCD is updated every scan.

The fridge was found to be running at or above 10C during the day when the door is being opened, and dropping down to only 7.5 overnight. This is way to warm. After some adjustment it’s now running at around 8C during the day and about 3C at it’s coldest, though the motor is on a lot more (of course). Opening the door almost always sees the temp go up by at least 3C.

I think a new fridge is probably needed. Given this one is about 25 years old I guess it’s done okay. The refrigerator is a single door unit with manual defrost. so it’s as simple as they come.

I’d like to be able to flag when the door was opened and also when the motor is running. The door could be monitored with a light dependent resistor, though would mean more wires into the fridge. Monitoring the motor would be trickier. something for another day.

The following sites were useful when developing the code:

  1. http://www.arduino.cc/playground/Learning/OneWire
  2. Arduino sample code in the IDE

My code is on github: https://github.com/TypeFaster2/Fridge-Temp-Monitor

Hopefully code has enough comments to make it easy enough to follow. Any questions, then just ask.

Notes

  1. typefaster posted this