Optocoupler and grounding

Hi all. 1st post but been hanging around a little while! I am coming to the end of my 1st project and wanted to ask a question before i power up - i think i might fry the board if I do? My build is slightly different to my prototype hence it has just come up.

Project is simply an I/O box that takes a binary 12v/0v from my alarm systems outputs and via an optocoupler (to handle the voltage difference) sends it into an Mega which then sends it on to a home automation hub (Hubitat, via Hubduino).

My question is around grounding. I hope that with the image below you can follow. Basically the 12v input side (the cat 5 wires) is grounded to the Arduino power input (which will be 12v out from my alarm panel), and the 5v Arduino side is all grounded to a G pin on the Mega. I realised/learned a couple of things last night:

  • The 'in' and 'out' ground sides of the optocoupler board are joined by the jumper on the opto board. If it leave it as built, then in theory the 12v side can ground into the Mega G pin? Sounds like bad news to me?

  • To fix that i can either pull all the jumpers, or can i simply ground the 5v side into the 12v power input as per the 12v side (my simple logic says yes?)

  • Finally in poking around with a continuity meter to investigate this i realised that all grounds on each side of the optocoupler are linked to each other so I wasted my time making around 50 tiny jumper wires to connect them all up :joy: good practice I suppose. Not clear in the photo but there are 3x 8 channel opto's stacked on top of each other!

Thanks in advance for any pointers.

1 Like

The reason for optocouplers is to avoid connecting the grounds. With grounds connected there are simpler options.

No doubt it could have/should have been done different - absolute beginner in electronics and Arduino here with a 1st project! The optocoupler grounds are connected together down each side (ins and outs) whether i bridged them or not as i discovered afterwards. The jumper just bridges one side to the other. Odd design on the board is the summary i have read elsewhere.

Still leaves me with the 12v/5v grounding issue though.

Since you are getting power from the alarm system the Arduino also has to share a common ground anyway. That's OK because you don't need complete electrical isolation. (If you needed complete isolation you'd need a separate power supply.)

Presumably, the purpose of the opto-isolators is to protect the Arduino from 12V? There are other solutions (where you don't need isolation) but opto-isolators are one of the "safest" solutions (as long as they are wired correctly :wink: ).

Suggest you neaten up your wiring.

Hope the Arduino wires are stranded .

Thanks Doug - i read up on it using the page below and the last diagram is similar to my case.

Power Supplies (myzen.co.uk)

The opto's are there to keep the 12v away from the Arduino yes, and hence my question as it looked like i was sending 12v through the Megas G pin. I understand a tiny bit more about 'common ground' now!

Going to have to get some practice in to get that neat and tidy Larry!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.