I must say i don't fully understand how pnp/npn transistors works in a circuit, having done this, i don't get how this schematic works:
In particular i have two questions :
Assuming there is an external voltage supply to power the relay , in the emitters pin of the transistor flows a current more or less equal to the one who's flowing in the relay. This current it's superior to the Arduino's capability both to emit and to sink. So if the emitters is linked to the arduino ground, how's arduino handling it? I assume the ground pin too can't absorb high amount of current, right? (if this is true, may you tell me the exact value?)
If we are using a low voltage relay, it can be powered via arduino let's say via digital pin n, but a new problem arise, in the digital pin isn't now flowing an amount of current higher than the recommended value of 40mA ?
The transistor is used here as an electronic on-off switch. The only current the Arduino has to provide is that flowing through the transistor's base (which is very, very small). The current that flows through the relay's coil (and the transistor, via collector and emitter) doesn't "run back" into Arduino via the ground connection. It simply returns to the power supply connected to the coil.
I think you can connect "Relay Power V+" to Arduino 5V ouput. Don't remeber the max current value, though.
Oh ok i got it, the current that exits the transistor via collector pin enters the voltage supply and then go back in the transistor via emitter pin, it never go in the Arduino, this answer to my first question thank you.
By the way, should the voltage supply be the arduino, we should not use the digital pin in output mode, or we would give him too much current right?
Does the 5V supply pin of the arduino have a different max current value than the digital pins?
And is the ground pin on the left side of the arduino connected to the right side ground pin, so that they always have the same voltage?
I'm pretty sure the 5V board output can provide higher current than a digital pin in output mode.
I also think the two gnd output are linked. To be 100% sure I recommend you look at the Arduino board schematics.
The 5V header pin can supply ~800mA less whatever the Arduino board itself is using. 800mA is the limit of the regulator, and may be less if Vin is high, like 12V, and the regulator overheats and goes into thermal shutdown.
All the ground pins on the headers are connected via the ground planes to barrel jack ground pin.
Also you might look at the schematic diagram for these very widely used relay boards: http://goo.gl/PcWJ2
Scroll down and look at the schematic diagram. This is like the Arduino.cc example, but adds an optical isolator. This is not costly in large quantities (This 2-relay board is $4 )