Control 5V relay from mbed LPC1768

mbedrelay

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!

Best Answer

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.