Electrical – Hooking up a loop-powered 24V NPN/PNP sensor to Arduino

arduinonpnopto-isolatorpnptransistors

I have a 24V pressure switch that is loop powered. Here is the manual/datasheet. I'm trying to figure out how to read the sensor with an Arduino.

Obviously, the Arduino can't handle 24V, so I got some optocouplers (manual/datasheet)

The original schematic looked like this:
Original Schematic

This, however, didn't seem to work. When I measured voltage across ports #1 and #2 (from the schematic), it measured between ~13V and ~20V (when the sensor was engaged vs not-engaged).

I'm not really sure how to fix this. I tried using a voltage divider (instead of an optocoupler), but, in my ignorance, I burned up one of my small resisters.

Thanks for any help!

UPDATE:
New Schematic (the one above is old)
enter image description here

Best Answer

Here is the final (working) schematic: Final Schematic

In the end, I actually ended up using an NI DAQ box (USB-6255). This would still work with an Arduino though.

Thanks for all the help! Joe