+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Newbie level 4
    Points: 33, Level: 1

    Join Date
    Aug 2019
    Posts
    6
    Helped
    0 / 0
    Points
    33
    Level
    1

    NodeMCU sinking current through DIO while power is off

    Hello, the issue I'm having with the circuit below is that the DIO pin is sourcing current while the push button is open. There are actually several push buttons that are arranged exactly as shown in the circuit below, but I've only shown one. The device is running on a battery, so I'm trying to have no current consumption while the push button is not being pressed. Could someone please take a look and offer some suggestions? Also, why is the input pin acting as a ground pin in this configuration while the power is off ??
    Thanks!
    ps. The purpose of the circuit is to detect which push button is being pressed, which will determine what the micro controller does when it's powered on.


    Click image for larger version. 

Name:	NodeMCU_wiring_diagram.jpg 
Views:	6 
Size:	124.6 KB 
ID:	155011
    Last edited by smckinnon; 16th August 2019 at 18:29.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 80,963, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,270
    Helped
    4432 / 4432
    Points
    80,963
    Level
    69

    Re: NodeMCU sinking current through DIO while power is off

    I'm hardly surprised, disconnecting the ground will almost certainly violate the maximum voltage and polarity ratings of the nodeMCU.
    Consider that the DIO pin effectively becomes the ground (lowest potential) pin on the device while the supply is still present. You really need to switch the supply if you want to power it off but you are likely to run into a different problem, the time it takes from powering up to reading the switch.

    nodeMCU is not a particularly low power device but you can do some tricks to reduce its consumption, for example putting it to sleep and awakening it when a button is pressed or using some external low power logic to read the switches then powering it up to read them. It really depends on what other things it has to do. Presumably you chose that device for its WiFi capability and you need to be aware that if takes quite a lot of current when the transmitter is turned on.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  3. #3
    Newbie level 4
    Points: 33, Level: 1

    Join Date
    Aug 2019
    Posts
    6
    Helped
    0 / 0
    Points
    33
    Level
    1

    Re: NodeMCU sinking current through DIO while power is off

    Quote Originally Posted by betwixt View Post
    I'm hardly surprised, disconnecting the ground will almost certainly violate the maximum voltage and polarity ratings of the nodeMCU.
    Consider that the DIO pin effectively becomes the ground (lowest potential) pin on the device while the supply is still present. You really need to switch the supply if you want to power it off but you are likely to run into a different problem, the time it takes from powering up to reading the switch.
    Thanks, could you explain how switching the ground violates the maximum voltage and polarity ratings?
    Also, I had tried using a P Channel mosfet, but the issue I had was the supply voltage is 9 volts, and the allowable DIO voltage is 5 volts. I couldn't figure out how to drop the voltage to the input pin without consuming power when the device was off. What do you mean "you are likely to run into a different problem, the time it takes from powering up to reading the switch" ?

    Also, the push button's I'm using are rated at 150mA @ 24Volts DC. I think a simple solution would be to remove the Mosfet completely and use the pb as a high side switch to Vin on the NodeMCU. The pb inputs could then be pulled low when the corresponding button isn't pressed (while off/booting), and go high to 3.3 volts using the zener configuration (consuming no power while off). I measured the current consumption and it didn't go above 300 mA for the time it was turned on (stays on for 4 second intervals). I believe the current rating of the button is increased by lowering the voltage to 9 volts, but I'm not sure what the limit would be. The naive solution of maintaining the same power rating is incorrect. I've emailed the manufacturer for their input, but haven't heard anything back... Any idea how to determine that?
    Thx.
    Sean

    - - - Updated - - -

    Like below. Just not sure if the button is rated for 300mA @ 9VDC, the spec only says 150mA @ 24VDC ?

    Click image for larger version. 

Name:	NodeMCU_wiring_diagram2.jpg 
Views:	4 
Size:	119.8 KB 
ID:	155019

    - - - Updated - - -

    One thing I didn't try when using the P Channel Mosfet was connecting the input to the drain (via the 3.3v zener). I had it connected to the gate of the Mosfet.
    Does anyone see an issue with this idea below?

    Click image for larger version. 

Name:	NodeMCU_wiring_diagram3.jpg 
Views:	6 
Size:	266.3 KB 
ID:	155020



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 80,963, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,270
    Helped
    4432 / 4432
    Points
    80,963
    Level
    69

    Re: NodeMCU sinking current through DIO while power is off

    The voltage ratings and polarity limitations are from the DIO pins (and others) to the ground pin. Ask yourself what voltage will there be between DIO pins and ground if you connect the negative side of a 9V battery to the DIO pin and the positive side to Vin.
    What will happen is conduction through paths on the board will make the ground pin float at some indeterminate voltage between 0V and 9V which will likely violate the ratings.

    The switch current is not directly related to the voltage, at least at low voltages. However the nodeMCU, as you noticed, can draw about twice the switch rating which might work for a while but will likely result in welded contacts after a while.

    What do you mean "you are likely to run into a different problem, the time it takes from powering up to reading the switch"
    It depends to some extent on your program but consider that there will be some delay while the nodeMCU initializes after power is applied. If you are relying on the switch providing power it will have to be closed for long enough for the unit to initialize before its state can be read in and acted upon. For example, if the nodeMCU took 1 second to initialize but the switch was only held down for half a second, even if it did manage to start up, the switch would already have been released.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  5. #5
    Super Moderator
    Points: 29,576, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,837
    Helped
    1114 / 1114
    Points
    29,576
    Level
    41
    Blog Entries
    9

    Re: NodeMCU sinking current through DIO while power is off

    I had tried using a P Channel mosfet, but the issue I had was the supply voltage is 9 volts, and the allowable DIO voltage is 5 volts. I couldn't figure out how to drop the voltage to the input pin without consuming power when the device was off.
    The above arrangement with diodes could do that with no need to add any transistor as simulated bellow, however not acting on GND, but rather on supply bus itself, so once any button is pressed, either the power input is supplied (channel A), the power is delivered to device (channel D), and you are able to determine which button were pressed (channels B and C):

    Click image for larger version. 

Name:	Circuit.png 
Views:	4 
Size:	14.7 KB 
ID:	155030

    But obviously you should keep button pressed for a time enough to let the uC do its tasks, so you should provide on the code some way to sinalize (e.g with a LED) the accomplishment of the job.

    Anyway, as Brian said, putting the uC into the sleep mode would be the suited approach, and the ESP8266 has what is called 'deep-sleep' mode, which would sink from the chip an average current of about ~20uA, a pretty small current.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  6. #6
    Newbie level 4
    Points: 33, Level: 1

    Join Date
    Aug 2019
    Posts
    6
    Helped
    0 / 0
    Points
    33
    Level
    1

    Re: NodeMCU sinking current through DIO while power is off

    Thanks for your help.
    Brian, that makes more sense now. I guess I need a better understanding of how the uC hardware can switch between being an input and an output. I assumed there was some kind of isolating in place to prevent the pin from acting as a ground.
    Andre, what's the purpose of the two capacitors in parallel with the zener diodes? Do these just help stabilize the input voltage to 3.3 volts?

    The way I have the code setup, the user pushes and holds the button until the LEDs on the handheld indicate the task is complete (The ESP8266 is in station mode and quickly connects to the AP via a static channel and it's locked to the mac address of the AP. It then sends a modbus command to the appropriate register of an Allen Bradley MicroLogix PLC - the register that's written to is determined by which push button is pressed. The whole thing takes about 2 to 3 seconds.). If the user continues to push the button after the LEDs go out, the NodeMCU goes into deep sleep. The issue with using deep sleep continuously is that the NodeMCU draws far more power than just the ESP8266 alone would. If I recall, this is due to the UART and on board voltage regulator. The deep sleep current draw of the NodeMCU is 3mA (which is too much for my application).
    Thx,
    Sean



--[[ ]]--