No. See here:
There are two problems with your setup. Firstly, you appear to switch the relay directly from D12 on the Arduino. This means that you almost certainly exceed the maximum ratings of the microcontroller; it's not designed to source that much current. Secondly, the diode should be as in the picture above: in parallel with the coil (not series), with the cathode to the positive supply.
The npn transistor drawn in the snippet above can be replaced with a MOSFET; it's a matter of preference.
As @rsmls says, it should be parallel with the coil. And I agree about using a transistor unless it's a tiny reed relay that doesn't need much current to switch it.
Yes. In fact, you don't want anything connected to Vin if you're powering the Nano through the 5V pin.
Good morning,
So I'm trying to figure out how to add the transistor but I'm just not getting it. What am I trying to switch? I think I have the emitter and base correct, but there does the collector go? This is all new to me so be gentle lol. Here's the diagram that I'm working with, it also shows the diode across the relay coil.
You want to use the small signal from the GPIO to switch the current through the relay coil.
Disconnect relay pin 1 from Arduino pin D12. Connect a resistor (e.g. 560R or 1k) between transistor base and Arduino D12. Connect transistor collector to relay pin 1. Emitter to GND as you've drawn it is OK.
Okay here's what I came up with based on your instructions (which were super easy to follow, so thank you for that.) One question though, I assume the transistor is switching 5 volts, but how much current is it switching and where is it coming from. Probably a really bad question but I'm confused (story of my life )
OK, great. Now, I'd pick something smaller for R1 instead of 4k7. 560Ohm to 1k sounds about right. 4k7 should probably work, but it would be better IMO to make it a little smaller.
This is another issue you need to address. See remarks below.
This depends on the relay.
You specified this type: SRD-03VDC-SL-C. This is a 3V relay, meaning the coil should be actuated with 3V. Not 5V as you've drawn. I would suggest using relay SRD-05VDC-SL-C instead.
Assuming you use the 5V version, the datasheet of that part indicates it draws 70-75mA or so. This is the constant current the transistor needs to pass (the peak current as it triggers is higher, but don't worry too much about this; it'll work out in practice). So your transistor needs to be able to switch 75mA or so at 5V. The maximum collector current of the BC547 (and its modern variant BC847) is 100mA. This means you're running it kind of close to its limits. I'd suggest using something beefier; maybe simply 2n2222 or so (rated for 600mA).
You can think of the current through the transistor as being limited by the resistance of the coil, which you can actually measure with your multimeter. The math says it's about 66 ohms, which is the resistance of the long string of copper wire that makes up the coil.
And no, you can't use the 3.3V output of the Nano for the coil. It won't deliver enough current.
The relay is being used as a kill switch for a vehicle. A friend of mine has one of those cars that is easily stolen and it wasn't cost efficient to have a kill switch installed professionally. So I built one for him. The GPS side of it works great, it seems to be good within about 3 ft. But when he sends a text message to the unit it is supposed to open the relay so the car can't start.
That was another problem I was having, in Easy e d a I couldn't find the correct relay in the footprint that I needed so I used that one. But I am using a 5 volt relay.
The relay coil will be drawing current in either normal use or in anti-theft mode, depending on how it's set up. I wonder if there isn't a better way. I've never used them, but I understand there are bi-stable relays. It takes current to turn the relay on or off, but in either state you don't have to continue to provide current to keep it that way.
Assuming a car (post #37), I'd not worry about it too much since there will either be a regular 12V battery which will probably last a couple of weeks with a small relay being powered from it, or an electric vehicle that basically is just a massive giant battery on wheels anyway.