Photoelectric sensor for demanding applications