I have a simple project where I want to turn a 5v fan on/off and both the MCU and fan will powered by a LiPo battery.

I'm powering the ESP and fan directly from the battery in the attached circuit. For now I've decided not to boost the power to 5v for the fan because the fan runs fine at lower voltage. Also using a BJT transistor as a low side switch.

This all seems to work fine except at full duty cycle the voltage to the fan seems to completely collapse. At just below full (like if a do analogWrite(pin 1000) it's humming along fine but when I go to 1023 the voltage drops from around 4 to closer to 2 and the fan stops. Even at lower duty cycles like 50% the fan operates nice and slow.

I put a multimeter on the leads to the fan and observe the voltage drop at full duty.

I'm very new to all this and have done a lot of reading but I haven't been able to solve this. Also this is my first fritzing drawing so I hope it makes sense.

Edit: I made some changes to the circuit and it's working as expected. I have also updated the circuit diagram below.

enter image description here

  • The 3.3V pin needs to be provided with a regulated 3.3V. When the power input of the ESP gets too low, it will show weird behavior
    – chrisl
    Jun 16, 2020 at 6:59
  • Oh I need to update the schematic. I’m actually feeding the power from the LiPo to Vin on the MCU. Still unregulated, to your point, but it’s not going to 3v3, it’s going to Vin. Anyway, I can try boosting the LiPo output to 5v and use that to directly power the MCU and the fan and see if that makes things stable at full duty.
    – farzadb
    Jun 16, 2020 at 8:03

1 Answer 1


According to specs I found online, the NodeMCU wants 7-12V on Vin. Most LiPo cells put out around 4 volts, which isn't enough. The battery voltage may drop and the MCU's voltage regulator probably fails to keep putting out 3.3V when the fan's average power draw exceeds some threshold.

It might also be that the fan itself is slowing when the duty cycle approaches 100% and the battery voltage drops.

Doesn't the NodeMCU run on 3.3V, not 5V? If you feed 5V into the 3V pin and that's supposed to have 3.3V, it will likely damage or destroy the board.

  • Looks like you’re right about Vin. I’m still trying to find the datasheet for my exact devkit board to confirm but I can easily put a regulated 7v into Vin and see if it fixes the voltage drop off problem at full cycle. And, sorry, but I don’t understand your last paragraph ... Vin is connected to a voltage regulator so it will regulate to 3.3v for the board which should be safe. Did I misunderstand your comment?
    – farzadb
    Jun 16, 2020 at 14:58
  • Sorry, that was a typo. I fixed it.
    – Duncan C
    Jun 16, 2020 at 15:23
  • Yes, I would suggest measuring the voltage, both across the motor, and at the Vin to the board, when you're running it at 100% duty cycle. I'm suspecting a voltage drop.
    – Duncan C
    Jun 16, 2020 at 15:24
  • It turns out that the nodemcu dekvit I'm using supports 5v on Vin. And I'm no longer going directly from the Lipo to the Vin but boosting the voltage from the battery to 5v then to Vin and I also changed the transistor to a 2N-2222A and things seem to be working as expected.I don't know enough about transistors to say what fixed it but I'm guessing the one I was using wasn't the right one for my application.
    – farzadb
    Jun 24, 2020 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.