We all have these 5V Arduino relay breakout boards. They work on 5V, and expect a 5V control signal from your controller.
They work very well in that 5V / 5V setup. But these days, most microcontrollers have 3.3V for a logic high, not 5V. And these boards don't work well with that, because:
Electronics (sort of)
The majority of these breakout boards use a traditional BJT transistor to switch the relay, with a 1K basis resistor.
The 5V input voltage, with a 1K basis resistor, will drive the transistor in saturation. But when your logic level is 3.3V, it doesn't (if it does, it's marginal). The relay will not switch with confidence.
To make a transistor saturate at 3.3V input, in this scenario, we need more base current (some members may chime in with the correct transistor graphs: the DC resistance of the 5V relay I'm using is +- 40 Ohm so all parameters can be calculated).
I did not go the formal way to investigate what the best resistor would be. The 1K resistor in the original design is a compromise anyway (just like the 1K resistor for the on/of led and input led). I used my jellybean transistor sense and decided that 500 Ohm would do. (well, I know that 500 Ohm is OK-ish, and it allows me to just solder a 1K resistor on top of the one that's already on the breakout board.)
Solution
Use 5V as the relay board Vcc. The coil needs 5V, there's no way around that.
Solder a 1K resistor on top of the basis resistor of your breakout board. That puts 2 1K resistors in parallel and gives us a saturated transistor. The relay will click with confidence.
LTSpice simulation files (I used a 40R resistor to represent the relay):
Top Comments