Earlier, I saw the post about the BrewPi and I got excited. I mean really excited. After reading up on it, I decided that I wanted to give it a shot and build one. However, there was at least one thing that I wanted to change. I didn’t want to crack open the fridge and start messing with the circuits inside. That’s when I came across a blog post describing how to hack a wireless power switch and control it with an arduino. This sounded much simpler and safer. Also, I added a light sensor to the netduino in order to detect whether or not the power was on.
Hacking the Remote Control
To modify the remote control, I followed the steps listed here. Here’s the circuit to build:
Here are the connections to the remote control:
Additional details can be found in the original blog post
Writing the Code
The code is fairly straight forward. We are going to write an event handler so that when the button on the netduino is pressed, our code gets called. To do this, we declare the button to be an InterruptPort:
InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);
Then we add an event handler to the OnInterrupt event:
button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
To start out, we are just going to toggle the state of the onboard LED:
private static bool isLedOn = false;
private static OutputPort led = new OutputPort(Pins.ONBOARD_LED, isLedOn);
private static OutputPort d0 = new OutputPort(Pins.GPIO_PIN_D0, false);
static void button_OnInterrupt(uint port, uint data, DateTime time)
if (data == 0)
isLedOn = !isLedOn;
Now, if we push the button, the LED should turn on, and if we push the button again, the LED should turn off.
Our ultimate goal is to turn on/off the remote power supply, so inside the if statement, we will add the following code:
What this does is that it turns on the d0 (digital 0) output port, sleeps for 100 milliseconds (0.1 seconds), and then turns off the d0 output port. This is equivalent to pushing the button on the remote control, holding it down for a fraction of a second and then letting it go.
Adding a Sensor to Detect When the Power Is On
If you read a couple of follow up posts to the blog that this is based on, the author ended up ditching the power switches used in this blog for different model so that they could be more certain whether or not the power was on. Another option is to add a light sensor and detect whether or not the light on the front of the power switch is on. This short video shows the light turning on when the switch is turned off:
So, by placing a sensor next to the light, we can determine whether or not the light sensor is on. The circuit for the light sensor is a really easy one, and looks like this:
All that is left is some code to read the sensor and write out the value to the screen:
AnalogInput a0 = new AnalogInput(Pins.GPIO_PIN_A0);
int val = a0.Read();
By doing this, we can then tell whether or not the light is on, which in turn lets us know whether or not the power is on.
Here’s a video demonstration of the project:
In this project, I hacked into a power switch remote controller in order to control it with a netduino, and implemented a light sensor to make sure that the command that I sent to the power switch was correctly received and executed. Hopefully, I’ll be able to build upon this and hook it up to a fridge!