Feed on
Posts
Comments

Update: check my blog post here for an even better and simpler way to decode remote control signals

For a while I’ve been looking for a way to switch household power line (110V) devices. One of the simplest options is to use a relay that is connected to the power line. This is easy in concept but quite dangerous to work with. You don’t want to accidentally touch the power line wire and shock yourself. A much better option is to use the powerswitch tail, which insulates the relay and the relevant circuity inside a plastic enclosure, leaving only two MCU pins to interface with. Much safer. But you still have to run wires between your MCU and the power socket. I am more interested in an wireless option.

Recently I purchase a set of remote controlled switch sockets from Amazon. It comes with one remote and three sockets, each of which can be individually switched. The whole package is quite cheap. The way this works is that you plug the sockets into the wall, and when you press a button on the remote, the corresponding socket will switch, thus turning on or off the device connected to the socket.

I took apart the remote control and found that the circuit is quite simple. It’s based on an HT2262 remote control encoder and a 434 MHz transmitter circuit. In fact, the schematic of the circuit is well documented in the datasheet of the encoder:

From the schematic, it’s quite clear that when a button is pressed, the input voltage is fed to one of the encoder pins (as well as the VCC pin of the encoder). Then the encoder will send the signal to the RF transmitter circuit. The RF signal will be received at the power socket side and decoded. Very simple. Now, to use my Arduino to interface with this power switch, all I need to do is to simulate a button press by sourcing a positive voltage to wires labeled SW1, SW2, SW3 etc. It turns out that the HT2262 can work with a fairly wide range of voltage: from 4V to 18V. Clearly the 5V output from an Arduino IO pin falls within the acceptable range. So I can simply connect those wires individually with Arduino I/O pins, and write a program that outputs HIGH momentarily when I need to switch a device. The only downside is at 5V the transmitting range is limited. The higher the input voltage, the longer distance it can transmit. So a more flexible design is to have a ‘source’ driver to supply higher than 5V to the encoder.

This can be done by using a transistor based high-side switch. Here is a schematic:

Basically, when the IO pin outputs low, transistor Q1 (NPN) turns off, and its collector is in high impedance status. Hence Q2 (PNP) is also off. Now, when the IO pin outputs high, Q1 conducts, driving the gate of Q2 low. Therefore Q2 also conducts, sourcing +12V voltage to the encoder. The reason to use such a high-side driver is to be able to switch a high voltage (>=12V) using a relatively low-voltage (<=5V) control signal from the MCU.

I implemented this method on a small proto-board. Since the remote control has 3 buttons, I made 3 copies of the above high-side driver, and the entire circuit fits nicely inside the remote control cover. I soldered five wires out: +12V, GND, and three control wires. A picture is shown on the left.

With this modification, I can now switch power line devices such as home lights and heaters using a microcontroller. Better, I can connect the remote control with my OpenSprinkler Controller, thus I am able to control power line devices through a web interface. The video below show a demo. Enjoy!

24 Responses to “Use Arduino to Interface with a Remote Controlled Power Switch”

  1. Kevin says:

    Whats the max Amps they are rated at? I can’t find anything on the load they can take.

    • ray says:

      (Sorry, my previous comment was not relevant).

      I just took a look at the ratings, these sockets are rated at 10A @ 120V.

    • ray says:

      Today I had a chance to take apart the power socket (the receiver side). I noticed that inside there is a relay rated at 16A @ 250VAC. I assume this means it can handle up to 16A even though the spec says 10A.

  2. Cyrus Morrell says:

    Nice write-up. I have a remote-controlled outlet at home and have been wanting to hook an Arduino up to it as well, but I was thinking about using an optocoupler instead of transistors. Do you think that will work or will the optocoupler have too much resistance to complete the circuit?

    • ray says:

      I think optocouplers would work just fine. The input of the encoder is probably MOSFET based, so it’s activated by voltage instead of current. But I should do a test before I can say for sure.

  3. Vaidas says:

    Hi, nice idea, was thinking about something similar when i will ran out of wires that were planed in design phase of my project :)
    One question, you say that 5V downside is transmitting range. Do you have a calculation what range is critical?

    Thank you
    Vaidas

    • ray says:

      I haven’t done any experiment to see how far 5V will get me vs. 12V. For transmitting in a single room or across a couple of walls, perhaps 5V is sufficient.

  4. DogP says:

    Nice writeup! I did something very similar with the Belkin Conserve ( http://www.belkin.com/conserve/switch/ ), which uses the same HT2262 chip, so your article very much applies to one of them as well. They’re available at several local stores (Home Depot for sure), as well as Amazon. Basically they’re the same as you have, except full power strips, and rated for 15A (IIRC).

    I collect arcade games, and got sick of climbing over machines to turn them on… and I made a touchscreen jukebox, so I figured turning games on/off with the touchscreen would be cool too. I hacked one remote and interfaced it to a Parallax Propeller microcontroller, which talked to the PC over USB. I then wrote a PC app showing the layout of my arcade… so you touch the games you want to turn on or off.

    I ended up running my remote off 12V to keep good range… but there were still a few places that had a hard time being reached (in my basement through foundation walls and arcade cabinets). What made a huge difference for range was adding an external antenna. I simply made a half wave dipole out of two strands of ribbon cable… which at 433MHz is about 6.5″ on each side. Being exact isn’t really that important though… just about anything is better than the PCB antenna. I cut the trace to PCB antenna to get it out of the circuit, attached one wire to that stub, and the other wire to ground (and oriented them in a T shape).

    If you’re interested, you can see a screen shot and some info in this thread: http://forums.arcade-museum.com/showpost.php?p=1355100&postcount=44 and http://www.projectvb.com/arcade/pics/screenshot.jpg … and the arcade/touchscreen in action here: http://www.projectvb.com/arcade/ .

    Pat

  5. KyleC says:

    I purchased the kit that was linked to, and it looks like they updated some of the components to surface mount versions. That said, I am still really new at working with electronics, do you have any more detail about where you hooked up the arduino digital pin and ground pin at each switch?

    • ray says:

      @KyleC: if you look at the schematic of HT2262, each switch is connected to +12V on one side, and a resistor on the other side (which is further connected to the IC). The side you need to hook up wire to is the resistor side. This should be fairly easy to identify if you look at the circuit board, locate the switches, and find out which side is connected to a closeby resistor. Alternatively, you can use a multimeter (use continuity measurement) to find out which side of the switch is connected to the +12V line, then the other side is what you need to hook up wire to.

  6. Steduiono says:

    Hi my x10 remote is 5v, what can i do ?

  7. Erica K says:

    Bless you for the high-side transistor switch diagram. That is just what I needed.

  8. jens says:

    Isn’t pressing a key on the remote toggling on/off? so how do you ensure that the sofware and the receiver side are in sync?

    • ray says:

      Yes, pressing a key on the remote will also toggle the switch. The software can’t ensure it’s synced with the switch because this is only one-way communication. However, you can use those switches that have separate on/off buttons, and the software can send on or off signals at regular intervals to make sure it’s in sync.

  9. Dmoles says:

    Can you control it with a web interface without having to use the OpenSprinker controller?

    • ray says:

      Of course you can. OpenSprinkler is just an Arduino based controller, you can use any Arduino and in fact any microcontroller.

  10. Lester Aponte says:

    https://www.youtube.com/watch?v=CbX17sxbk68&feature=youtube_gdata_player
    Hi I was wondering if you could give me the code you used in this video, im trying to replicate what you did
    Thank you

  11. Joey says:

    Hi if I am using those switches that have separate on/off buttons what would you recommend to make my software send on or off signals at regular intervals to make sure it’s in sync? wouldn’t sending the signals at intervals turn the device on then off or vise versa? Basically my question is, if I last turned on a device and using the arduino and then I go and manually turn off the device, how can I get that information to my software?

    Thank You

    • ray says:

      There is no simple way of getting feedback because the remote control here is one way communication. You can repeatedly send the same signal at regular intervals.

  12. D says:

    For the transistor based high-side switch, you made it right?

    Is it possible to just buy a high-side switch and use that?

    • ray says:

      Not sure if there is any off-the-shelf high-side switch you can buy. If there is, then sure it should work too.

Leave a Reply