I have put a voltmeter across the relay and I get 3.85v when it is powered by a USB and then I get 4.05v when poweered of a 9v battery. I am guessing that I need to up the power to the nano but wondered if there is anything obvious I have done or could do
the relay you chose has an operating current of 80mA which is far more than a digital pin can supply.
There are very small relays operating at 25mA that can be used directly on a digital output but usually you need a transistor to operate the relay
Right just read up a bit about transistors. Would you use a transistor or use a lower current relay? I what the circuit to use as little current as possible so not sure how the transistor would affect this?
So I need the diode in parallel with the relay. I thought the diode in series would be better or should I put the diode in series before the relay to prevent and current going the wrong way which I think can happen with a relay when it powers down?
The diode does go in parallel with the relay, but the negative end towards positive. This is to deal with the brief burst of energy created when the relay is turned off. Not having it risks damaging the transistor.
Well I have an understanding of transistors and now am stumped about which one to get. I am using the Arduino nano so that is the starting point and it is very easy to get to maplins so was going to get the transistor from there.
Your drawing is still wrong. The right hand connection to the relay wants to go to +5v.
A general purpose transistor for playing around with is the 2N2222 which at a glance Maplin don't seem to stock, so you might want to consider eBay? I would suggest Rapid Online, but you need to assemble a fair sized order to get free delivery!
Failing that, the 2N3904 looks fine for the job. Minimum gain of 100 (from the Maplin site) so for 80mA you'll be drawing .8mA from the Nano pin. 200mA max, 40 volts, all within spec.
The only voltage I have is coming from D6 which is the 5v. I hadn't intended to provide a second power source which is what I think you are getting at.
Should I then use an additional power source D7 and put 5v to the collector? Or are you saying put the right hand connection of the relay before the resistor to D6?
So D6 is is High and goes to the base. Check
The emmiter goes to ground. Check
The container goes to the relay then in parallel with the relay is the LED. Check
So where does the right hand side of my relay go to? I assume back to D6 as I have only one source of power?! <- This is the bit I think I a struggling with. Why is this not correct? Should I put another 5v from D5 through the right hand side of the relay?
+5VDC will go to one relay coil terminal and to the diode.
The other relay coil terminal will go to the diode and to the transistor collector.
When the Arduino pin goes HIGH, the transistor will allow current to flow from the collector to the emitter. The transistor acts like a light switch, channeling current flow through the relay coil into ground when current is applied to the base.