Go Down

Topic: NPN as a switch question (Read 1 time) previous topic - next topic


I'm using a voltage divider to change 12v in to 4.3 volts out to monitor battery voltage. The voltage divider seems to be working properly.

I'm using a 2n4401 NPN as a switch so that I'm not draining power through the voltage divider (even through it would be a low draw anyway, I'm using 3.3k/2k as R1 + R2 on the divider).

When I measure voltage on the v out while using the NPN, High state voltage = 4.19 (close enough), Low state voltage = 0.80.

The NPN is between R2 and GND, the Base has a 1k resistor between B and the +5v

If the NPN is at low(off) why I'm I getting a voltage? Any clues?


Well, you're always going to get SOME kind of reading. It's actually not a very good circuit because with the transistor off, it's as if the transistor and R2 do not exist. So you have a path from 12V, through the 3.3k resistor, and into your Arduino. The 3.3k resistor limits your current but it's still not a good idea to apply 12V to the Arduino input pin.

I would not have predicted the 0.80V myself (I would have thought it was closer to the maximum possible reading). Is it possible your code is not designed to handle a reading of 1023 (maximum 10-bit ADC value) and prints out 0.80 erroneously?

The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons


Whoa!!! Good catch! Lucky I was testing this on a breadboard without connection to the arduino. I had the NPN up stream of the voltage divider and was getting 1.65 at Vout (High) and 0 at Vout (Low). I got confused as to why the voltage was so low so I thought to put it downstream.

Any idea why I was losing so much voltage through the NPN?


With the NPN "upstream" (I'm guessing that means collector at 12V, emitter connected to the 3.3k resistor) you are not saturating it since the emitter voltage is rising when it turns on, and the collector-emitter junction has to stand off everything between 12V and ~4.3V. NPN transistors don't really work well as "high side" switches in this way. I'd recommend a PNP transistor arrangement instead (or P-channel MOSFET arrangement). Let me know if you get stuck and I'll try to draw you up a circuit :)

The Aussie Shield: breakout all 28 pins to quick-connect terminals


Thank you sir!

I was trying to skirt around using a MOSFET because I had a NPN laying in the box and a MOSFET would require a trip to the store... LOL.

I'm not sure if its even worth the trouble. The circuit will only draw .002A at 12V...


Indeed, if you kick up your resistances to 33k and 20k then your voltage estimates should be quite good enough, you won't need a transistor, and current draw is only 231 microamps.

The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131