0

Im trying to sense if a 12V dc motor is switched on. A hi low reading for the voltage on the gpio would be fine.

My thought was to use a voltage divider to get a low voltage of about 3 volt to the raspberry. However, when the motor is in series with the 2 resistors, there is not enough current to run it. Does anyone have an idea how to accomplish this. It doesn’t have to be with a voltage divider, another method would be fine as well.

This is what I tried:

schematic

simulate this circuit – Schematic created using CircuitLab

3
  • This is not a Pi specific question.
    – joan
    Commented Jul 26, 2022 at 7:32
  • This is going to slow the motor to a crawl, and also can introduce huge spikes of voltage when the motor is switched on/off, I would not recommend this at all. I would suggest some sort of isolated sensing circuit. There are plenty of isolated current sensors, and something like that would allow you to see if (and how fast!) the motor is spinning, without interfering with the operation or risk hurting the board.
    – Chad G
    Commented Jul 26, 2022 at 15:18
  • 2
    place the resistors across the motor
    – jsotola
    Commented Jul 26, 2022 at 15:52

1 Answer 1

1

The way you draw it, the motor is always on, so I added a switch.

The problem here is that you put the rather large resistors in serial with the engine. Therefore, you will limit the current through the motor to 1mA max. The motor will probably not run with that small current.

Rather put the resistor bridge in parallel with the motor. Like that, the motor will not be limited in current and you will get the right output value.

I also added a 100nF condensator. Motors are known to produce voltage spikes and these will be flattened-out by the condensator. This wil save your Pi.

enter image description here

EDIT: As per comment from @Milliways, it is suggested to add a diode that should eliminate the backEMF that you get when you turn off the motor. I've added it to the diagram.

EDIT 2: Use only for very small motors!

The optimum would be to use an opto-coupler and completely separate the 12V circuit from your Pi. You will want to look into that. enter image description here

8
  • Oh man, that looks great, I'm gonna try that. Yes, there is indeed a switch in the circuit. Not sure, why I didn't think of wiring the motor in parallel, but I'm just starting out with this stuff. Will the PI survive with the condensator, or is this still a gamble? I'll take a look into the octo coupler.
    – markus902
    Commented Jul 26, 2022 at 19:53
  • DO NOT do this! 1. It will NOT detect if motor is running, only if voltage is applied. 2. The motor will generate backEMF when power is cut; the capacitor MAY reduce the spike BUT the conventional solution of a snubber diode will totally eliminate it.
    – Milliways
    Commented Jul 26, 2022 at 22:23
  • @Milliways: Normally, with the two resistors, the 100nF is quite sufficient for a motor circuit. I added the diode tough. It will detect whether the motor is switched on as the OP stated that he wanted. Commented Jul 26, 2022 at 23:46
  • @markus902: Added the circuit for use with an opto-coupler. To be honnest: that is the way to go, certainly if your motor is larger. Commented Jul 26, 2022 at 23:48
  • @LjmDullaart 1.67kΩ resistor should suppress transient (although without knowing how much energy is stored in the unspecified motor it is a guess); diodes are cheaper. If you are going to use an optocoupler the divider is pointless.
    – Milliways
    Commented Jul 27, 2022 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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