2

I'm trying to trigger eight different 5 V relays using an Arduino Atmega 2560. The relays (70Ω coil) are powered by an external 5 V source, and I'm trying to trigger them through a driving stage which contains for each relay an NPN transistor (2N3904) and a 1 kΩ resistor directly connected to digital pin of the Arduino.

The relays in my application are supposed to be driven 2 by 2, not all of them at once.

My problem is that I don't succeed in triggering the relay with digital pins of my Arduino; once I connect it to the resistor, the voltage of the digital pins drops from 5 V to 0.4 V or less. The transistor needs only 7 mA to be triggered, the output current of the Atmega2560 pins is 20 mA max.

I tried with an external 5 V source, it triggers correctly showing 10 mA maximum of current through the driving stage.

enter image description here

19
  • 1
    @timemage it is 1kohms i did the conception.
    – TESLA
    Commented Nov 24, 2020 at 13:32
  • 1
    A base resistor of 1kOhm at 5V will give you a max base current of 5V/1kOhm = 5mA, which is less than 7mA. That could prevent the transistor from working correctly (as you wrote, that it needs 7mA). have you tried with about 500Ohm? That would give you 10mA. Does the pin correctly output 5V, when nothing is connected to it?
    – chrisl
    Commented Nov 24, 2020 at 13:51
  • 1
    Please show a schematic.
    – ocrdu
    Commented Nov 24, 2020 at 13:56
  • 3
    Are you setting the pin to OUTPUT? You could be "activating" the pin with the internal pullup resistor otherwise, which would exhibit the symptoms you describe.
    – Majenko
    Commented Nov 24, 2020 at 14:11
  • 2
    Without showing us your schematic (edit the question), you problem is not really understandable. e.g. do you set the resistor direct in series to the relay or did you add it to the base of the NPN transistor. You said the relay sees only 0.4 volt if the resistor is in place. That sounds like you have the following connections: emiter of the transistor --> resistor --> relay. That does not work. Commented Nov 24, 2020 at 14:27

3 Answers 3

1

Your circuit will no longer work. The original transistor you used was a NPN, you have changed it to a PNP connected somehow as a low side driver. It is important to show the emitter, as it tells us what type of transistor it is, leaving it out as you have done causes many of us to assume you have done it correctly ie the emitter is connected to the ground. Here is a Copy of a circuit from electronics-tutorials that uses a simple MOSFET: https://www.electronics-tutorials.ws/blog/relay-switch-circuit.html Note the 10K resistor from the port pin to ground, that guarantees it will be off during reset and setup.

enter image description here

0

If the coil is 70 ohms and it's driven by 5V, it should draw about 5/70 = 71 mA. That's pushing the 2n3904 a bit hard, and doesn't even account for inductive effects. (It's a small-signal transistor.) Do you have an NPN power transistor to try, just as a test? If its current gain (beta) is too low, use a Darlington configuration by combining it with your 2n3904. (2n3904 base from digital out resistor, emitter drives power NPN base directly, both collectors are connected together to the bottom of the coil, and the power NPN emitter is the effective emitter of the just-created "super transistor" with high beta and power handling.) Be sure to use an anti-kickback rectifier (1n4001)across the relay coil.

3
  • sorry i did a mistake, its actually a 5V relay, it means 71mA through the relay. taking in account the 2N3904 gain i would have arround 7mA through the transistor this is why im using a 1k resistor.
    – TESLA
    Commented Nov 24, 2020 at 14:17
  • Just to be sure: The relay coil must be between +5 and the collector, with the emitter grounded.
    – Boggyman
    Commented Nov 24, 2020 at 14:41
  • yes i just added a schematic please look at it.
    – TESLA
    Commented Nov 24, 2020 at 15:13
0

Good Job, you are right on, the transistor is rated at 200 mA which is adequate for the job. The flyback diode will protect your system and the transistor. the drain source drop would be maybe 0.01V on a bad day depending on the RDSon. You will probably need a little lower value base resistor depending on the gain of your transistor. I would use something between 220 and 510 ohm. It should work fine. Using a darlington would hurt you instead of the ~.7 volts drop across the collector it would become about 1.4 volts, leaving the relay with 3.6V assuming you are actually getting 5V. My preference would be a small logic level avalanche rated MOSFET. Use a 50 Ohm resistor in the gate circuit and it will be just fine. Use something like a 10K pull down resistor between the gate and source, that will guarantee that it will be off during reset.

3
  • Why do you need any gate resistor at all with a MOSFET? They have capacitive inputs, and draw almost no current.
    – Duncan C
    Commented Nov 25, 2020 at 2:23
  • 1
    When the gate pulse starts, the capacitive input will appear as a short to the output pin (for a few nanoseconds). The gate resistor limits the current at that time. There is a lengthy discussion about this on the Arduino Forum which you might find interesting.
    – Nick Gammon
    Commented Nov 25, 2020 at 5:38
  • To prevent oscillation, it does not happen on all circuits but a good design practice. This happens because of the miller capacitance effect during the time the channel in enhancing.
    – Gil
    Commented Nov 25, 2020 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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