2

I took a picture of my mock setup to give a better idea of what I'm working with.

enter image description here

Basically, I'm will be using relays connected to my Raspberry Pi that I intend to use to control a series of lights (21 to be exact) via a web server. I already have the web controls working but I just need to scale up my current model. I haven't had any issues with my setup but one of my relay's response time seems to have slowed down after some use. I was wondering if I am causing some damage to them with my current set up, or if there's anything I can use to protect both my board and the relays. I've seen people talking about using transistors and resistors but they don't mention how to arrange them and my technical background in hardware isn't quite there yet so I can't figure it out on my own.

Here is the relay's schematic: enter image description here

and here's a closer look at the relay: enter image description here

  • 1
    The wiring is a serious concern. It violates the basic safety rules. The relay module is not suitable for the Pi - it will be unreliable from 3.3V – Milliways Aug 14 '18 at 23:19
  • 1
    Your picture suggests that you're working with household AC voltages - are those lights powered from AC mains? If so, the relay should be "in the box" at least - at very least. 220 VAC or even 120 AC can be lethal. – Seamus Aug 15 '18 at 2:11
  • Make sure of relay spec, the picture is too blurry for old man to read. They do come with different ratings. Also check the optocoupler rating- the relay may say 5V but the coupler MAY be good for 3.3V. Either way - have a good power supply for the relays itself - they are relatively power hungry and won't budge if your power supply does no give at least 2A strong output. – Jan Hus Aug 15 '18 at 3:17
  • 1
    Possible duplicate of Protecting Raspberry Pi from Relays – Dirk Aug 15 '18 at 8:05
  • The relay was built to work from a raspberry pi or arduino board. They're activated by low voltages and the 3.3V GPIO outputs are working just fine. I had to remove the relay from it's case because otherwise you wouldn't be able to see anything if I took a picture of a metal box (I'm assuming no one here has x-ray vision). Rest assured, the final product will be properly stored to maximize safety. – Dave Aug 15 '18 at 16:07
2

Re this part of your question:

... wondering if I am causing some damage to them with my current set up, or if there's anything I can use to protect both my board and the relays.

I. Damage and protection to my board (the Raspberry Pi):

Zooming in on the picture of (what I presume is) your "relay board", it seems to have all the protection you'd want when switching an inductive load (the relay coil). Note the diode connected across the relay coil just above the 2N5551 transistor: This is sometimes called a "snubber" diode, and it acts to limit the voltage spike when the relay is de-energized (V = L * di/dt :)

Another "circuit-friendly" protective feature for your RPi is the opto-isolator (817C in the picture schematic). This isolates your GPIO pin(s) from the relay board. (Note that I can only assume that you're using a GPIO pin to control the relays `cause you have no schematic, and didn't mention it in your question.) But assuming you are using GPIO pins for this purpose, be mindful that the relay board's supply voltage VCC is within SOL for the GPIO pins.

In summary, and based on the information available, your Raspberry Pi seems to be reasonably well protected in this setup.

II. Damage and protection to the relays:

This part of your question concerns the relay contacts, and there is much uncertainty due to lack of details in your question. But to address this question, let's first consider the physical characteristics of the relay contacts. These contacts are wee small metal pads mounted on an armature; this link has some pictures.

Operation of the relay is as follows: When the coil is energized (current flows through the coil), the NO contacts are moved such that two of them (one fixed and one moveable) make physical contact with each other. Once that happens, AC current from your wall outlet flows through those contacts and into your load (the lights).

However, contact closure is never initially absolute; there is always some "contact bounce" during the transition to a closed state. This "bounce" can cause significant problems if care is not taken because as the current is being stopped and started at a high rate there will likely be at least some electrical arcing (think of welding) caused by the voltage generated. Again, think of (V = L * di/dt) where di is large, and dt is small.

This "bounce" may damage the relay contacts as shown in this example. In general, the greater the current through the contacts, the greater the wear and pitting is on the contacts. This may also be exacerbated by the characteristics of the load. If the load is inductive, there can be significant arcing (think of a spark plug) that will destroy the contacts in short order if they are not protected.

You haven't told us much about your load beyond the fact that they are "lights". If they're filament light bulbs, you should know that their resistance is much less when they are cold, and this results in greater ac electrical currents when they are first turned on. This will last until the filament has heated up, at which point the resistance increases, and the current approaches its steady state value. Unfortunately, as you now see, this load characteristic is working against your relays; the greatest current occurs during the period of relay contact bounce. Unfortunately, there is not much you can do to remedy this in your circuitry. Your only defense is to select relays suitable for the load you're switching on and off.

In summary, the very first thing you should do is check the relay specs, and verify that their current rating will cover the current drawn by your lamps.

You should have some margin of safety in these ratings. If your lights are incandescent types, you must have a greater margin of safety; a margin sufficient to cover the inrush current. If you don't do this, your relays won't last long, and your experiment will present greater safety hazards for you.

Hope this helps - feel free to ask questions, and/or edit your question to add details we've covered here.

  • I think 10A @ 250VAC is plenty for any reasonable household light solution. Whether that spec can be trusted is another question. – Dmitry Grigoryev Aug 16 '18 at 8:15
  • Got it. I was playing around with the raspberry pi and turning the relays off and on very quickly to get the bulbs to light up in a cascading way (if that makes sense?) so maybe doing constant repetitions of that might have caused some arcing. Thank you! – Dave Aug 16 '18 at 20:26
  • @DmitryGrigoryev: If the 10A, 250V spec was in the question, I missed it. Do you mind pointing that out? – Seamus Aug 16 '18 at 21:38
  • It's visible on the pictures – Dmitry Grigoryev Aug 17 '18 at 6:56
  • @DmitryGrigoryev: So it is - thank you. Turns out this Tongling relay was the subject of another question here recently. I also see from the picture the UL logo silk-screened on the relay, but the logo looks a bit "off". And no published spec sheets for that relay part # that I could find. So it's still a bit of a gamble perhaps, but if those ratings are correct it should be suitable for purpose. – Seamus Aug 17 '18 at 12:12
0

5V relay modules are indeed not suitable for 3.3V signals. You are correct that the "LOW" level (0V) is the same whether your signals are 3.3 or 5V. However, the "HIGH" level is 1.7V lower, which means that you still apply 1.7V to your optocoupler+LED. Normally, that's not enough to produce any measurable current, but it's enough to have a LED with higher leakage and you suddenly end up in a setup where your relay is never completely shut down. This is exactly what can result in a relay reacting slower than others.

My advice would be to deactivate all relays (applying "HIGH" level to GPIO pins driving module inputs) and measure the current consumed by the module. Anything above 1mA means you're in trouble. (1mA is not nearly enough to have an effect on a relay, but such currents tend to change wildly with temperature)

One thing you can do is to buy several extra relay modules and bin the ones which don't work well with 3.3V. Of course there's no guarantee that the modules you keep will still work a few years down the road.

A proper solution would be to buy real 3.3V modules, or a 3.3 to 5V level converter like this one.

-1

I share the concern of the other commentators. The relay board you are using is not built for the raspberry, and running live 220v or 110V on an unboxed board like that is dangerous. In theory it should work, but practically, no. Just no.

We have used these relay boards meant for the raspberry:

1) https://www.seeedstudio.io/Raspberry-Pi-Relay-Board-v1.0-p-2409.html This board has no inputs, and four relay outputs. You can stack up to 8 boards - just assign a new binary address to each board. This will allow you to "scale" up to 32 lights.

2) https://www.element14.com/community/docs/DOC-69001/l/piface-digital-2-for-raspberry-pi This board has 8 inputs and 2 relay outputs, and is not stackable.

  • I understand your concerns. I have the relay boxed up but I took it out to demonstrate what was going on. My only issue with the relays you provided are their price is substantially higher than the relays I found. The relays are active low and take an input voltage of 0-5V to be switched. The GPIO pins are properly triggering them as needed and various product review on Amazon state the same. I'm still running 5V from the pi's 5V pin which powers the relays themselves (the JD-VCC pin). I'm confused what you mean about the incompatibility between the components? – Dave Aug 15 '18 at 15:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.