Relay curcuit not switching on

Hi everyone,
I am new to the arduino world. I want to make a simple relay switch that sits ontop of a cord connected to my wall (220V).
I want it, on my command using arduino, to turn on and thus turn on a light.
I have a Compact fluorescent lamp as my light bulb (one of those energy saving lights.
My arduino is connected to my laptop via USB for power (I bought and am waiting for a 9V wall adapter)

The circuit i'm using is as shown in this site.
http://www.glacialwanderer.com/hobbyrobotics/?p=9

My circuit works fine until the relay (I checked and can see the diode site that is connected to the relay is getting 5V or 0V on my command using arduino, but for some reason the other side (i.e. the output of the relay) is always on 0...

Any suggestions on what I might try in order to get this working?
Thanks!

If the relay is always on then perhaps the diode is wired the wrong way round. The line should point to the +5V.
Or you have wired up the normally closed contacts. Can you here the relay turn on and off?

The relay does NOT turn on (opposite to what you wrote that it stays on constantly)

I cannot hear the relay go on and off.

If the relay is not on but your lamp is then you have used the normally closed contacts in place of the normally open ones.

You have also miss wired the transistor if the relay is not coming on and off, or you have forgotten to set that pin as an output in the setup function.

I apologize as I think I have not explained it clearly.

The lamp is off constantly.
the whole circuit, up to the part where the relay connects (the 2 relay pins that are parallel to the diode in the site i posted in my first post) get 5V or 0 on my command (using the arduino lol)

so what i was trying to explain is that my circuit works fine, but for some reason the relay does not turn on and off, it is off constantly...

thanks again for the help

Can you show a photo of your setup ?
One that shows all components and what wires go where.
Could be all kinds of things causing your problem.
Also please tell us what relay you are using (what is written on it, or also a photo of the text on it).

so what i was trying to explain is that my circuit works fine,

So what is the problem?

but for some reason the relay does not turn on and off

Then the circuit is not working fine. What makes you think it is working fine?

@ MAS 3
I have 2 setups, with 2 different relays.
As of now I took the cord which runs on the relay off, but of course when i was testing it was connected.

3 images are attached:
1 (blue relay) is simpler and connected to a breadboard (soldered)
1 (relay not seen) is the same and connects to the relay in image 3. This does not use a breadboard as i thought i might have had an issue with the soldering (I don't)
1 image of the 2nd relay - gray relay

@Grumpy_Mike

What I mean the circuit is working is that until the relay (if you look at the gray relay picture i am referring to the point where the wires connect to it in the image), I can control the 5V or 0V making its way there on command.
Thanks

and the other 2 images.... :roll_eyes:

last one...

Some more questions.
Is the transistor a 2n2222 as mentioned in the link you supplied ?
I can't see what relay you used in the first pic (the blue one), so can't tell you anything about that and will ignore it for the rest of this reply.

Make a measurement on your diode, the side that does not have the line and the other measuring pin at 0 volt.
Measure voltage.
At the moment the relay should be off, you should measure close to 5 volts there.
At the moment the relay should be on, you should measure 0.6 volts.
Tell us what you measure in both states please.

The second relay is a solid state relay.
It does not click and you cannot feel it switching when you touch it during switching.
It has a LED on it, so you can see that lighting up when the relay is supposed to switch.

You can check the blue relay to see if you connected it correctly.
Measure Ohms across the used pins.
You should measure something between 200 and 1500 Ohms or so.
Also check whether it is to be polarised, so if it has a + and - side at the coil.
Most of the times you can see that on the top of it.

So after writing all of this, i decided i'd check again assuming the transistor you used is indeed a 2N2222.
Looked up (Googling) where Collector, Base and Emittor are.
Looking towards the flat side of that transistor, holding the pins downwards, they are at C B E.
You have the red wire connected to + at the solid state relay, and at the Emittor.
This cannot be correct.
The green wire is at the 0 volts of the relay, at the Cathode of the diode and at an orange wire going nowhere (i'll assume it would go to either 5 volts or 0 volts) .
This is also incorrect.
There is also a yellow wire going somewhere unknown, and connected to the collector.
The diode is not neccesary when using a solid state relay, but if you still want to use it, connect it directly to that relay's screw terminal.
Connect the Cathode (the side with the line) to + and the Anode to - (this would suggest it is "upside down", but is exactly what it is supposed to do in this case).
Check the drawing in the link you posted for this.
You can also see that the + side of the relay is supposed to be directly connected to + 5 volts.
The - side is to be connected to the Collector of your transistor.
And the Emittor is to be directly connected to 0 volts.

Short: Your transistor is probably upside down, and so are your relay and diode.

Tip:
Print the photo from your link.
Use colored crayons or so to mark each different line, corresponding to the colors you have available in your jumper wires.
So now each connection should be in its own color.
You need 4 colors, not counting the connection to your Arduino.
Mark each connection once you connected it.

You might think this is a bit of a childish approach, but it makes it very clear and easy to keep everything in track.

Recheck everything i told you here as it is 3:34 AM over here, and i might have missed something or assumed too much.

[Edit]Typo's[/edit]

WOW! Finally (1/2 of it works)

Solid state circuit - you were right, I had the green and red wires going to the + and - wrong. switched it and now the led finally turns on, and the lamp works on my command!!

the n2222 circuit still doesn't work. I haven't changed anything. I hear it clicking when the relay turns on and off. I checked resistance on all the top 3 pin pairs of the relay (when the circuit is not connected to anything) and they were all infinite.

also measured the diode, the side that does not have the line and the other measuring pin at 0 volt.
Measured voltage.
At the moment the relay should be off, you should measure close to 5 volts there. - I measured close to zero.
At the moment the relay should be on, you should measure 0.6 volts. - I measured close to 5V

I verified again, the actual circuit up to the blue relay are the same in both circuits

Thanks again for your help, hopefully we can figure this one out as well...

yoavac:
the lamp works on my command!!

How do you command it then ?

yoavac:
the n2222 circuit still doesn't work. I haven't changed anything.
also measured the diode, the side that does not have the line and the other measuring pin at 0 volt.
Measured voltage.
At the moment the relay should be off, you should measure close to 5 volts there. - I measured close to zero.
At the moment the relay should be on, you should measure 0.6 volts. - I measured close to 5V

Ok, i Googled again and downloaded a Fairchild datasheet (instead of just a quick look at some pictures like i did yesterday).
The 2N2222 is E B C so not what i said yesterday, sorry for that.
So the yellow wire should be connected to 0 volts.
The red wire in the picture should be connected to - of your solid state relay.
The green wire in the picture should be connected to +5 volts.
Leave the other end of the diode (orange wire) disconnected.
Remember that these observations are to the pictures you posted, and might be different to what you have at this moment as you have done some changes since.

Do the same measurements, measure at 0 volts (black measuring pin) and relay - (red measuring pin).
Again, you should see relay off = 5 volts, on = 0.6 volts.