Voltage direction on 5V -> 220V relay?

Hi guys!

After lending one from a friend I finally got my own 5V to 220V relay from Ebay.

Problem is that when I connect it to the Arduino, both of the channels light up. I've done nothing in my sketch, it's literally just setting the pinMode to OUTPUT. The relay is connected as it's written on it, GND to GND, VIN to 5V and the control pins to the Arduino.

Other than that the relay works fine, it's just that LOW from the Arduino turns it ON and HIGH turns it OFF.

Could I tackle this by just changing the VIN and GND pins or am I going to burn my relay?

Pic related, it's the type of my relay.

There’s nothing to tackle really. Just remember the high / low being upside down from what you might have expected.

But don’t forget, on the output side you can choose between Normally Open and Normally Closed, so you can “invert” things there.

Do you mean the leds also light up when you set it as a low output? If so, it's just active low. Just live with that :wink: It's just a matter of flipping the code.

And to not get a start up blimp do:

digitalWrite(relayPin, HIGH);
pinMode(relayPin, OUTPUT); //In this order so the pin is high (= relay off) the moment it becomes output

But I must say, most of those non-opto relay boards are just active high. So if the led doesn't turn on you just have to connect the load to NO instead of NC.

It's probably maybe better not to think of the relay as on or off, since with the pair of no/nc outputs, one output is always on and one's always off. Rather think of the relay maybe as active or energised?

Yeah, I guess it's just an active LOW model. Kinda annoying that the LEDs are always on but yea, I will try to live with that. After all the relay works fine.

So I'm assuming flipping the VIN and GND will not work in this case?

There's a transistor on there by the looks of things, which if it's NPN would explain the inversion: low input and transistor is not conducting, so open collector is high to Vcc. Reversing the Vin and Gnd will reverse the polarity on the transistor.... which will not be good for it methinks.

OK guys, according to the schematic, this module does in fact, use PNP control transistors.

Not unreasonably, it seems most of these modules, particularly the "opto-isolated" ones - employ active-LOW logic.

JimboZA:
There's a transistor on there by the looks of things, which if it's NPN would explain the inversion: low input and transistor is not conducting, so open collector is high to Vcc.

That doesn't make sense, does it?

Twinsmaker:
Kinda annoying that the LEDs are always on but yea, I will try to live with that.

No, they are not. The green LED is always on but the red LEDs only light when their respective relay is activated. You can always de-solder LEDs you do not want - or just paint them over with "white-out".

Twinsmaker:
So I'm assuming flipping the VIN and GND will not work in this case?

You aren't really seriously into electronics, are you? :grinning:

Paul__B:
You aren't really seriously into electronics, are you? :grinning:

I'm just starting to look at things in depth, but yea, I'm still a noob (I guess it's obvious).

Anyway thanks for the information, I learned quite a lot from all of you guys!