I'm looking at using one of these relay modules to control switching a mains powered air freshener on/off:
Unfortunately the logic of the module seems to be the opposite of what I want (it seems like it's acting normally closed, whereas I want it normally open). After mucking around with a transistor, I somehow came out with the following circuit to act as a kind of logical NOT gate (please excuse my lack of ability with Fritzing - also, the 'servo' is actually the servo style connector leading into the relay module!):
Can anyone explain why this works? I'm not entirely sure why....
And also, can anyone see anything dangerous with how this is wired up? The air freshener draws super low current, so the G5LA-14 relay should handle it, and I'm presuming that the module isolates the Arduino/breadboard sufficiently (it looks like it has a requisite diode for back EMF, etc). I'm not looking to hold anyone accountable should I blow up myself and burn my house down, I just want to double check I haven't missed anything obvious!
You appear to have an NPN transistor with its collector at the most negative potential in the circuit - that doesn't look right.
Your relay seems to have only one available contact. Still don't "expect" it to be normally closed. Check on DFRobot site!
---( Wrong solution)---
Simple solution: the relay has both "Normally open" and"Normally closed" contacts. Rewire it for Normally Open...
Aha! Found a wiki page on the module here, with a relevant code example:
So a high voltage will indeed open the relay/switch it off. Am I just being stupid with faffing with transistors to invert the state of the digital output - should I just invert the logic in the Arduino code? I'm guessing this will mean that the relay will be closed during Arduino boot up time (as power will be flowing to it and the digital output controlling it will be low), but this shouldn't be a problem in this application...for future reference, is there a way around this?
Hey, that relay DOES have both Normally-open and normally-closed connections although the DFROBOT page doe not show the exact connections Grr....
Just operate the relay and check the connections. I think you're all set....
This is a Single Pole Double Throw relay with both Normally-open and normally-closed connections.
should I just invert the logic in the Arduino code
Yes every time providing the arduino can stand the load.
Thanks very much for the help guys, much appreciated :)
So, just taken a look at the module - unless I'm mistaken, it sadly doesn't look like it's possible to do NO operation with it. If you take a look at the PCB traces:
And compare with the datasheet:
Pins 1 and 3 of the relay are hard-wired to the outermost contacts of the module, and the inner most contacts on the module are hard-wired to each other. Here's the view from the top for comparison:
As I understand it, switching the relay on swings the connection from pin 3 to pin 4 of the relay, opening it. It doesn't look like pin 4 is connected to anything to me...
Unless I'm talking nonsense - there's a strong possibility of that, mind.. ;)
If this is the case, I'll rewrite the logic of the Arduino code to send the output "low" when I want to switch the air freshener on
- annoying to have power blips on start up, but it'll have to do for now..
EDIT: In fact, I was talking nonsense about 'power blips' - have the appropriate pin set to high in setup and it seems to be seamless! Lovely. :)
I bet DFRobot didn't intend to do that....
This one gives you both options: http://arduino-direct.com/sunshop/index.php?l=product_detail&p=49
Yeah, it seems like an odd design choice to limit users like that. Thanks for that - I'll buy one of those next time!
I'm a total newbie in electronics, but I want to learn. I'm a software developer.
I bought the follow relay module http://cgi.ebay.ca/5V-4-Channel-Relay-Shield-Arduino-Electronic-DIY-/110648585724?pt=LH_DefaultDomain_0&hash=item19c32b6dfc#ht_1351wt_1139.
I thought that I knew how the basics of relay worked, i.e. put a small voltage and it close/open a switch. But nothing seems to work.
I have connected the VCC and the ground to the board and connected K1 to pin 13. Now let say for testing purpose I want to make a led blink from the relay, where do I plug the cables?
have connected the VCC and the ground to the board and connected K1 to pin 13. Now let say for testing purpose I want to make a led blink from the relay, where do I plug the cables?
Well all that wiring just powers up the relay board and allows the relay's coil to be turned on and off by pin 13. You should be able to hear the relay click on and off if you just use the standard pin 13 blink sketch. Check that out and tell us if you hear a one second click and then we can talk about how to wire a circuit to be turned on and off by the contacts of the relay.
Ok, I realized that the relay 1 and 3 were defective :~. Well, there is no clicking sound from them. I'll test them later directly with their pins. After all, I'm not that dumb.