I have a question regarding an inductive sensor of the type "LJ12A3-4-Z/BY", with an input range of 6-36 volts DC.
My build only has a 5VDC and 12VDC power supply, so I figured I'd most easily power to sensor from the 12V supply. However this causes the returning signal to be 12V as well, and the arduino that is supposed to read the signal runs at 5V, which I guess will cause problems.
I made a small schematic drawing of a part of the circuit for easier understanding.
My guess is that I will need something to reduce the voltage from 12V to 5V. I already tried making a voltage divider using resistors, but that arduino died from either that or something else, so I'd like to ask for advice before headlessly trying that again.
Thank you guys in advance, I hope I find the help I'm seeking.
I know some people don't recommend this connection method.
You can get one schottky diode, connect the cathode to the output of the sensor, connect the anode to the input of the Arduino, and set it to INPUT_PULLUP like a normal push button to make it work.
Hi, a low cost 4.7v zener diode and resistor (say 1k) could meet your need. That will cap the 12v from the sensor to a max of 4.7v into the arduino. The resistor value should be big enough to prevent the zener diode hitting it's power limit. if the zener is rated at 100mw then the max current will be max 20mA. to drop the 7V a 1K resistor will be fine.
Connect the 1K to the 12v signal, the zener (in reverse polarity ) to the other end of the resistor and GND, then tap of the 4.7V signal off the zener/diode connection. This might cost you as much as 3 pennies.
DIYmall LJ12A3-4-Z/BY Proximity Switch DC 10-30V PNP 3-wire 300MA 4mm Cylindrical Inductive Sensor Approach Positive Voltage Regulator L7805CV for 3D Printer Ramps
Proximity Switch Description:
Product Name: Proximity Switch
Model: LJ12A3-4-Z / BX
Voltage: 10-30V DC
Current: 300MA
Sensing distance: 4mm Output Type: PNPnormally open
Cable length: about 140cm
L7805CV Description:
Output voltage: 4.75-5.25V
Maximum input voltage: 35V
Quiescent Current: 4.2-8mA
Output voltage noise: 40uV
Ripple rejection ratio: 78dB
Output resistance: 17mΩ
Output voltage temperature coefficient -1.1mV /degree
Package Included:
1 X Proximity Switch
2 X Gasket
2 X Screws
1 X L7805CV
As stated, since it is open collector, the output voltage is whatever you pull it up to.
You could simply use a 4,7k pullup to 5V and get your arduino input signal directly
from the sensor output pin. It cannot possibly be 12V if it is pulled up to 5.
(or, as shown, use Input Pullup) pinMode Input Pullup
Voltage divider or zener approach is fine for if PNP
If have an opto-coupler like the PC817, it's fine to use it.
By the way, this type of sensor has a 10kΩ pull-down resistor inside the sensor.
(The NPN output type is also pull-up to VDD via 10kΩ, so can't be directly interfaced...)
However, pulling the INPUT_PULLUP to LOW is not possible with that pull-down, so in the case of PNP the circuit I presented doesn't work.