Relay and current

Not sure if this is the correct section to post this question....but I am building a music control to switch lights on/off with relays. The fuse in the lights are rated at 3 Amp (yes...Christmas lights- led type). I am looking at the relays below and am thinking that the solid state will not be able to handle the current...? The solid state is rated at 2 Amp, while the mechanical is 10 Amp. I've seen posts about these relays, but have not seen this question. Forgive me if this has been answered elsewhere. If so please post the link and I'll take a look.

And I guess I would also like to ask if anyone has an opinion about these products. I've read that they are normally closed and you have to drive the pin LOW (as opposed to HIGH), so I think I can handle that in my sketch, and I've heard that the documentation sucks, and that the mechanical relays are somewhat noisy. Any feedback would be appreciated. I tried the seeed relay shield and made that work fine....just not enough relays so I'm looking at these.

http://www.sainsmart.com/relay/8-channel-dc-5v-relay-module-for-arduino-pic-arm-dsp-avr-msp430-ttl-logic.html http://www.sainsmart.com/8-channel-5v-solid-state-relay-module-board-omron-ssr-4-pic-arm-avr-dsp-arduino.html

Measuring the actual current drawn by those lights would be the first step. The fuse is a CYA thing. It may be overrated by a factor of two or more. Look at the wiring. Does it look like it can handle even one amp?

Hi, These type relay boards are easy to use. See this page of the ArduinoInfo.Info WIKI:

http://arduino-info.wikispaces.com/ArduinoPower (For general Arduino Power information) and specifically http://arduino-info.wikispaces.com/ArduinoPower#4-8 About this type board, and the Active-Low question)

Example code there shows how to utilize the Active-low property to guarantee no relays are activated at power-up or Reset until you want them to.

Just as a couple of general comments to start-off… There are solid state relays that are rated for currents well over 100 A, but for maximum currents above ~5 A they get costly in a hurry. Also, you are right that ideally the fuse should fail before the relay. Therefore the relay probably should have a rated maximum current above the fuse’s value.

You didn’t mention the voltage level or if it was AC or DC, but I’m presuming since these are Christmas lights they are being powered from the mains and since your location is Florida, that’s 120 VAC. If these presumptions are true, there is an alternative method if you just want to switch the entire LED array on and off, a PowerSwitch Tail II. Now if you want to do things like dimming or flashing specific LEDs on and off you’ll still need a relay, or perhaps high voltage MOSFET, based control circuit.

Edit: PaulS is correct that the fuse could be well over rated for the actual current draw, the fuse’s main purpose would be to prevent an electrical fire. However if it’s pratical to have a relay with a higher maximum then you eliminate the possibility of replacing a relay before the fuse. :wink:

If you use mechanical relays and you try to switch the lights on and off in time to the music, that's a lot of wear on the relays and they may be quite noisy. Maybe the lights are marked with their power rating? You could also try replacing that 3A fuse by a 1A fuse. If it doesn't blow within a day or so of continuous use, you can safely assume that the lights take well under 2A.

Thanks everyone for your responses. PaulS, yeah, I'll check the current. I don't want to play it too close to tolerance, so we'll see. Part of the wife's "budget approval" process for buying Arduino items is the Christmas Light project. I can only imagine what a small fire would do to the available funds in the budget. :)

The fuse in the lights are rated at 3 Amp (yes...Christmas lights- led type)...

The solid state is rated at 2 Amp...

yeah, I'll check the current...

Check the current, but I'm pretty sure you'll be fine. Power = voltage x Current, so 3 Amps is more than 300W! That would be a ship-load of power (and light) for a string of Christmas lights... Especially LED Christmas lights.

Is there a Wattage rating listed somewhere? I looked-up a string of 70 LED lamps online, and it's rated at 4.8W (0.04 amps = 40 mA). That "feels" about right to me.

The only "gotcha" could be an "inrush" current when the lights are switched-on. Highly unlikely, and the only you'd find that is if you smoke a relay.

Just wanted to send an update and perhaps some insight for others that use these relays…and perhaps get some advice.

As a recap, I wanted to control flashing sequence of glass block christmas decorations I made last year. Basically flashing them to music. I did purchase the SainSmart 8 channel relay (mechanical, not solid state) and although they are loud, I am able to mute the clicking enough with a box and insulation. At first, I powered the relay from the Arduino power. Big mistake, the regulator chip was so hot it damn near burned my finger. I figured it was a power issue and after some reading on line I realized I should supply both the Arduino and the relay with their own power supplies.

My sketch is working well (included below) based on readings from the analog pin 5…which is connected to headphone output from laptop, iPhone, iPod, etc. Be careful, I was using an old boom box with Line In connections to piggy back the headphone feed so I could hear the music while feeding it to the analog pin, and there seemed to be a loop back voltage or spike that disabled my USB connections from the laptop. Freaked out for a while thinking I blew the USB port, but a hard reboot brought them back (whew…changed connections to isolate my poor Arduino and laptop). I’ve included the sketch just in case someone wants to copy and mess with it.

My question is this…What I really want to do is read frequency ranges, so that I can flash specific lights based on (or at least associated closely with) notes from instruments or singing. I was able to build a project (my first) where the Arduino plays a song by using the tones and melody controls. I mapped all the notes and delays to play the song and it worked pretty well. I’ve also seen projects that use Vixen to map light sequencing to the music patterns, but that means you have to map every song. I’d like to read the analog input and sequence from whatever song was being fed to Arduino on-the-fly - so to speak. I’m thinking I have to use an A to D (or the other way around) converter to be able to capture notes or frequencies, but I’m not sure. And…since just about everything in life is math, I would think there is a way to do it with calculations against the readings in the analog input.

I have photos and a video of this project, so if someone is interested just let me know and I can post them or provide links.

So there’s the update. Thanks to the smart people on this forum for their continued assistance and knowledge.

(Be kind, you’d have to have a vivid imagination to call me a programmer.)

/* Lights to Music Analog Input (pin A5) via Headphone Output
 * --------------
 *
 * @author: rfbase
 * @hardware: Arduino Uno
 * SainSmart 8 Channel DC 5V Relay Module - therefore the digitalWrite(relayPinX...) is driving LOW
 * Sending data from a headset outlet on laptop, iPhone, or iPod - volume is typically very high on the client device
 * Analog read is typically between 10 and 140 with the volume all the way up 
 */

unsigned char relayPin2 = {2};
unsigned char relayPin3 = {3};
unsigned char relayPin4 = {4};
unsigned char relayPin5 = {5};
unsigned char relayPin6 = {6};
unsigned char relayPin7 = {7};
unsigned char relayPin8 = {8};
unsigned char relayPin9 = {9};

int analogPin = 5;
int sensorValue = 0;
int pause = 85;

void setup(){

  Serial.begin(9600);
    pinMode(relayPin2,OUTPUT);
    pinMode(relayPin3,OUTPUT);
    pinMode(relayPin4,OUTPUT);
    pinMode(relayPin5,OUTPUT);
    pinMode(relayPin6,OUTPUT);
    pinMode(relayPin7,OUTPUT);
    pinMode(relayPin8,OUTPUT); 
    pinMode(relayPin9,OUTPUT);
  }
  
void loop() {

  sensorValue = analogRead(analogPin);    // read the data/voltage from the input pin

  if (sensorValue > 10 and  sensorValue < 17) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin2,LOW);
    delay(pause);
    digitalWrite(relayPin2,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 18 and sensorValue < 22) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin3,LOW);
    delay(pause);
    digitalWrite(relayPin3,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 23 and sensorValue < 28) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin4,LOW);
    delay(pause);
    digitalWrite(relayPin4,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 29 and sensorValue < 35) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin5,LOW);
    delay(pause);
    digitalWrite(relayPin5,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 36 and sensorValue < 48) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin6,LOW);
    delay(pause);
    digitalWrite(relayPin6,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 49 and sensorValue < 59) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin7,LOW);
    delay(pause);
    digitalWrite(relayPin7,HIGH);
  Serial.println(sensorValue); 
} 
  if (sensorValue > 60 and sensorValue < 69) { //if the voltage is in this range hit the LED
    digitalWrite(relayPin8,LOW);
    delay(pause);
    digitalWrite(relayPin8,HIGH);
  Serial.println(sensorValue);
}
  if (sensorValue > 70) { //if the voltage is above 70 hit the LED
    digitalWrite(relayPin9,LOW);
    delay(pause);
    digitalWrite(relayPin9,HIGH);
  Serial.println(sensorValue);
}
}

What you probably want is a fast Fourier transform. This changes the sound into frequency information. There is a tutorial. http://www.arduinoos.com/2010/10/fast-fourier-transform-fft/ It's probably more math than you were thinking of, but it will give you amplitude by frequency. Makes a good light show. The other way you could do it would be with an electronic crossover. That way it's done in the hardware. But, doing it all in the Arduino would be a more elegant solution. Of course, since you posted this before Xmas, you probably don't care any more.

Hi,
OR, do it in hardware with more channels available. See BlipTronics shield: http://www.bliptronics.com/item.aspx?ItemID=116

This has 7 bands of frequency with separate outputs. This is used in some of the high-end stereo systems for the Oh-Cool! display.

You could buy the chip, and make you own… See: http://www.bliptronics.com/item.aspx?ItemID=116 and discussion: http://arduino.cc/forum/index.php/topic,8328.15.html