If you're looking for an "off the shelf" solution (which most of us are not) look at opto22 modules or similar.