Problem

Ever been laying in bed and realize you forgot to turn the light off? Well I have. Apparently one to many times because I chose to take matters into my own hands...

Solution

I was wandering through Target one day and came across a remote controlled outlet sitting in a clearance bin. Huzzah! My problems were solved. I could control my pesky light with a remote. But why stop there? Why not control it from my phone, through the web?

This was the spark that started it all, but I've sinced upgraded to more robust hardware. The major problem with using a third party remote controlled outlet was that there was no way to poll the switch to get its current status. I had no way of knowing whether the light was on or off, other than of course looking at it. So, I ended building my own solution from the ground up using a popular hardware stack used in various tutorials online.

Hardware

The hardware is on its second iteration. You can see version 1.0 here.

The hardware uses two nrf24l01 radios, one connected to a Raspberry Pi acting as a control hub, the other connected to an Arduino controlling a relay to turn the light on and off. The pinout for the Raspberry Pi and the schematic for the Arduino hardware can be seen here.

### NRF24l01 pinout
# 1 GND  =>  ground
# 2 VCC  =>  3.3V
# 3 CE   =>  GPIO22
# 4 CSN  =>  SPI CE0
# 5 SCK  =>  CPI CLK
# 6 MOSI =>  SPI MOSI
# 7 MISO =>  SPI MISO
# 8 IRQ  =>  ?

Here's a few pics of the completed hardware. Excuse the sloppy wiring, it is a prototype after all.

switch hardware front
switch hardware back

Web Interface

I wrote a simple interface to control the light as well as display the current status. Not much else to say, just checkout the video below.