What is the best way to control an electronic's switch with a digital pin?

Board: Arduino Uno

I'm trying to use the board to control a humidifier's on/off switch, depending on a DHT22's reading on humidity. Should be simple enough, then I realized I can't power the humidifier since it requires 5V and 300mA, which a digital pin can only provide like 5V 40mA.

So maybe I need to provide its power separately, what's a good way to do so? Do I have to buy anything else, like a controllable switch wired to digital pin?

who said ?

yes. it calls "transistor". invented in ~1950. but since then there are one special version of it "MOSFET". very helpful in digital circuits.

  • What is your definition of best way.

  • If you need to control the power to the sensor, use a P Channel MOSFET high side switch.

Atmel/Microchip says.

image

wow it is much more as i heard earlier: 20mA 5.5V

  • 40mA is the point where things can go wrong.

  • A safe maximum is 20mA.

Yes... that notice explains the depth... and thank you for posting it.

What is your definition of best way.

I think the safest way to run it for extended period of time is the best way.
Does that mean I also shouldn't power it with Uno's 5V output pin? I measured the humidifier drawing 5V 140mA at peak.

  • 150ma should be okay if running from USB power or 7 to 9V into the power jack.

Here's my current schematic sketch. Is that protection diode needed for flyback when switched off?

Hi, @k-h-c

Is that protection diode needed for flyback when switching off?

Yes, the magnetic field collapsing in the windings of the load, produces a reverse current that can damage the associated electronics.
The diode provides a short for the current around the MOSFET.

Tom.. :smiley: :+1: :coffee: :australia:

In this case, I'd have tended to put the protection diode across the load, that is the humidifier (R1 on the schematic). The mosfet has anyway a body diode in parallel with the "protection diode" the OP has drawn.
Oh. It looks like the whole thing is powered by a 9v battery!

It looks like this now. Protective diode across the load only. In this use case, humidifier shouldn't have any relay inside, so I guess it should be fine.

Hi @6v6gt,
Yeah it'll likely be powered either by a 9V cell or a AC-to-DC 9V adapter.

:+1: :+1: :+1: :+1: :+1:

Tom... :smiley: :+1: :coffee: :australia: