I am doing a project for object detection. But my problem is I'm using a 12V photoelectric OMRON sensor to connect with 5V Digital PWM port 3 on Arduino using normal coding. Do I need an extra circuit to step down the voltage to 5V? Can it work because the only connection between the sensor and Arduino is the output signal, the VCC and Ground are from external power. Link to the datasheet Please help me
-
sensors are not connected to outputs ... inputs are used for that– jsotolaFeb 17, 2021 at 6:08
-
Can you share the Omron datasheet also so we can suggest to you the circuit required– Maaz SkFeb 17, 2021 at 6:15
-
I have shared the datasheet sir @Maaz Sk– De SafaFeb 17, 2021 at 6:31
-
Yes you need to step down the sensor voltage using any external circuit. Arduino GPIOs cannot bear that much voltage.– astrickFeb 17, 2021 at 13:22
2 Answers
My favorite solution for such an application is to use an optoisolation module. In this case, the signal can have a voltage of 12 V and the output of the optoisolation module can be connected to the input of the Arduino, where the input is configured as INPUT_PULLUP. Example of the optoisolation module:
In this way it is possible to connect other types of sensors and switches and the solution is universal also for other development kits, e.g. with 3V3 logic.
-
TQ so much. But can you explain it to me more detail sir. Are you implying i have to connect the 12V sensor to arduino port 3 normally, with the optoisolator is connected to the arduino input port? How does that works? Sorry for my bad understanding– De SafaFeb 18, 2021 at 5:52
-
@DeSafa Connect the sensor to the input of the optoisolator module (2 pos. terminal) – signal and GND. Connect the Arduino to the 3 pos. terminal – 5V pin, input pin (e.g. D2), and GND.– JSCFeb 18, 2021 at 8:00
-
TQ sir for your help. May i have the source code? Or just copy online anywhere– De SafaFeb 19, 2021 at 0:25
-
-
For one, you need to connect the two grounds together.
Secondly, the 12V signal will indeed fry your Arduino. Lower the voltage to just below 5V, using a voltage divider circuit. You could for example use a combinations of a 2.2kOhm and a 1.5kOhm resistor, to get around 4.9V.
-
Don't use a voltage divider circuit whatsoever, you will probably damage the chip. Use a transformer or buck converter. Unless you calculate the load induced that will be induced on the voltage divider, you cannot guarantee the voltage divider will provide a steady 5v, as load changes the output voltage of a voltage divider. Feb 17, 2021 at 19:40
-
@JamesBarnett I was talking about converting a 12V signal to a 5V signal. Not converting 12V to 5V, to be used to supply power. Since the output of the voltage divider goes into an Arduino INPUT pin, the current will be next to nothing, and will not affect the voltage.– GerbenFeb 18, 2021 at 10:09
-
1