2

I want to detect if there is an electric current in the wire where I wrote "here > > > > > >" (on the image)
The secondary circuit is a 12v circuit.
How can I do this ?
Thanks !

My simplified shéma

5

I would recommend that you use a Opto Coupler. An Opto coupler consist of a LED (Light Emitting Diode) and a Photo sensitive transistor.

That will create a safety isolation between your motor that creates nasty electrical spikes and your precious Raspberry Pi.

Take a look at the Youtube video for more detailed info https://www.youtube.com/watch?v=pYENAGK8qH4

If you really want to measure the current then is a ACS712 (Current Hall sensor) and since the Raspberry Pi doesn't have a Analog input a ADS1115 (Analog to Digital converter) that has a I2C interface that Raspberry Pi understand.

3
  • 1
    I very much appreciate your answer, concisely giving a good and comprehensive guidance to newbies. Cheers. – tlfong01 Sep 17 '20 at 1:24
  • 1
    I watched the 4 minutes Youtube video on optocoupler and surprisingly found it also concisely giving a good and comprehensive guidance to newbies. I was particularly impressed by the use of newbie friendly colored text and also the selection of popular components like 2N2222 and PC817 which are widely used in the industry and commercial areas I gave both your answer and the video 5 stars (top 3%). Cheers. – tlfong01 Sep 17 '20 at 1:38
  • 1
    @tlfong01 Im glad that you liked it and hope it help you on your journey in electronics. – Mats Karlsson Sep 17 '20 at 4:30
1

The circuit from the video in the above YouTube link shows how to use the RPi to turn the motor on or off. To detect whether or not the motor is running, the circuit needs to be modified (see the schematic/diagram below). You won't be using the "here > > > > > >" part of the yellow wire (as seen in your question) because that would be measuring current through a series connection which the RPi can't handle. Instead you would measure the potential difference (voltage) across a parallel connection. This is what the GPIO (configured as an input) will measure: a HIGH potential or a LOW one.

Make sure the barrel style DC plug has a positive center. The 33K resistor, which has one end going to the transistor base, will have its other end connected to the green wire in your circuit. This way, when the motor comes on, some current will drive the transistor, allowing current to flow through the opto-coupler's internal LED. It then shines on the receiver, allowing the isolated collector-emitter junction to conduct.

A 10K current limiting resistor connects the 3.3V pin to the GPIO you wish to use to detect if the motor is running. The 10K hardly drops any voltage because the GPIO's input impedance is far greater, so the GPIO sees nearly the entire voltage coming from the 3.3V pin. This ensures that the input always reads a stable HIGH, since the voltage must drop quite a bit before the transition from HIGH to LOW occurs. Grounding the GPIO, as it is presently wired, will pull it down to ground (LOW) while drawing less than 1mA through the 10K resistor (thus protecting the RPi). When opto-coupler conducts, it is connecting the ground and GPIO wires on its terminals. This is how the RPi is able to detect the state of the motor. enter image description here

0

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.