Detecting a 12V Source With Opto Isolator?

Hi, I'm after a bit of guidance on how to detect a 12V supply please.

Im building quite a complicated control project including 12 x digital temperature probes, a pressure monitor (0-5V), plus a 4x20 LCD display and also an ethernet shield, all being developed for a Mega.

In the case of any of a range of error conditions it will activate a 5V relay, which switches 12V across its contacts from a separate PSU. I want to ensure that the 12V is always available at the relay contacts so that if the (remote) PSU fails, the Mega will throw up an error on the display, also squrt an error message via IP. I can provide the location where the Mega and its 5V relay are located with 3 wires - 12V supply, 12V ground and the N/O output for the relay. The Mega itself will be powered with either 9V from a PSU or with 5V if the USB is in use.

I'm keen to keep the Mega and the 12V supply completely isolated from each other rather than using a voltage divider and assuming I can common the grounds from the two separate supplies. So I'm assuming that some sort of opto isolator circuit is going to be the way forward but in this case with things working back to front compared with the normal sort of configuration, where Arduino normally supplies the signal and the output of the chip controls a load. I'd also like to keep the 12V quiescent current consumption as low as possible.

What do you think and can anyone offer any suggestions for a circuit diagram please? My preferred IC would probably be CNY17-2 because these are available and cheap from my usual supplier.

Many thanks.

These are contradictory. :woozy_face:


Is the 12V supply GND connected to the Arduino GND ?

For sure an opto isolator can be used, a resistor divider, common emitter switch are other options. Even a normally energized 12V relay will work.

We need a bit more information.

image

You might want to revisit the emitter/base connections. :wink:

Good catch @LarryD
New revised correct


circuit--->

1 Like

As a side note, the internal Arduino pull-up resistor can replace R1.

No contradiction at all, maybe just a bit of inelegant wording. To clarify:

  1. Relay contacts switch 12V, which comes from a remote PSU, with it's own 0V.
  2. Arduino is predominantly 9V supply, again from its own PSU and its own 0V
  3. For info, both PSU's are on the same 240V mains phase, although probably from different MCBs. Hene the desire to know if one is lost.
    4.I could have used a voltage divider to drop 12V down to 5V and assumed that both PSUs have a "common" 0V by connecting them together, but want to avoid that. I think they are best kept separated.
  4. I've re-read my question and it's all there.

Something that looks for the presence of 12V or thereabouts and puts (HIGH) or (LOW), I don't care which on a digital pin, or indeed just has an output I can read even if analog, will meet my needs.

  • Jim’s post #5 will work.

  • You can use the input pull-up resistor instead of R1.

Many thanks for that and the super quick, workable solution. The 6mA current won't break the bank.

Keep in mind if the 12V supply, for some reason, goes to 10V, the opto circuit still says all is good.

Yes, that's my objective, on or off is close enough without being precise.

Just out of interest, what is the output to to the Arduino, is it an analog voltage or a digital?

The opto’s collector will go to ~0V for 12V input, will go to ~5V for 0V input.

Hence digital.

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