Relay and battery

I’ve managed to successfully turn a relay on and off. The imp was powered with a USB cable (April board) while the relay got power from the VIN pin. When using a 9V battery the imp cannot (or hardly) control the relay. The relay has it’s own opto-coupler and I think it requires 5V (the usb provides around 4.8 while the battery around 4.6V). Is there I way I can use a battery to power the relay? I need to place the whole contraption far from any power source.

The imp outputs can only provide 4mA each, and you relay probably needs ten times this current. You will need a transistor to drive the relay, with a resistor to limit the base current (e.g 1kilohm), and make sure you put a diode across the relay to absorb its back emf when turned off. I got a nice kit on ebay with a latching power relay on a pcb with two driver transistors, resistors and diodes on a pcb, suggest you look under “latching relay kit”.

Thank you for the advice, indeed a 2N3905 transistor, a resistor and a diode solved the problem. Thank you!

Also, maybe look into a 3 or 4 volt relay.

The transistor+diode+resistor solution worked brilliantly. I managed to hook up the boiler to the imp so now I can switch it on and off from da internet! Word of advice: do yourself a favour and switch off the mains before you dabble with the electrics:D