I want to detect when an air conditioner is blowing. I placed a PC fan in front of the unit and when it's running, the motor in the fan will generate about a 1.5v output.

How do I detect that with a Pi 3? It's only half way to 3v, so I'm thinking I need a transistor or is there a way to detect that with a GPIO pin directly?

If a transistor, what kind?

  • Try putting a 100k resistor on the output and see if the output maintains above 1V or so when under load. If so a simple NPN BJT with pull up resistor will probably suffice. Dec 31 '16 at 14:21

If the fan motor will generate above 0.7V whilst providing a small current (i.e. under load), then you will be able to interface using a simple BJT inverter circuit.

BJT Inverter

Simply connect Vcc to +3.3V, the motor to VIN, and then VOUT to the Raspberry Pi GPIO pin. You can use something like a 100k resistor for the pull up, and any old NPN transistor (e.g. 2N2222A, BC547, etc.).

The base of the transistor will clamp the input to roughly 0.7V because the fan will likely not be able to source very much current, so you probably won't need anything else on the input. You could always try adding a 1k resistor in series with the motor if you are concerned.

When a current flows through the base, driven by the fan, the output will be pulled low through the transistor. When the fan is not spinning, no current will flow into the base turning the transistor off and pulling the output high through the pull-up resistor.

You may find that the input is noisy - toggling high and low - due to lack of any hysteresis in the circuit. However you can do some rudimentary debouncing in code - basically if the input is high and stable for a few milliseconds, then the fan is off, otherwise the fan is on.


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.