Refridgerator Monitor

A few weeks ago my wife noticed our refrig­er­a­tor tem­per­a­ture was start­ing to go up and down pret­ty dra­mat­i­cal­ly and she was wor­ried about the impact it would have on our food, and her shop­ping bud­get if we had to throw a bunch of stuff out. Luck­i­ly I had a spark device and sen­sors on hand, so I threw togeth­er some hard­ware and code to mea­sure the tem­per­a­ture in the refrig­er­a­tor and the amount of time the door was open.

First, the hard­ware: Spark Mak­er Kit This con­tains every­thing I used in this project. A spark device, the wires, bread­boards, capac­i­tor, temp sen­sor and light sen­sor.

A pic­ture is worth thou­sands of my hor­ri­ble inef­fi­cient words.
Great instruc­tions on the set up can be found here: Mea­sur­ing the Tem­per­a­ture

I then added the light sen­sor from the kit on A5, using the fil­tered pow­er. After test­ing and such I extend­ed the wires as you will see in the fin­ished prod­uct.

Here is the code for the spark core:

char resultstr[64];
int lightsec;
void setup()
pinMode(A7, INPUT); // A7 Analog Input is temperature
pinMode(A5, INPUT); // A5 Analog Input is light
lightsec = 0; // Variable to keep track of how long light is on
Spark.variable("result", &resultstr, STRING);
void loop()
int temp = analogRead(A7); // Read temp data
int light = analogRead(A5); // Read light data
if (light > 2200) { lightsec++; } // If light is on add a second to count
// Put the results out for Google Script to grab
sprintf(resultstr, "{\"temp\":%d,\"lightsec\":%d}", temp, lightsec);
delay(1000); // wait for a second

And here is the code for the Google Script run­ning in the Google Sheet. An exam­ple and instruc­tions can be found here: Log­ging and Graph­ing Data

function collectData() {
var sheet = SpreadsheetApp.getActiveSheet();
var response = UrlFetchApp.fetch("[DEVICE_NAME]/result? access_token=[TOKEN]");
try {
var response = JSON.parse(response.getContentText()); // parse the JSON the Core API created
var result = unescape(response.result); // you'll need to unescape before your parse as JSON
try {
var p = JSON.parse(result); // parse the JSON you created
var d = new Date(); // time stamp
sheet.appendRow([d, p.temp, ((((p.temp*3.3)/4095)-0.5)*100)*1.8+32,p.lightsec]); // Add the line and convert the temp to F
} catch(e)
Logger.log("Unable to do second parse");
} catch(e)
Logger.log("Unable to returned JSON");

Final­ly I put the whole con­trap­tion into the refrig­er­a­tor and start­ed mea­sur­ing.

I let it run for about 36 hours, mea­sur­ing every 10 min­utes.


Here is the data, and it appears the wife might be cor­rect and a 10–15 degree swing is to much for our refrig­er­a­tor.

It also seems we do not go into the fridge much. About 4 mins over 36 hours.

I guess it is time to call the repair man!

2 thoughts on “ Refridgerator Monitor

    • If I had mul­ti­ple refrig­er­a­tors I wouldn’t have this prob­lem! Actu­al­ly, get­ting up above mid 40’s is an issue any­ways. I think res­i­den­tial refrig­er­a­tion is only sup­posed to vary by ~5 degrees.

Leave a Reply