Introduction: Arduino Remote Control

About: Lazy Old Geek

Problem: Living out in the middle of nowhere, I have problems getting fast internet, so I have a big antenna on my roof (see picture). The connection is borderline so it seems to help if I recycle power on my radio/antenna. Being a Lazy Old Geek, it is not convenient to unplug and re-plug the power connector.

Solution: Often, I am reclining on my bed with my laptop, (see easylaptopstand), so I decided to build a remote access power resetter (see first picture) with an Arduino clone. I can aim my laser pointer at the resetter and it will automatically cycle the power on the radio/antenna.

Parts list:
Phototransistor: Digikey SFH310 $ 0.38
Relay: Digikey Z146-ND (G2RL-24DC5) $3.22
Transistor: 2N3904
LED book lamp: Dollar store
Laser pointer: Dollar store
Anarduino (Arduino clone): Ebay $18.90 for 2

USB-BUB: seems to be cheaper at Wulfden $16
http://wulfden.org/TheShoppe/pa/index.shtml

Step 1: Simplified Electronics Theory

Skip this step, if you’re not interested or already know it.

A phototransistor is basically an on-off switch like a light switch or a pushbutton. But it’s controlled by light instead of mechanically pushing the button. When light illuminates the phototransistor, the two leads will (basically) be shorted together. When the light is removed the two leads will be disconnected. (see picture)
Specifications: The specification that is most significant is whether it is an NPN or PNP. My design is based on an NPN phototransistor. The data sheets have a lot of information about wavelength, sensitivity and (collector) current. Unless you are designing for a specific application, these shouldn’t be that critical. Most phototransistors will respond to typical light sources like LEDs and laser pointers. One thing you may need to worry about is the distance between the light source (especially an LED) and the phototransistor. With the LED and phototransistor, I had, they had to be within about three inches of each other. That’s why I decided to use a laser pointer where I can be across the room.

A relay is (usually) an electromechanical switch. (See pictures) The relay is the upper part of the drawing. The little curly cue thing is the coil. It is an electromagnet that is a magnet when voltage is applied to the coil. When there is no voltage, the COM (COMmon) connector is connected to the NC (Normal Connected) connector.
When the coil is activated with voltage, the magnet actually moves the COM connector. The COM connector is disconnected from the NC and is connected to the NO (Normally Open) connector.
So depending on what you are trying to do, you can open a circuit with the voltage or close a circuit or both.
By the way, this is called SPDT (Single Pole Double Throw). The particular relay I am using has two sets of contacts, so is a DPDT (Double Pole Double Throw) but I am only using one set for this application.

The second drawing shows an important feature of a relay labeled “Isolation.” What that means is the coil is completely electrically and physically isolated from the contacts.
Specifications: The specifications for relays are divided into the input (coil) side and the output (contacts) side.
On the input side, the voltage and current are important.
On the output side, the current capacity is the most important.

A transistor is an electronic amplifier with three leads. See picture. There are two types of transistors, NPN and PNP. I will only be using NPN. Basically a little current between the base and emitter controls (amplifies) a lot of current between the collector and emitter.

Step 2: Safety

There are two dangers working with 110Vac.
One is electrical shock to a human (or dog). At 110Vac, it takes very little current (5-25mA) to cause harm to a person. That is why all bathrooms and many kitchens are protected with special AC outlets called Ground Fault Interrupters.
Two is shorting out AC when plugging in a miswired device. This can result in severe arching, and blown out equipment and outlets. I know this by personal experience as I did this when I was a kid.

**********WARNING:*****************************************************
I will include precautions and warnings as they come up, but if you don’t understand what I write or why I suggest things, do not try any of the power strip parts of this project.
**********WARNING:*****************************************************

Step 3: Design

Overview: The radio/antenna on my roof is powered by 110Vac. I wanted to switch this off and on without having to unplug it. My first design was to take a relay, connect it to a power supply, install it in a power strip, and plug the radio/antenna into the power strip. I ran some wires from the power supply to a pushbutton. This worked okay.
But I am a GEEK, so I decided to convert it to Arduino control. I also decided to use a laser pointer to recycle the AC power. Another reason for using an Arduino is that future plans include being able to recycle power over a computer network.

Power strip: Why did I choose a power strip? A power strip already has a cord on it to plug into a 110Vac outlet and also an AC socket so that the radio/antenna power cord can be plugged into it. It is easy to disconnect to work on and if there are any problems. (See picture) The one I selected also had screws to hold the base plate so it is easy to disassemble and reassemble. It also has a built in circuit breaker.

Relay: Why did I use a relay? One reason is to isolate myself and the Arduino from 110Vac for safety reasons. The second reason is that so I can control the 110Vac circuit with 5Vdc from the Arduino. These are two very different and incompatible voltages. This is the isolation factor mentioned earlier.

Relay specifications: So I need 5Vdc for the input voltage. The radio/antenna requires 110Vac at 0.3A so the output needs to be able to handle that much at least. The G2RL-24DC5 is spec’ed at 5Vdc 80mA with contacts rated at 250Vac 8A so it is more than adequate.
TIP: Input requirements are what is needed to function. Output or contact ratings are maximums; anything less is okay.

Arduino: I selected the Arduino-clone, the Anarduino mostly on price. http://www.anatools.com/anarduino/
The Anarduino is made by Anatools.com but seems to be available only on ebay.com. (See picture)
Advantages: Cheap, includes Arduino-programmed ATmega328, with headers it can be plugged into a protoboard. Works with a USB-BUB.
Disadvantages: Does not have a power supply regulator. Has a resonator instead of a crystal so may not be as accurate for critical timing projects. Cheap IC socket and harder to solder than many kits.

Step 4: Implementation

Problem: The first problem is the relay power requirements: 5Vdc at 80mA. The Arduino (actually, the ATmega328) will output 5Vdc at about 20mA maximum.

Solution: There is an easy solution for this called a transistor. I have a bunch of old printer PCBs so I looked for some transistors. Transistors are usually three legged devices and often identified starting with 2n. I happened to find a 2N3904 so looked up the specifications online. The most important to me was that it was an NPN and collector current maximum is 200mA.

Wiring: To limit the current I added a 10K resistor to the base. (See schematic). To wire up a transistor, you must know which leads are E, B, and C. (See transistor drawing) It is not really clear in the picture but I soldered one lead of the resistor into the D3 pin of the Anarduino. The other side of the resistor is connected to the base (B) of the transistor. The emitter (E) is connected to a ground. The collector is connected to one lead of the speaker wire. The other speaker wire lead is connected to 5V on the Anarduino.

Step 5: Wiring the Power Strip

Open up the power strip. (See picture) The one I used has three standard dual AC outlets. From the right on top, basically the black wire from the AC cord connects to a switch, then the circuit breaker, then to first outlet. The first outlet is connected to the second and the second to the third. The two connections on top of each dual outlet are actually shorted together so all the black wires are electrically connected.
The white wires on the bottom follow the same pattern.

Important: Standard U.S. AC wiring specifies that the black wire is the hot side and the one that you want to switch. If you look at the switch on the right, you can see that the black wires go to the switch but that the white wire goes right to the circuit breaker.
If you look at the left outlet, you will notice a little black item with some electrical tape on it. That is the relay.

Wiring: I can’t get a picture of the wiring so will describe it instead. I cut the black wire between the second and third outlets. One side goes to the common pin, 3 on the relay. (See drawing of relay pinout) The other side of the black wire goes to the NC pin, 2 of the relay. {What this means is that when the relay is not energized, the two wires are connected and AC is on the last two sockets. When the relay is energized, the connection is opened and no power goes to the sockets}. Pins 1 and 8 are the coil pins and are connected to speaker wires coming from the Anarduino. For this relay it doesn’t matter which wire is connected to which side of the coil.
**********WARNING:*****************************************************
Make sure the two black wires are not touching any other pins of the relay or anything else in the power strip. I isolated them with hot glue.
Make sure the two (speaker) wires coming from the Anarduino are only connected to pins 1 and 8 of the relay and not touching the black wires or anything else in the power strip.
**********WARNING:*****************************************************
  If you have an DMM, measure the two AC leads of the power strip plug. They should be open, (infinite resistance) with nothing plugged in.
Otherwise plug it in very carefully.

Step 6: Wiring the Phototransistor

This yellow object is a book LED I bought at the dollar store. It has a nice little clamp. Well, it only worked for about a day, than I had some trouble turning it on and off. (What can you expect for a dollar.) I thought it would make a nice holder for my phototransistor. First it has a little reflector for the LED and second it had a nice little clamp.

Conversion: Well, I don’t have any pictures of it torn apart but here’s what I did. I unscrewed the LED cover. The LED was mounted on a little round PCB. I removed the LED and soldered the SFH310 phototransistor onto the PCB leaving the long leads. The PCB didn’t really have any circuit connections. Next I drilled a couple of small holes in the side just below the threads. Then I bent the two leads and fed them through the holes.
So I decided to connect the phototransistor right across the reset push button. The idea was that activating the phototransistor would be just like pushing the reset button. For this phototransistor, the original short lead is the collector and I wired it as shown in the diagram. In this particular case, it shouldn’t hurt if you connect it backwards, it just won’t work. Just unsolder it and flip it over. Now what I did was just solder it to the pins of the reset button. The little reflector helps focus the light so (theoretically) not as much light is needed to activate the phototransistor.
Aren’t I clever? Probably not.

To power the Arduino, I currently have the USB-BUB plugged into the Anarduino. I’m powering the USB with a cellphone USB charger.

Step 7: Arduino Code & Conclusions

Attached is the code Resetter.zip

Arduino code

/*
  Resetter
  Turns on a relay on for ten seconds, upon reset

*/

  // set pin numbers:
const int relayPin = 3; // the number of the relay
int oneTime = 1;


void setup() {
pinMode(relayPin, OUTPUT);
}

void loop(){
if (oneTime) {
// turn relay on:
digitalWrite(relayPin, HIGH);
delay(10000); // Hold for 10 seconds
digitalWrite(relayPin, LOW);
oneTime = 0;
}
}

Comment: For this application, I wanted to do a ten second reset only one time after a reset. The standard Arduino has a loop function that will repeat itself until power is lost or another reset occurs. I used the oneTime variable so that it will only turn on the relay once for ten seconds then do nothing.

How it works: When I shine the laser pointer at the phototransistor, the phototransistor activates, putting the Anarduino into reset. Once the laser light is removed, the Anarduino starts running. The relayPin (3) goes high turning the transistor on and connects the ground pin of the relay to ground. This activates the relay, disconnecting power to the bottom two outlets of the power strip where the radio/antenna is connected. After ten seconds, the relayPin goes low turning off the relay and power is reconnected to the radio/antenna. Since I set oneTime low, the if statement is no longer used. See pictures.

My application is rather specific but I hope the information and techniques might be useful to others for their own applications.