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 thatjsotola– jsotola2021年02月17日 06:08:09 +00:00Commented Feb 17, 2021 at 6:08
-
Can you share the Omron datasheet also so we can suggest to you the circuit requiredMaaz Sk– Maaz Sk2021年02月17日 06:15:16 +00:00Commented Feb 17, 2021 at 6:15
-
I have shared the datasheet sir @Maaz SkDe Safa– De Safa2021年02月17日 06:31:16 +00:00Commented Feb 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.astrick– astrick2021年02月17日 13:22:33 +00:00Commented Feb 17, 2021 at 13:22
2 Answers 2
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 understandingDe Safa– De Safa2021年02月18日 05:52:21 +00:00Commented Feb 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.JSC– JSC2021年02月18日 08:00:24 +00:00Commented Feb 18, 2021 at 8:00
-
TQ sir for your help. May i have the source code? Or just copy online anywhereDe Safa– De Safa2021年02月19日 00:25:26 +00:00Commented Feb 19, 2021 at 0:25
-
Just google and use
digitalRead()
function.JSC– JSC2021年02月19日 06:19:41 +00:00Commented Feb 19, 2021 at 6:19 -
Thank you so much again @JSCDe Safa– De Safa2021年02月19日 07:28:18 +00:00Commented Feb 19, 2021 at 7:28
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.James Barnett– James Barnett2021年02月17日 19:40:12 +00:00Commented 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.Gerben– Gerben2021年02月18日 10:09:47 +00:00Commented Feb 18, 2021 at 10:09
-
1Oh, makes sense. Sorry!James Barnett– James Barnett2021年02月18日 17:42:40 +00:00Commented Feb 18, 2021 at 17:42
Explore related questions
See similar questions with these tags.