1

I am using the arduino with DHT22 temperature, humidity sensor, but i don't want to constantly power the sensor, so I would like to have a NPN 2N2222 transistor to control when to the give the power.

but i am a bit puzzled how to wire them together, which how the collector and emmitter should be wired to DHT22 sensor

user824624
  • 207
  • 1
  • 3
  • 7
  • I'd make this an answer if this question wasn't marked as a duplicate of a more generic question: the control output is wired to the base, with an appropriate current limiting resistor, and the emitter and collector are wired between the earth pin of the DHT22 and earth. – Phil Dec 18 '17 at 21:00
  • A better reason to do this than to save power (and why this question is really not a duplicate of the one it's marked duplicate of) is because the DHT22 is known to crash after a while, requiring a powercycle to reset. – Phil Dec 18 '17 at 21:02

1 Answers1

2

I know it doesn't fully answer the question about using a transistor, but you can simply power the sensor from an MCU pin.

The datasheet says it draws only 40 uA in standby, which might not matter anyway, and only 1.5 mA max during measurement. Many microcontrollers will be able to drive that.

The only thing to be careful of is that your software doesn't assert the data line, before powering the sensor. You might have to modify the standard libraries to force the data pin to high impedance when you're done measuring.

This is a useful trick to save parts and save power on a microcontroller. Try to power the small or parasitic loads from the micro's output pins if they're not needed all the time. Things like the red power LED, the high side of a potentiometer for a user knob, pull-up for opto-isolators and the peripherals can go through the micro. You need to respect its current limits, total and per pin (and you can't safely put pins in parallel).

tomnexus
  • 7,617
  • 3
  • 19
  • 35
  • 2
    "Any microcontroller"? I think not. I've worked with some that did not have output pins capable of supporting this. As such I corrected answer to say "Many microcontrollers". – Michael Karas Jan 05 '15 at 14:24
  • Agree with Michael. Plus even if you can power one sensor, powering multiple quickly becomes tricky as you have to watch for chip current draw, and port current draw limitations – darudude Jan 05 '15 at 18:30