I have a single transistor relay amplifier driven by GPIO output of Raspberry PI. The amplifier works reliably and is not causing any immediate problems. Still, if I leave the relay flipping on/off every second, the computer board somehow gets reset after an hour or about. I suspect that my relay still generates too much noise and I need to take more measures then just a flyback diode which I already include.


simulate this circuit – Schematic created using CircuitLab

Would adding a capacitor between base and emitter of the transistor help? By idea, when GPIO level changes, this capacitor should cause gradual closing/opening of the transistor rather than abrupt. This would give much more time for the flyback diode to engage. I understand this would slow down the switching, but 200 ms or about delay is acceptable for this relay.

If you think this would work, that would be a recommended capacity of this capacitor?

Please also tell if could do something else can be done to make this amplifier really quiet. I cannot easily get rid of the relay because the circuit it controls is totally undocumented (no clue about the voltage, current, polarity, requirements, just that < 12 V and this is a signal circuit so unlikely a lot of current). I only have a single power source to power up both computer and amplifier.

I currently have no oscilloscope in my disposition so my possibilities to investigate the noise spikes are limited.

  • 4
    \$\begingroup\$ Try replacing the relay with a 145 ohm resistor and see if your circuit resets every hour. \$\endgroup\$ – Andy aka Jan 20 '20 at 9:19
  • \$\begingroup\$ the capacitor will cause more heating of the transistor \$\endgroup\$ – Jasen Jan 20 '20 at 9:26
  • 2
    \$\begingroup\$ If the 145 ohms instead of the relay solves the issue, then add a decoupling capacitor (like 100 uF) between +5 V and ground as close as possible to the relay and transistor. Currents run in loops, when the relay switches on/off there's a spike in the current, the spike needs to be contained in a short loop through a decoupling capacitor. \$\endgroup\$ – Bimpelrekkie Jan 20 '20 at 9:33
  • \$\begingroup\$ By idea the transistor should stay either closed or saturated open most of the time, so not heat too much. \$\endgroup\$ – h22 Jan 20 '20 at 9:40
  • \$\begingroup\$ It could be noise from the spark between the relay contacts when it switches. Try without a load, does it still reset? \$\endgroup\$ – bobflux Jan 20 '20 at 10:20

Yes, it can help.

I suggest to use capacitor 1...10uF here, it will make time constant (R*C) about 2...20ms, but the real OFF time will be about 10x shorter, because only starting part of capacitor unloading curve will be effective.

The voltage on capacitor will change between 0V and about 0.7V - so you can use electrolytic capacitor for any voltage.

BTW: if the flyback diode is not enought, it means that you probably have problems with ground wiring (to thick wire, too long wire etc).

  • \$\begingroup\$ Looks promising. There is one more more ground pin on the GPIO connector, I will also connect it in parallel to the current ground pin. \$\endgroup\$ – h22 Jan 20 '20 at 9:38

I've had an issue with the same thing while trying to control a relay using a microcontroller output port and a darlington pair. I had random cases where the relay switching caused my MCU to reset. I remember placing a bypass capacitor at the power supply of my microcontroller to fix this. Since you can't do that with a raspberry pi (it probably already has bypass capacitors), here's a schematic from the darlington chip ULN2004AN that has internal flyback diodes for inductive loads like yours: enter image description here

I'm not sure how effective this would be against noise suppression, but you could add diodes from ground to the GPIO of the pi like they do. Additionally, if there's anyway for your to place the pi farther from the relay circuitry or shield it using something go ahead and try that as well.

Also, I don't see why adding the capacitor you suggested would cause problems other than the delay you mentioned. I think a typical value is 100 nF or 0.1uF for bypass capacitors, so you can start there and increase if the noise doesn't seem to be bypassed.

  • \$\begingroup\$ What are these three pin components 'COM', 'Output C' and 'E' ? \$\endgroup\$ – h22 Jan 20 '20 at 10:02
  • \$\begingroup\$ COM is the supply powering the circuits/inductive loads, output C would be the collector of the specific darlington pair, and E is the emitter of each pair, which in this case is all GND. Here's a link to the datasheet: link \$\endgroup\$ – OhmerSimpson Jan 20 '20 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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