a. Home appliances and lighting control

It is relatively easy to connect a relay to the PIC18F24J50 or PIC18F26J50. There are two options. You may go for a simple 2N2222 transistor circuit, or a more sophisticated relay driver IC (like ULN2803A) based circuit. ULN2803A chips have inbuilt inverse current protection to prevent damage to electronic from relay switch-off reverse current. It is important to note that PIC18F2xJ50 operates on 3.3 V and you must check that the relay driver chip supports TTL voltage levels (that is: a relay is switched on if the input voltage > 2.4 V). However, as an extra precaution you may also add a protection diode (ex. 1N4007) to all relays. But the diode is a MUST for the transistor circuit! If you are planning to connect more than 2 relays, you will be probably better off with an IC! If you are driving high current relays with more than 100 mA then you should also take care about driver IC overheating!

Here are the circuit diagrams:

Relay connection to a K8055N board and +12 V= external relay power supply photo. Click on the photo to enlarge it.

Integrated relay controllers. Click on the schematic to enlarge it.

Single transistor relay controller. Click on the schematic to enlarge it.

Home automation server and electric cabinet. Click on the photo to enlarge it.