Fridge Cam

What Should Connected Appliances Do?

“Simplicity is the ultimate sophistication.”
Leonardo da Vinci

Let’s take a moment to think about connected appliances (or “Smart” appliances if you’re a marketer) – those expensive, futuristic home units with touchscreen LCD’s and an overabundance of software features. At least, that’s what we saw plenty of at this years CES. Should a connected fridge really have Evernote integration? Should it track expiry dates, or tell you what foods are in season? Should it tweet, sync with Google Apps, or play Star Wars Angry Birds in HD? Increasingly, those are the kind of innovations we’ve seen demoed by the large appliance manufacturers – and it’s exactly the wrong approach they should be taking when designing these products.

A refrigerator has a simple purpose – prolonged food storage. The data associated with storage is inventory. So naturally the core function of an internet-connected fridge is to provide us with a tally of its contents. That’s it. Luckily, we already have a good model for taking a quick inventory – opening the door and looking inside. Our eyes and memory do the rest. A brief glimpse immediately tells us if we forgot to buy eggs last week, how many bags of milk are left (a Canadian thing), and if the fruit looks spoiled.

The most basic connected fridge that fulfills its purpose is one that takes a picture of its contents and pushes them to your devices. It provides you the opportunity to take a glimpse inside the unit wherever you are (probably the grocery store), just like you were at home. This approach is so brain-dead simple and easy to implement with some basic components, and yet we haven’t seen it from manufacturers. Instead, we can tweet.

We hacked together our own connected fridge that snaps shots every time the door opens and uploads them to the cloud. It took barely any time to construct (since it was patched together with masking tape and rubber bands) and used some very basic components. In actuality, the site to host the images took longer. The result is very rudimentary and ugly, but it works and communicates exactly what it should – inventory. Take a peek inside.

Build your own connected fridge.

Necessary Parts:

Wire a reed switch (ground, vcc, and signal) to the Raspberry Pi. We used GPIO4 for signal. Attach the switch to the door hinge at the top of the fridge. Glue a magnet to the top of the door such that when the door is at an open position, it’s directly under the reed switch. This will send a signal to the Pi.

Connect the cameras to the Pi and embed them in the fridge. We were lucky enough to have an opposing wall so the cameras could be mounted outside, but that’s an unusual setup. Embedding inside would be a lot more time consuming and would involve drilling through door for wire passthrough, plus resealing so cold air does not escape.

Next, you need to program the Raspberry Pi to watch for the signal from the reed switch, take photos, and send them up to the cloud. There are many ways to do this, but ours was with fswebcam, and some basic node.js.

Install fswebcam:

$ sudo apt-get update
$ sudo apt-get install fswebcam

Install node.js

$ wget http://nodejs.org/dist/v0.8.19/node-v0.8.19.tar.gz
$ tar -zxf node-v0.8.19.tar.gz
$ cd node-v0.8.19
$ ./configure
$ make
$ sudo make install

Install the GPIO package in your project directory:

$ npm install gpio

Write a simple node program that takes photos from the cameras when GPIO reads the value 1 from pin 4. After the photos are taken you can upload them wherever you want. We push ours to S3 using knox.

var gpio = require("gpio");
 
function takeShot(device) {
    var filename = device + '.jpg';
 
    // Spawn the webcam child process.
    var spawn = require('child_process').spawn,
        fswebcam = spawn('fswebcam', [
            '--device', '/dev/' + device, 
            '--no-banner', 
            '--resolution', '800x480', 
            '--rotate', '90',
            '--jpeg', '95', 
            '--save', shots_path + filename
        ]);
 
    // Log fswebcam output.
    fswebcam.stdout.on('data', function (data) {
        console.log('stdout: ' + data);
    });
 
    // Log any errors.
    fswebcam.stderr.on('data', function (data) {
        console.log('stderr: ' + data);
    });
 
    // continue processing after it has taken photos
    fswebcam.on('exit', function (code) {
        // Do stuff, like saving/hosting your images.
        // We used knox (https://github.com/LearnBoost/knox)
        // to push the photos to S3.
    });
}
 
var gpio4 = gpio.export(4, {
   direction: "in",
   ready: function() {
 
        gpio4.on("change", function(val) {
            if(val == 1) {
                takeShot('video0');
                takeShot('video1');
            }
        });
 
    }
});

That’s it! Our office fridge is now open for public scrutiny: fridge.teehanlax.com

This is a simple project, but it opens some great questions for discussion – namely, how should we be designing our appliances? What value can we add to them? When is adding features actually a detriment? Let’s talk about it on Branch.