$USD
  • EUR€
  • £GBP
  • $USD
TUTORIALS BluetoothArduino

Controlling Remote Control Plug Sockets with Arduino

DFRobot Feb 20 2015 343

A remote control light was a really good idea when I bought the RF plug sockets. But having to fumble around finding the remote in a dark room was annoying and dangerous (once knocked over a glass of water onto a power outlet). So I decided to hack it and connect a motion sensor. Here’s how I did it.

Imitating the Remote

When a button is pressed on the remote a binary signal code is transmitted. The code is unique to that button. We can simply copy that binary code and use our own RF transmitter to broadcast it.

Ray from Rayshobby.net goes into detail about how you might record this code. He creates a small circuit to sniff RF signals using his computer’s audio-in. It’s a really interesting read and you can literally see how the remotes work, but there is an easier way.

RCSwitch is an Arduino library which helps you send and receive RF signals. The library contains every example you might need, including ReceiveDemo_Advanced which displays the signal from any 315/433MHz AM transmitter.

The binary code for one of my ‘on’ switches was 010001010100010101010101, and it was simply a case of using the library to send out that code using an RF transmitter.

Sensors

I used a PIR sensor to detect motion. They’re easy to hook up and code with. Arduino.cc has a very nice example sketch you could use, but I found a simple if(digitalRead(pirPin) == HIGH){ to work just as well.

Turning on during the day became a problem. I would leave my room in the morning and the light would turn on, so I needed to add a condition to only turn it on during the night. I used an LDR to do this. LDRs, or ‘Photo Resisters’s output a range of numbers depending on the light level. With some tweaking you can activate the light at just the right level of brightness.

Find the fully working code below.

source: Techmog

REVIEW