I have a relay board which I bought from dx.com and I am not sure about its reliability. If it fails, then it may harm my Pi right? So I googled around and read that opto isolator provide complete isolation. Even though the relay board is built with an opto isolator, still I won't trust it.
I chose PIC 817 for this. There is no strong reason behind it. I found its datascheme here. From what I understand, for operating input should be 1.2v 20mA.
The relay requires 5v to turn on/off and 5v to operate the relay board.
Based on this I made following circuit and I calculated R1 using Ohm's law.
(3.3v - 1.2v)/0.02A = 105 Ohms
I also want to power the relay from Pi itself. I think I should keep a diode in between them so that its always unidirectional and there is no current coming from relay board to Pi. And I think diode with minimum 5v should do for this purpose. I picked 1N4007 because it's easily available for me. It's ratings are 1000v and 1A. Or should I be using a transistor instead?
Is following circuit correct? Do I need to any extra component? and also can this whole thing can be replaced by any available IC?