0
\$\begingroup\$

I want to connect up a relay module (wired up to control a normal desk lamp) to an mbed LPC1768 board. I have the circuit connected up successfully using an Arduino via the Arduino's 5V pin. From the control perspective, all I am doing is turning on/off the lamp; I have no problem from the code side, just the electronics!

Mains voltage-->relay module-->lamp
                     ^--mbed

From what I have read, the mbed's Vout is 3.3V. Some of the other pins are 5V tolerant, but looking at this datasheet, it seems to say that the pin has the same tolerance as Vdd(3v3), which has a max voltage of 3.6V.

The other option I have seen is using the VU pin. As far as I can tell, it is a 5V Out pin as long as the board is connected up via the USB cable. If so, then that makes life a lot easier. I have read mixed accounts of whether it is Out or In, but most people seem to be using it to power 5V peripherals, so I assume I can do that then. I couldn't find confirmation of this in the documentation, though, so if anyone knows more about this I would be grateful.

Fail this, then I would appreciate any suggestions on the best way to boost the voltage to run the relay. I imagine I will need a MOSFET or similar, but I know very little about how to wire them up. I saw this, but it blew my mind a little...

I am also not sure on the current requirements, but as it runs from the Arduino without a problem then I don't think it is too much to imagine that it would also run from the mbed. Feel free to berate me for assuming anything if incorrect!

\$\endgroup\$
2
  • \$\begingroup\$ Without knowing which relay or relay module you are using we cant help. \$\endgroup\$
    – Passerby
    Jul 31, 2015 at 14:29
  • \$\begingroup\$ It is a 250V (mains compatible) relay module which requires 5V to control it. It is basically the one found here \$\endgroup\$ Jul 31, 2015 at 14:53

2 Answers 2

1
\$\begingroup\$

Simple, with a standard NPN transistor. You could also use a 3.3V mosfet, but an NPN what you need.

schematic

simulate this circuit – Schematic created using CircuitLab

The Relay Module will be powered from the same USB power supply needed for the mbed board.

The Module has an optocoupler that needs to be pulled low at Relay IN to enable the relay. The transistor is enabled by a GPIO HIGH.

\$\endgroup\$
6
  • \$\begingroup\$ Ok, this looks great as I have a 2N3904 to hand! I have a question. If it is the voltage which needs to be boosted, why is the voltage line directly connected to the VU and the GPIO line regulated? The GPIO pins are 5V tolerant, so I thought that they would have no issues. \$\endgroup\$ Jul 31, 2015 at 15:41
  • \$\begingroup\$ @bladepanthera if the gpio you need control the module is 5V tolerant, you still wouldn't be able to control it properly. While the pin wouldn't be hurt by 5v IN, when it is HIGH it will still only be 3.3V, and that means the relay control optocontroller will still be ON. You could never turn the relay off. \$\endgroup\$
    – Passerby
    Jul 31, 2015 at 15:51
  • \$\begingroup\$ @bladepanthera the VU line is 5V USB. The Relay needs 5V to trigger. The control side of the module could work with a lower voltage, but would require having two voltage supplies, and modifying the board. Trust me, this resistor + transistor setup is needed for multiple reasons. \$\endgroup\$
    – Passerby
    Jul 31, 2015 at 15:53
  • \$\begingroup\$ The relay turns on and seems to have enough power through the transitor which is great, but now when I try to turn the lamp on and off by sending 1/0 signals to the pin it is connected to, the lamp doesn't change. It turns on initially when the relay is powered on and stays on all the time. Any ideas? (Using this example code - pretty basic!) \$\endgroup\$ Aug 3, 2015 at 15:08
  • 1
    \$\begingroup\$ Ok, forget it! It works now :D I had it connected through the pin that I was using for the lcd board on the mbed expansion board! Works like a charm. Many thanks! \$\endgroup\$ Aug 3, 2015 at 15:13
0
\$\begingroup\$

You need also to tell the solenoid voltage of the relay and voltage of other DC source (shall be the solenoid relay voltage) to boost the output you have. Simple NPN transitor, base resistor and freewheeling diode will do the trick.

\$\endgroup\$
1
  • \$\begingroup\$ I read this and I think my soul departed as this flew over my head. After a quick google I'm using a relay, not a solenoid. They are different. Why do I have to "tell" it to boost the output voltage, considering that this voltage is coming from the mbed? I hope I'm not appearing standoff-ish, I just don't understand. And if I need those components, how on Earth do I connect them up?! And which ones exactly do I need? Even if you leave me to find that out, what does the circuit look like? Sorry, but I'm still pretty new to more in depth electronics so I'm still learning what things are. \$\endgroup\$ Jul 31, 2015 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.