Electrical – Trouble turning on relay using PNP transistor

arduinomicrocontrollernpnpnprelay

I am having problems turning on this relay:
https://omronfs.omron.com/en_US/ecb/products/pdf/en-g6qe.pdf
Using a transistor whose base is connected to a digital signal of an Arduino Nano.
The schematic I am using is attached. I have tried both, BC558 (PNP) and BC549 (NPN) transistors. Neither of these works. I would've figured the PNP should work because it is a high side switch but it almost seems that the Arduino Nano does not supply enough current to switch on the transistor. That is because when hooking the transistor's base straight to a power supply it does work but once again the Nano just can't seem to handle it. I am pretty novice at this so I am looking for some help. What am I missing here?
Thanks in advancemy schematic

Best Answer

schematic

simulate this circuit – Schematic created using CircuitLab

Do something like the above. You have the following problems:

  1. You need a better transistor (and you have damaged the one you have anyway)
  2. Even with a better transistor you need more base current to drive almost 300mA (but too much, as in grounded the base without a resistor, will damage the transistor)
  3. You need a flyback diode, or the transistor can be damaged by even one operation

Potential problems.

  1. Make sure your supply can handle the required current. Often it's better to use a higher voltage supply for the relay, such as 12V or 24V, which means less relay current (coil power will stay about the same) and this also helps avoid problems with the relay disrupting the MCU. That usually means using an NPN transistor since the circuit you are using won't work with a common-ground higher voltage supply (it would always be on).
  2. You can 'flip' the circuit so HIGH = ON if you want, just use a 2N4401 and make sure the diode polarity is reverse biased. Make sure you get the diode polarity correct from the beginning in either case or you'll need a new transistor.
  3. The base current is close to the maximum the MCU used in the Nano can supply. It would be nicer to use a MOSFET, however there are few appropriate MOSFETs available in through-hole packages so I have not suggested that. There are many, many available in SOT-23 and other SMT packages with stellar specs and those would be far preferable. AO3401 is one that works very well from 5V (or 3.3V). The circuit is similar to that with a PNP transistor however you may want to put 100K from gate to source in case the output is floated.

For what it's worth, just the other day, I lashed up a circuit with a relatively lower power relay (9V 360mW driven by an 8050 NPN transistor) driven by a Nano to run a test on an embedded system by interrupting and re-applying the power at random intervals.

enter image description here