Issues operating the PowerSwitch Tail 2

Hello, First of all I am new to Arduino and this is the first actual project that I am doing (other than blinking an LED)! I am trying to use my arduino and a PowerSwitch Tail to control a desk lamp so that when I type a 'H' and press enter into the serial monitor it will turn on and when I type a 'L' and press enter it will turn off. I have written my code below.

My actual problem is that when I type 'H' in the serial monitor and press enter, the indicator LED turns on and I hear the relay clicking but the lamp plugged into the other end isn't turning on. And when I type 'L' and press enter the relay clicks again and the LED turns off. I am using an Arduino UNO and the PowerSwitch Tail 2 240V kit. I have the +in of the PowerSwitch Tail to the 5V pin on the Arduino, I have the -in to the signal pin on the Arduino (pin 11) and the ground on the PowerSwitch tail to the ground pin on the Arduino.

I hope one of you can help me solve this problem. Thanks, Matt

int currentState;
int prevState;
int powerPin = 11;

void setup() {
  pinMode(powerPin, OUTPUT);
  digitalWrite(powerPin, HIGH); // Cut the power when it starts up
  if(Serial.available() > 0) { // If any serial data is avaialable:
    prevState =; // Set it as prevState
  Serial.println("Type 'H' and press enter to turn on the power and type 'L' and press enter to turn off the power.");
  Serial.println(" ");
  Serial.println(" ");

void loop() {
  currentState =; // Now set the currentState
  if (currentState != prevState) { // If a message has been sent:
    if(currentState == 76) { // And it is a 'L':
      digitalWrite(powerPin, HIGH); // Send the signal
      Serial.println("Power is off"); // And say that the power is off
      Serial.println(" ");
    if(currentState == 72) { // Or if it is a 'H':
      digitalWrite(powerPin, LOW); // Don's send the signal
      Serial.println("Power is on");// And say that the power is on
      Serial.println(" ");
  prevState = currentState; // Reset the state so that it works the next time through the loop

If you hear the relay clicking on and off with the appropriate input, the problem is your lamp, not the Arduino code or the powertail.

I have also tried connecting it to several other devices and none of them are working. Thanks, Matt

It sounds like a relay problem. Check if the contacts of your relay are closing properly.

Thanks for all the help guys,

How can I check that the contacts are closing properly on the relay?

RUMPIKUF: Thanks for all the help guys,

How can I check that the contacts are closing properly on the relay?

What you do to check is ridiculously simple. You take the wires from the PowerSwitch Tail and connect them to GND and Vcc on the Arduino - with the correct polarity. Connect nothing else to the Arduino, but connect the "tail" to the mains and the lamp. When you plug the Arduino into its power supply, whether a separate supply or the USB, the lamp should turn on. This test indicates whether the "tail" is functional; if it is not, well you have to sort that out. If the Arduino power LED does not come on when you test the "tail" this way, it would indicate a short circuit.

I rather thought the PowerSwitch Tail used a SSR and you would not hear a relay in it?

Thanks, I will test that. The instructions on the kit say that you should be able to hear the relay clicking. So it mustn't be a SSR.

Thanks again everyone for helping me out. I have identified that it is definitely a problem with the powerswitch tail. I have contacted where I bought it from asking for a replacement.

Thanks, Matt