I'm at the end of a project to monitor lighting, climate and several other devices in a chilled terrarium, but I'm stuck with troubles related to 8-channels 5V relay.
I try to follow the advice read here ==> http://arduino-info.wikispaces.com/RelayIsolation and I ended up willing to use a ULN2803A chip to benefit from the flyback diodes.
I found many advice on this forum and on the internet but unfortunately, I haven't completely figured out yet how to properly wire my boards, in order to profit from the opto-isolators and to be done with the EMI problems that I met at the moment. I would like to get a prior confirmation before any attempts.
I have summed up 4 diagrams, of which I hope one is correct.
Number 1). I don't use the opto-isolations and grounds are not common :

Number 2). Because I read many times RPi and 5V power supply grounds must be common, here it is :

Number 3) : Opto-isolation provided, but not common grounds :

Number 4 ) : Opto-isolation + common grounds :

Maybe I got everything wrong and I have to give it another go. Please, could you help me out here, and tell me which diagram I should follow to get everything working out ?
Thanks.
Vince