I am wiring things at home to switch the lights. Each room has a UTP cable that is hooked up to Arduino. The inputs have internal pull up enabled and the buttons in the room just connect the pin to GND to change the state.
Is it OK to use it this way or should I consider using some optocoupler circuit to protect the pins? This same UTP cable has additional +12V line to power some other devices.
You need a bit of protection due to the long cables. The internal pullup isn't strong enough either.
I'd recommend 1k pullup, 10nF cap to ground on each signal wire, and 1k is series as current-limiting
should there be spikes and interference in the wires. You must put this series resistance between
the Arduino pin and the 1k pull-up or you won't have enough pull-up voltage. Also don't use interrupts to
read the lines unless you also add a schmitt-trigger to cleanup transitions - but there's no need for
micro-second response times here of course.
I presume the 12V is on different wires - 12V is not Arduino compatible.
The 10nF cap will knock out lots of interference, its a very low bandwidth situation so we don't care about
most things.
If there's any chance of dangerous voltages getting onto the wire that would another matter, but CAT5
has 2 layers of insulation so its well protected.
As my installation is not a small one (around 40-50 buttons), and TBH I would like to spare myself wiring the capacitors and resistors on my own, would id still make sense to use one of these boards instead:
It is based on EL817 optocoupler. Unfortunately no schematic in the auction... Seems very simple though. Not sure if it will solve the problems you have addressed in your post.
It'll certainly protect. And if its cheap it might make sense. However with that many inputs it
would make sense to find a port expander that allows reading many dozens of inputs over a small
number of Arduino pins. There might even be a ruggedized port expander designed for this
exact purpose...