Help me Understanding the PMOS selection to turn one 5v load with 3.3v logic

nope, those 3v ones does not work. none of them work.
and yes the Ground is same for all.

Which mosfet part number is installed in the circuit? The prints say one thing. You have other part numbers listed in your posts. Which specific part was used and is not working?

Start with the basics. Have you breadboarded your circuit with power supplies to test the circuit off-board? Does the mosfet switch a 5v resistive load with a 0 and 5 volt gate signal? Then does it work at 3.3v on the gate?

The success or failure of this circuit depends upon the very careful selection of the mosfet and the level of the 5 volt supply. A marginal mosfet along with a higher than expected 5v supply and it will not work. As shown, with the output of the esp32 at 3.3v and a 5v led supply, you only have a -1.7 volt gate differential which could be lower than the threshold of the part selected.

WattsThat: Which mosfet part number is installed in the circuit? The prints say one thing. You have other part numbers listed in your posts. Which specific part was used and is not working?

Start with the basics. Have you breadboarded your circuit with power supplies to test the circuit off-board? Does the mosfet switch a 5v resistive load with a 0 and 5 volt gate signal? Then does it work at 3.3v on the gate?

The success or failure of this circuit depends upon the very careful selection of the mosfet and the level of the 5 volt supply. A marginal mosfet along with a higher than expected 5v supply and it will not work. As shown, with the output of the esp32 at 3.3v and a 5v led supply, you only have a -1.7 volt gate differential which could be lower than the threshold of the part selected.

I tested with 5v gate voltage as my older board used ardinuo pro micro in 5v and it worked great. i am using this part rignth now and older board also. and right now it's not working with 3.3v from esp and i tested it with 5v by just connting the gate to the 5v supply and it worked fine. so i think it's a mosfet selection issue now.

"As shown, with the output of the esp32 at 3.3v and a 5v led supply, you only have a -1.7 volt gate differential which could be lower than the threshold of the part selected." correct, i also think that. that si2301 RDs_on voltage is 2.7 but i need lower then 1.7v. https://www.mouser.com/datasheet/2/427/si2301cd-1765174.pdf

so i need to select a mosfet that can do the work so my question is iff i select a fet thhat's rds_on is 1.8 will it work? as there is no fet bellow that 1.8 rds_on voltage.

You should be able to use the circuit you have, but you probably have to change your code at function static void power_lcd(void).

As I see it, you have to have the pin declared as OUTPUT , using pinMode(), with a value LOW to switch the PMOS on. However, to switch the PMOS off, you have to allow the pin to float HIGH (to 5v) by changing it to INPUT. Writing a HIGH to a pin declared as OUTPUT will prevent the pin floating up to 5 volts by holding it at 3.3volts. Don’t write a HIGH to an INPUT pin, though, as that switches on the pull-up resistor (at least on some platforms).

3.3 volt pins may possibly handle 5v presented through a 100k resistor but the current is so low it may be to near the leakage value for the PMOS but that is another matter.

EDIT

I’ve just added this simulation (with a reasonably similar mosfet to the OP’s Si2305CDS ). Clear is that a 3.3 volt pin will not turn the mosfet off unless the pin is switched to high impedance allowing the gate to be pulled up to 5volts.

so there is no way to use that new mos i wanted to use here? that si2305cdc?

and how that floting pin will go to 5v as esp32 runs on 3.3v?

rahmanshaber: so there is no way to use that new mos i wanted to use here? that si2305cdc?

I chose a Mosfet which was available in my simulator. It doesn't mean your choice is wrong. That picture is to illustrate that if you have a 5 volt power rail, the mosfet gate must be 4.3 volts or more to turn it off.

rahmanshaber: and how that floating pin will go to 5v as esp32 runs on 3.3v?

Where does the 5 volts come from in your "schematic" in post #14 ? The issues is anyway not the 5 volts, it is the that the gate must be within 0.7v of the source to switch the mosfet off.

You've understood that, if I am correct, this is just a coding problem ?

// in setup() , remove this statement:
pinMode(POWER_LCD, OUTPUT);



static void power_lcd(void)
{
  if(lcdState){
    // digitalWrite(POWER_LCD, LOW);
    pinMode( POWER_LCD, OUTPUT ) ;  // pin register is LOW at set up so this forces the pin LOW
    Serial.println("POWER_LCD=LOW");
    lcdState = 0;
  } else {
    // digitalWrite(POWER_LCD, HIGH);
    pinMode( POWER_LCD, INPUT ) ;     // high impedance : allow pin (gate) to float high via pull up resistor.
    Serial.println("POWER_LCD=HIGH");
    lcdState = 1;
  }
}

Yes, the code works very good. but still don't get the how gate goes to 5v or the difference comes to 0.7v when the pin is floating. if the pin flots what is the voltage of that pin from the esp? That 5v is only to powering the LCD and pi. Esp-32 does not have access to it. Also i need the lcd turned on when the device boots, so i called the powerLCD() in the main function. but some how the lcd does not auto turned on on the boot. Also another serious question, when those pins will be in load like 500~800 mah will the on-off function work?

void setup(void){
  
  // Set PIN Stater
  pinMode(LED_1, OUTPUT);
  pinMode(LED_2, OUTPUT);
  pinMode(POWER_MAIN, OUTPUT);
  pinMode(POWER_OFF, INPUT_PULLUP);
//  pinMode(POWER_EX, OUTPUT);
//  pinMode(POWER_LCD, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  pinMode(BATTERY_MESUREMENT, INPUT_PULLUP);
  pinMode(PI_STATE, INPUT_PULLUP);

  // Set thumbstick PIN Stater
  pinMode(upButton, INPUT_PULLUP);
  pinMode(downButton, INPUT_PULLUP);
  pinMode(leftButton, INPUT_PULLUP);
  pinMode(rightButton, INPUT_PULLUP);
  pinMode(mouseButton, INPUT_PULLUP);


  // Set Switch State
  digitalWrite(POWER_MAIN, HIGH);
//  digitalWrite(POWER_EX, LOW);
  digitalWrite(POWER_LCD, LOW);
  digitalWrite(BUZZER, LOW);
  powerstate = digitalRead(POWER_OFF);

  power_lcd();
  
  // Serial setup
  Serial.begin(115200);

  // Set up Keyboard and Mouse HID
  device.begin();
  
  // Set up keypad matrix
  Dummy.setHoldTime(1);
  Dummy.setDebounceTime(0);
  Dummy.addEventListener(keypadEvent);
  delay(1000);
}

OK. I'll try to answer your direct question then go on to make some general comments about the project and your approach to it.

...but still don't get the how gate goes to 5v or the difference comes to 0.7v when the pin is floating. if the pin flo[a]ts what is the voltage of that pin from the esp?

The gate goes to 5 volts because the 100k gate pull-up resistor is connected to a 5 volt rail according to the "schematic" in your post #14. When the ESP32 puts its pin, which is connected to the PMOS gate, into high impedance (INPUT) mode, it effectively disconnects itself from the PMOS. Therefore, the only voltage source for the PMOS gate is the 5 volt rail via the 100k resistor. So the PMOS gate floats to 5 volts. The gate must be at 5volts (or very close) to fully switch the PMOS off. This solution is a compromise and has limitations.

From the complexity of the project you are working on and the elementary issues you are facing, I am guessing that you are not the original project author. It appears (from post #11) that you have started with a "Micro" design, that is a native 5volt device and adapted the design for a 3.3 volt ESP32. Clearly, a 5volt MCU has no problem managing a PMOS connected to a 5 volt power rail. In your case, the best solution would have been to use a proper high side switch design such as @crossroads presented in post #6. However, you are reluctant to do that because you have already fixed the PCB design. So whatever you do is a compromise.

Using a weak gate pull up resistor works but, because of the gate capacitance of the PMOS, it will switch off slowly. Because of this, the design is not suitable for, say, PWM at any reasonable frequency because the PMOS would often be in a "half conducting" state and start getting warm, especially at the 500~800 mA current levels you are talking about. If you are not attempting to rapidly switch the PMOS on and off, it should be OK. You cannot solve this with a much stronger pull up resistor because you will stress the pin protection diodes of the ESP32 which are designed to protect 3.3 volt pins. You could possibly minimise this by a diode between the esp32 pin and the PMOS gate but that would mean a new board design.

Very generally, if the PMOS stays cool under maximum load conditions, it should be OK.

rahmanshaber: yes.

Then it wont work. The gate must be at +5V to switch the pFET off fully. Taking it to +3.3V will leave it on, possibly only half-on, but not switched properly off.

You need the two transistor circuit to switch 5V high-side from 3.3V.

6v6gt: Clear is that a 3.3 volt pin will not turn the mosfet off unless the pin is switched to high impedance allowing the gate to be pulled up to 5volts.

CMOS pins are clamped to the supply and ground with protection diodes, so it can't be pulled up to +5V when high-impedance, but to about 3.8V.

You cannot switch high-side with a single device from a lower voltage as you need to level-shift. Low-side switching is possible with a single device, but that splits the ground which is often not desirable.

6v6gt:
From the complexity of the project you are working on and the elementary issues you are facing, I am guessing that you are not the original project author.

I know it’s hard to believe, but i am the original and only one working on this. I am not a skilled full one but trying to learn this stuff.
The issue with me not doing the proper way like adding another transistor to the gate is because of the part count. and i opened this issue looking for a part selection guide not for a hack. I also won’t release the final board with this hack.
i think i will use the power circuit that i am using to power up the device, it uses duel p and n channel mosfet to turn things on and off. and it’s working with 3.3v. But i am not sure it will be great choice as it’s footprint big and require another resistor. I can use this mosfet as it’s already in the BOM list.

So what you think about the bellow circuit?

Well some devices from this millenium might be a start(!). A logic level pFET and an NPN BJT for
the level shifter would be good (3.3V MOSFETs are pretty much only SMT). With an NPN
level shifter add a series 1k base resistor. 100k for R1 means a slow switch-on, note, which
might or might not be what you want.

As i said BOM is a big thing in my project, I know and PFET and a NPN will be a solid way to do it. I would rather use an existing part from the BOM if it works well like duel channel P and N fet. I don't mind the switching time at all. But i am not sure the circuit will be sutible or work reliably with esp32 to turn on the 5v load.

OK. This project is going to be an excellent learning experience. I'm pleased at least that you are considering a more robust solution. To reduce the parts count, you can also consider using "ready made" high side switches. Here is an example which I have used: https://www.ti.com/lit/ds/symlink/tps27081a.pdf . These may still require some external components, depending on how you use them because they also offer possibilities like variable slew rate for a "softer" switch on if required.

edit

post crossed with OP

Just a note, these are the same chip drawings for the TPS27081A.

This type of parts are not that popular i think, i searched in the aliexpress and got only 8 sellers. also the price is higher. My project is for hobbyist.

Do you have any popular one that's easily available? i don't want to see after 2 years that part is hard to get. Any comments on using the circuit i showed, as those parts already in the list it will be much easier to use.

I often use the AO4614B.

yes, i am using the one mosfet that have dual fet in it. AO4616 or IRF7319 So what you think about using that to turn on and off using a 3.3v logic?

What @MarkT pointed out, that I had neglected the effect of the clamp diodes, is quite correct. I’ve attempted now to model the clamp diodes (just using Schottky diodes) and then use a 2.4volt zener to allow the gate to swing between 2 and 5 volts. This range appears to be sufficient to force the PMOS into clean states (fully conducting/fully non conducting). You would not then need the trick of switching the pin to high impedance to get it to work. Having said all that, I don’t actually recommend it because I prefer the high side switch model. The 100k pullup resistor gives a very soft switch off. 1k gives a very clean switch.

@6v6gt i have no idea what you guys are talking about. I just wanted to know if this circuit with duel mosfet. because i already have the chip in the list.
i am concerned about the battery one also, to turn on the 2.8~4.2v battery with 3.3v with that circuit.