0

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

4
  • sensors are not connected to outputs ... inputs are used for that
    – jsotola
    Feb 17 at 6:08
  • Can you share the Omron datasheet also so we can suggest to you the circuit required
    – Maaz Sk
    Feb 17 at 6:15
  • I have shared the datasheet sir @Maaz Sk
    – De Safa
    Feb 17 at 6:31
  • Yes you need to step down the sensor voltage using any external circuit. Arduino GPIOs cannot bear that much voltage.
    – astrick
    Feb 17 at 13:22
1

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:

PC817

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.

5
  • 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 Safa
    Feb 18 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.
    – JSC
    Feb 18 at 8:00
  • TQ sir for your help. May i have the source code? Or just copy online anywhere
    – De Safa
    Feb 19 at 0:25
  • Just google and use digitalRead() function.
    – JSC
    Feb 19 at 6:19
  • Thank you so much again @JSC
    – De Safa
    Feb 19 at 7:28
0

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.

3
  • 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 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.
    – Gerben
    Feb 18 at 10:09
  • 1
    Oh, makes sense. Sorry! Feb 18 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.