Recently, I was awakened by a crash—my blinds had fallen off my apartment’s bedroom windows. Then, later, I saw that water was dripping from the holes left behind in the frame. I replaced the blinds with curtains, and the drip continued, on an annoyingly intermittent schedule, over the days that followed.
While I waited for the landlord to track down and repair the problem in the apartment upstairs, I needed something that would alert me when I was home and the dripping started. And for the times I wasn’t home, I needed something that would automatically move the curtain as well in order to avoid water damage. Given that the situation was both urgent and temporary, I needed something I could throw together as a quick fix. Fortunately, I had just the thing to aid me in my time of need: the Nanospark.
Nanospark is a US $140 system for controlling electronics with your iPhone or iPad. A cable (owners of newer iOS devices will need an adapter) connects the phone to an interface board that has eight digital inputs and outputs, six analog inputs, and two analog outputs. A touch to an iOS app lets you read inputs or send commands to the board. Most interesting of all is that you can use an iPhone’s sensors and messaging systems to control electronics.
My plan was to use the Nanospark with the Colour Detector sample app, which Nanospark offers as a free download. I wanted the device to spot when the ceiling started dripping, trigger a motor to shepherd the curtain out of the way, and grab my attention. In the daytime or when my room was lit, I wanted to be alerted via a loud buzzer and an LED, but when it was dark and my lights were off (when I—or my neighbors—were more likely to be asleep), I wanted to be alerted just by the LED.
I downloaded the detector app once I got an old iPhone set up. (My iPod Touch was too old to be updated to the required version of iOS.) I soon learned that while it could indeed turn the board’s outputs on and off as color values changed in a designated part of the camera’s view, the app was inflexible. For example, it could pay attention to only one area at a time in the camera’s field of view, so I couldn’t watch the dripping on one half of the screen and check for light on the other half. It was something I could surely program myself by writing my own iOS app, but this was supposed to be a quick fix. I decided to detect the level of light in the room with a photoresistor wired to the circuit controlling the buzzer, bypassing the Nanospark.
A quick word about the Nanospark ecosystem: There isn’t one yet. There are a few short tutorials, and there are some videos that optimistically describe manufacturing tasks you could automate with Nanospark. The Controller app—more like a debugger, and the only existing app available for download besides the Colour Detector—lets you trigger the outputs individually or read out voltages from the inputs, but there’s no “if my phone detects this, then do that” interface. If you’re going to have to program all your software from scratch anyway, using Apple’s XCode (which has a nontrivial learning curve), maybe Nanospark isn’t the go-to manufacturing and tinkering solution it aspires to be. But the device is young; a database of user-created apps and tutorials could eventually fill that gap.
Back to apartmentland. To sense errant droplets, I made a crude color-changing water sensor by attaching a white piece of fabric (a scrap from my newly installed curtains) atop a red piece of plastic placed on a jar. When wet, the fabric turns sheer and the camera can pick up the higher red values in its field of view. I tied this action to a digital output on the Nanospark, which delivers enough current to power a breadboard circuit with a small $5 five-volt motor and an LED. Then I connected another circuit with a photoresistor and the buzzer, all of which I’d borrowed from an Arduino starter kit. I housed all this in an old Nintendo DS case. It conveniently had holes in the front for the LED and photoresistor to peek out and a magnet in its top to hold the motor in place.
When the iPhone spots a drip, the motor reels in a string that draws the curtain aside and whips the fabric and plastic panel off the jar. Then, when the red is no longer visible, the motor stops and the buzzer and LED cut off. When it happens in the middle of the night, it’s mildly alarming, even with the buzzer silenced, but when it happens later in the day, I trot off to investigate.
It’ll all be over soon, I hope, when my landlord finally fixes the terrifying pipes-and-expanding-wood combo he found upstairs. But when that time comes, I have a long backlog of problems in my apartment that could be solved by a watchful eye and quick, simple motor response. With a relay and access to stronger power, the same setup could easily power something beefier, like a system that unlocks my door when I hold a colored card to the peephole or one that fine-tunes the light based on the height of someone sitting in a chair.
I could think of a million and one more complicated ways to use my iPhone’s sensors—or a combination of those and remote messaging—to control and regulate my apartment. But most of those are beyond the amount of time I’m willing to spend without access to more customizable apps.
Until then, my trusty Nanospark, iPhone, and DS case full of parts will be the quickest of quick fixes.
This article originally appeared in print as “DIY Water Leak Detector.”