I want to use a nodemcu to water my plants. I connected a pump with a 2N2222 transistor (I know i should add a diode and a pull down on the gate). The pump is DSL370 and when it is off i measure 4.4V on the Vin pin while using a 2A charger connected to the USB port. When the pump is active, the vin voltage drops to 4.1V and the LCD becomes hard to read. I measured the current the pump uses and it is 300mA. What is the reason for the voltage drop? I thought the charger should be able to handle it. Also, as i saw at http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/powering-the-esp-12e-nodemcu-development-board/ The power from the USB is connected to the Vin via a diode so the Vin and the esp8266 power should not affect each other.
-
1\$\begingroup\$ what is "2A charger connected to the USB port"? Do you have type-C USB? \$\endgroup\$– MapleCommented Jun 11, 2018 at 6:48
-
1\$\begingroup\$ Did you actually connect the GND on the NodeMCU? \$\endgroup\$– Criticizing Israel not allowedCommented Jun 11, 2018 at 7:05
-
\$\begingroup\$ wire it to vin instead of the usb socket to avoid blowing out the nodemcu's diode and taking the voltage hit. \$\endgroup\$– dandavisCommented Jun 11, 2018 at 9:25
-
\$\begingroup\$ Of course GND is connected to the NodeMcu, missed it in the sketch. \$\endgroup\$– zbutCommented Jun 11, 2018 at 10:57
-
\$\begingroup\$ @dandavis what "it" are you talking about? \$\endgroup\$– MapleCommented Jun 11, 2018 at 11:27
1 Answer
Technically, you can connect USB power to VU input or USB jack and draw power from Vin trough schottky inside, as in your picture. However there are several problems with this:
- schottky will drop USB voltage by at least 0.6V.
- If your USB power comes from PC then you cannot draw more than 100mA without negotiation with the host. And PC is allowed to drop to 4.4V in these conditions.
- If your USB power comes from external charger through the jack then you cannot communicate with PC at the same time.
Another option is to connect LCD+Motor to VU pin, bypassing the schottky. In this case you can power the board via USB jack from external power supply and everything will work fine. But the problems #2 and #3 will still remain.
So, the solution is to power LCD and Motor directly from charger, if their voltages compatible, or through 5V voltage regulator if not. The same supply wire will also power nodeMCU through Vin pin. Main points here are:
- Motor power never comes through either schottky or internal nodeMCU regulator;
- Motor power never comes from PC USB port.
However you can separate LCD from motor and power it from either 3.3V or VU pins, depending on what voltage it needs. Then you will have working LCD whether you power nodeMCU from PC or from external charger.
-
\$\begingroup\$ Ok got it, will use a regulator and connect it to Vin. By the way, aren't phones charged with more than 100mA? \$\endgroup\$– zbutCommented Jun 11, 2018 at 10:55
-
\$\begingroup\$ The phones negotiate the available power with the computer after establishing data connection. That is why you sometimes cannot fast charge the phone if it is not recognized by the operation system. \$\endgroup\$– MapleCommented Jun 11, 2018 at 11:10
-
\$\begingroup\$ "will use a regulator and connect it to Vin" still does not make sense. What regulator? 3.3V as in that article is only necessary if you want to power other 3.3V devices. And you connect it to 3.3V pins, not Vin. If your motor and LCD require 5V you can use 5V wall adapter to power up nodemcu (via Vin pin) and all other devices directly. \$\endgroup\$– MapleCommented Jun 11, 2018 at 11:36
-
\$\begingroup\$ I am not connecting the USB charger to a computer but to wall socket. I have a regulator that can output 1A@6V and i can use a voltage divider. But theoretically, what is the difference between taking a 2A@5V USB charger, splitting its wires and connecting the power to Vin VS connecting it to the USB socket of the NodeMcu (Aside from the diode voltage drop)? \$\endgroup\$– zbutCommented Jun 11, 2018 at 17:15
-
\$\begingroup\$ OK, now I got it. If you have answered my very first comment we could have avoided a lot of misunderstanding. I'll modify my answer. \$\endgroup\$– MapleCommented Jun 11, 2018 at 17:26