Realy in DC

Hi,
I'm trying to switch on/off an DC 20W halogen lamp halogen lamp.
components: relay finder 10A max. 250V. 6Vcc. with 5 points. Arduino is able to power on a little bit the lamp. I think so.
1K resistor. and a 2N2222 transistor. I've built the diagram: Arduino Playground - HomePage
The code is simple: a delay sending a 1/0 to the pin10 out. This pin is connected to the base of the 2N2222.
I've taken some photos and notes to show you clearer than my english.
With this circuit, the relay doesn't emit signals of life. however, if I disconnect the transistor and connect directly the pin10 to the + of the relay, it makes a noise, trying to connect/disconnect.

The relay has 3 contacts, one is the gnd, and the others are +/-. If I change the red wire linked to the relay from there to the -, just in front of it, the PC power off. Yes.
Please, somebody can understand what I'm doing wrong?
Thanks a lot. In the spanish forum nobody answers me.
Relay: http://www.electan.com/catalog/rele-tipo-contacto-amp-bobina-6vcc-finder-p-1453. html
The lamp works Ok.

Sorry, the photos are in:
Imgur

do you have a voltage source for your lamp in your circuit? telling from your "1vista general"-picture you're just shorting the lamp with the relay. the relays is just a switch which can be "pushed/closed" by your arduino.

still the relay should make some sound if you operate it via the transistor. i would not recommend using it without the transistor, the electro magnet inside the relay draws a lot of current.

so the first thing to do is getting the transistor circuit to work. leave out the big lamp, and just try to control the relay (you wrote you can hear it).

i had a look at the relay pdf that you named (Arduino Playground - HomePage). to me this was quite misleading. you should look for other examples on using a transistor to control a relay. in the PDF it is important to understand that your relay is the small box named "K" next to the diode. the connectors on the right (Relay Power V+ and GND) go to either +5v and ground on your arduino or to your external power source (battery) if you are using a bigger relay.

i couldn't see this all on your pictures but maybe it will help you.

good luck, kuk

http://blip.tv/file/208464/

Thanks, but this video is about an AC configuration.
If the diagraf for DC that I've mentioned before is wrong, perhaps somebody can post a good one.
:o

If the diagraf for DC that I've mentioned before is wrong, perhaps somebody can post a good one.
:o

the diagram you have is NOT wrong. you just have to understand the symbols, which i tried to explain.
maybe you can do a schemetic of your setup. it's really hard to get your setup and all wires from photos.

I've upload some new and better photos:
Imgur
Without any lamp, only the basic stuff, and any response.

I changed the 2N2222 by a BD139 and it burnt in one second.

Thanks.
:-/

In this pix
Imgur
You have the emitter labeled as base, emitter is the tab

In this one
http://www.flickr.com/photos/21870166@N03/2112491093/
Starting at the tab it's EBC from left to right, you have it labeled B_C with the center I assume being E

I changed the 2N2222 by a BD139 and it burnt in one second.

Thanks.
:-/

Thanks! I must read first the datasheet, that would be help me a lot.
I've mounted following the diagram I post in the last post, but it doesn't work. I haven't any photo to upload, in a couple of days I'll make them.
I've realised that the NPN make a noise, but only once when the program begins. Afterwards, the code of a simple delay lights the led and turns it off, but the relay doesn't response more than the first time. And If I connect the outputs of the relay to +5V and gnd from the Arduino, the device begins to shortcircuit and the leds emit dangerously, noising and at the end the Pc switchs off suddenly. bu the Arduino is alive.
I'm sure something is wrong linked, but all of you could help me when I upload the photos.
Thanks!

I've uploaded some photos. The quality would be better :-[
Imgur

FIRST:

STOP TRYING THIS RIGHT NOW!

You're making very wrong connections with Arduino to transistor and Relay.
I'm surprised you only destroyed the BD139.

I'll post more as soon as I can draw it for you.

Here it is:

Note that this image is top view, but the relay is upside down, like your pics.

Don't forget to put the diode. When using coils (like inside relay), it's safely.

The lamp you're using has a high current comsumption. So you must use a external power source. DON'T use Arduino power pins to lamp power.

Arduino Pin Out is the same you described in sketch. +5v and GND is from Arduino Power Pin.

The picture is not ok because the pins in the transistor must be: TAP, B, C (1,2,3) from left to right (clock sense).
Otherwise the PC powers off when I plug the USB cable.

With a correct position I don't find what I'm doing wrong. Now, with the schematic that the partner has sent, nothing happens, even bad. Perhaps it's the lamp and the intensity it needs. I don't know.
I'm going to check with another DC object.
I would be delighted if somebody could take a look on photos.
Imgur
The power supply is in 6V (max. 1A in 12V).
Thanks again!

The page i flickr show a lot of photos. ONLY the first seven. 7 Enero, january.

Ananjar,

is good to see you make progress, at least on connections.
But you connection to transistor is still wrong. If you don't trust me, look at the datasheet of 2n2222a transistor:

or

So I'm saying, and the manufacturer is saying that:
in my drawing:
1 is emitter: must connect to gnd - that's ok;
2 is base: must be connected to resistor that comes from arduino pinout - it's inverted with collector;
3 is collector; must be connected to diode(anode side - non striped side) and relay - it's inverted with base.

You cannot change this (I saw that you already did it), I repeat, you cannot change this just because your computer powers off when usb is connected. Your usb is not saying: "your transistor has swapped pins". It's saying: "oh, something is wrong".

And what could be wrong? Well, looking your pics, the only thing I can see is the base swapped with collector.
But you're saying if connecting all like the drawing the usb powers off.
Then there are some possibilities:

  • your transistor has short circuited while you trying to make the project work;
  • your arduino 5v. source cannot support relay draining current;
  • your resistor is touching transistor case (this will not disable pc, but the project will not work). Transistor case is equal to collector;
  • another thing I didn't thought;

And there's one more thing I didn't saw before. Is this the sketch you uploaded to make arduino works with this project?
http://www.flickr.com/photos/21664172@N07/2175459890/
If yes, It doesn't does what you're thinking. It's the button example sketch. It works with pin13 as output, an pin10 as input. And I understood your project uses pin 10 as output, right?

Make the changes I listed, disconnect USB, disconnect arduino pin10 from resistor, and put Arduino 5v. directly on resistor. The relay must work, and light goes on.
If it doesn't try changing the transistor, and try this again.

If the additional hardware works, you must think about the sketch you want to write or use.

The sketch you're using should work, but you have to change the "wire from pin10 to resistor " for "wire from pin13 to resistor".
And add a button. One terminal from pin10 to button, and other from 5v. to button. You must connect a 10k resistor from pin10 to gnd too.

Or more easy: just to test if arduino is turning on relay, upload blink example sketch, and put a wire from pin13 to resistor. The relay will turn on and turn off each second.

If nothing more important and expensive burned out before, this should work.

And one more thing: I don't know why do you need USB in this example, but if using USB, remember to change the power selector jumper from 5 to 3.3 volts. And since you need to do this, I think your USB cannot support the current needed for relay. This can cause pc power off too, I'm not shure. So, if possible in a first moment, try all I said using 5v. only, without USB.

Hi,

but if using USB, remember to change the power selector jumper from 5 to 3.3 volts.

This is a question from a bystander, but what exactly did you mean by the "power selector" here? Do you mean on the Arduino board?

--Phil.

Ok, Follower.

I said something very wrong here.

http://www.arduino.cc/en/Guide/Windows

On the USB boards, the power source is selected by the jumper between the USB and power plugs. To power the board from the USB port (good for controlling low power devices like LEDs), place the jumper on the two pins closest to the USB plug. To power the board from an external power supply (6-12V), place the jumper on the two pins closest to the power plug. Either way, connect the board to a USB port on your computer.

I meant Arduino Power Selector. But since I'm not a USB board user, I make a mistake. Sorry for that.

But Ananjar cannot use the USB 3.3 volts as only source for Arduino (and relay), in this case.

I meant Arduino Power Selector. But since I'm not a USB board user, I make a mistake. Sorry for that.

That's what I thought you meant, which is why I thought it was worth clarifying. :slight_smile: Fortunately we're all human around here as far as I know. :smiley:

But Ananjar cannot use the USB 3.3 volts as only source for Arduino (and relay), in this case.

The power supplied from USB is actually 5V which the FTDI chip uses to also supply a regulated 3.3V. But as you point out, the provided current--a theoretical 100mA--500mA and ~50mA respectively--is the main factor he needs to take into consideration.

Hopefully I'm not just confusing the issue for the original poster. :slight_smile:

--Phil.