Is it possible, using the GPIO Port to power a relay. I have read things about the GPIO port saying it is very easy to mess up, and seeing that activating a relay (basically a short circuit through a magnetic coil) scares me a bit. I want to be able to turn things such as lamps on and off with the raspberry pi and knowing they use 120VAC means I will have to use a relay.
A relay is an electro magnetic, mechanical switch. You should not power a relay directly from GPIO because relays use allot of power to pull and hold the switches, plus there is risk of feedback that can cause damage to the GPIO. You need to use Diodes to prevent this and have a reliable power source, which the Pi does not really have.
It is easier to buy pre made Relay breakout boards, for use with Arduinos for example since they are built to be driven by GPIO and have all the protection built in while allow low power IO to activate the relays.
You can also look at using high power transistor- but these come with their own pitfalls. They can generate high amounts of heat and they can burn out creating short circuits on your high power- causing more problems. But they are easier to use if you understand how to use the,
I've had this problem before and although not with a RaspberryPi, the solution is still valid. Because of the high electrical requirements of a relay and the low power output of the GPIO pins, you need to step up the current to power the relay with a transistor. The GPIO pin gets connected to a resistor, which connects to the transistor. I've previously used a 2N2222A to good effect with a 1.5 Kohm resistor. The emitter gets connected to ground and the collector gets connected to the - of the relay. (The + is connected to a sufficiently high current/voltage source to drive the relay. Max 40 V.) Source, page 329.