Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. MOSFET as relay to keep ESP on until GPIO is low
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

MOSFET as relay to keep ESP on until GPIO is low

Scheduled Pinned Locked Moved Hardware
9 Posts 4 Posters 2.4k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • edsteveE Offline
    edsteveE Offline
    edsteve
    wrote on last edited by edsteve
    #1

    Hi,

    Aim:
    When a door contact reed switch is triggered it should turn ON the Wemos D1, send some data to IFTTT and turn itself OFF after that.

    Function:
    So the Wemos D1 is OFF all the time (to save battery) till the reed switch (SW) turns on the Wemos D1. When the Wemos is ON it triggers the MOSFET by setting GPIO5 to HIGH and keeps itself alive (even without the reed switch) until GIOP5 is set to LOW which turns off the Wemos.

    Problems:
    But i get strange behavior. In general it works. But after the GPIO is set to LOW the hole thing still draws 0,03Amps. And sometimes it draws 0.1Amps and i have no idea why.

    Did i use the right parts? Should i add a resistor somewhere?

    Here is my code (which only explains the function) and some schematics.

    int SWITCH = 5;
    
    void setup() {
    
      pinMode(SWITCH, OUTPUT);
      digitalWrite(SWITCH, HIGH);   // Trigger the MOSFET to stay ON
    
      // Do stuff.... for example send data to IFTT with the ESP8266_To_IFTTT 
    
      digitalWrite(SWITCH, LOW);    // Turn off the Wemos D1
    }
    
    // the loop function runs over and over again forever
    void loop() {
    yield();                      // do nothing
    }
    

    alt text

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kimot
      wrote on last edited by
      #2

      WEMOS ( and other IC ) is not LED.
      So switch it ON through GND is not very good solution.
      P-channel MOSFETs are used for this.

      edsteveE 1 Reply Last reply
      0
      • KoreshK Offline
        KoreshK Offline
        Koresh
        Contest Winner
        wrote on last edited by Koresh
        #3

        Add 10k resistor between the gpio5 and main gnd.

        1 Reply Last reply
        0
        • edsteveE Offline
          edsteveE Offline
          edsteve
          wrote on last edited by
          #4

          Thanks. I understand that my MOSFET is not the best choice. But that's the only one i have here right now.

          The 10K resistor solved my problem. Works great. Thanks for the tip.

          1 Reply Last reply
          0
          • edsteveE Offline
            edsteveE Offline
            edsteve
            wrote on last edited by
            #5

            Hmm... it worked for a while with the 10K resistor but now not any more.
            I guess i have to change the Mosfet to a P-Channel version.

            1 Reply Last reply
            0
            • K kimot

              WEMOS ( and other IC ) is not LED.
              So switch it ON through GND is not very good solution.
              P-channel MOSFETs are used for this.

              edsteveE Offline
              edsteveE Offline
              edsteve
              wrote on last edited by
              #6

              @kimot
              Do you have a common P-Channel Mosfet in mind which works for this project? I am struggling finding the right one.

              K 1 Reply Last reply
              0
              • edsteveE edsteve

                @kimot
                Do you have a common P-Channel Mosfet in mind which works for this project? I am struggling finding the right one.

                K Offline
                K Offline
                kimot
                wrote on last edited by
                #7

                @edsteve
                https://forum.arduino.cc/index.php?topic=294724.0

                1 Reply Last reply
                0
                • edsteveE Offline
                  edsteveE Offline
                  edsteve
                  wrote on last edited by
                  #8

                  Thx for the link.
                  For more info about the solution in this video perfectly explained:
                  https://www.youtube.com/watch?v=nbMfb0dIvYc&t=266s

                  He uses a NDP6020 for Mosfet. The datasheet says:
                  Vgs(th) (Max) @ id: 1V @250uA
                  Gate Charge (Qg) @ Vgs:35nC @ 5V

                  Is 1V the max i can connect to the Gate? That can't be true!?

                  E 1 Reply Last reply
                  0
                  • edsteveE edsteve

                    Thx for the link.
                    For more info about the solution in this video perfectly explained:
                    https://www.youtube.com/watch?v=nbMfb0dIvYc&t=266s

                    He uses a NDP6020 for Mosfet. The datasheet says:
                    Vgs(th) (Max) @ id: 1V @250uA
                    Gate Charge (Qg) @ Vgs:35nC @ 5V

                    Is 1V the max i can connect to the Gate? That can't be true!?

                    E Offline
                    E Offline
                    epaul
                    wrote on last edited by
                    #9

                    @edsteve as per datasheet VGS Gate-Source Voltage - Continuous = ±8 V and Gate Threshold Voltage is Max 1,0V and Min 0,4V, this is working(conducting) voltage.
                    So, according to above datasheet maximum voltage to gate can be ±8 V.
                    About the resistor, you could also try 30K or 100K.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    12

                    Online

                    11.7k

                    Users

                    11.2k

                    Topics

                    113.0k

                    Posts


                    Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • OpenHardware.io
                    • Categories
                    • Recent
                    • Tags
                    • Popular