Using mosfet to cut power to pn532 board

Hi all,

First some background: I'm working on a hobby project to create an rfid-based remote control for my Home Assistant alarm system. I've used the Zipato RFID Mini Keypad before for this, a Z-Wave device, but it is out of stock and the manufacturer is not planning to produce more. What I'm trying to design is a device that can

  • arm and disarm Home Assistant alarm system using cheap RFID tags
  • does not require any wiring, for power or for communication
  • should run on battery power for at least one year

I've created a Github project which you can find at GitHub - janpascal/rfidpad: Hardware, firmware, and Home Assistant integration for an ESP32 based device to enable and disable a Home Assistant alarm system. I have a working prototype based on an ESP32 board with integrated battery charger that should draw less than 20 μA in deep sleep mode, combined with a PN532 RFID board (connected via I2C). The device should spend most of its time in deep sleep, until woken up by a pushbutton, then read the RFID tag and send the tag ID over MQTT together with the button that has been pushed (labeled disarm, arm home and arm away). The firmware for the device is mostly done, and can be found at the Github project together with the schematic for the prototype.

My current problem is with the power use of the PN532 board. The specs of the PN532 chip itself mention a deep sleep mode which should draw 10 μA. Unfortunately,

  • entering deep sleep mode isn't supported by the PN532 library
  • the board has an LED which burns continuously

Because of these two reasons I would like to cut all power from the PN532 board when entering deep sleep mode, and restore power to it when the ESP32 board wakes up again. I can't power the PN532 board directly from a GPIO pin since its needs 150mA and the ESP32 can only deliver 40mA. I've looked around for solutions for this problem, but what I found mostly wasn't focussed on the deep sleep current which is essential in this case. I've drawn up a schematic using a logic-level N-MOSFET in depletion mode, since it is normally off, allows no current at all when off, and requires no current to stay off. The idea is that when pin GPIO35 is high the MOSFET opens up. R1 is for protection of the GPIO pin, limiting the initial current to fill the gate. When pin GPIO35 is put in high impedance mode, the gate is drawn to ground via R2, closing the MOSFET completely while requiring no current. R3 and R4 are the usual pull-up resistors for the I2C line.

My questions:

  • Would this schematic work, requiring no current when pin GPIO35 is in high-impedance mode?
  • Any suggestions for the MOSFET? I've thought of the TN0702 or the ZVN4106, the latter because it can be sourced locally in The Netherlands
  • Any other suggestions?

Many thanks for your thoughts!

Because you have placed the mosfet between the 3.3V supply and Vcc of the pn532, you should use a p-channel mosfet, not n-channel. Sorry, I can't recommend a model, I am not experienced with them.

As PaulRB says, switching the high side power usually is better done with a P-channel mosfet. The N-channel would require that the gate voltage be a couple volts above the source to turn the mosfet on. But your GPIO port will only provide 3.3V, which is what you want the source to be. So there is no GS differential to turn it on.

A P-channel would need a pullup resistor on the gate, and you would turn it on by bringing the gate low, which your GPIO pin can easily do. That creates a -3.3V GS differential.

The choice of a part would depend on what kind of package would be appropriate for your circuit. Unfortunately, there are no TO-92 parts that would work well at 150mA. The NDP6020P comes in a big TO-220 package, and the DMP1045U is a good surface mount choice.

But there's another problem. I have no experience with the ESP32 boards, but I assume the 3.3V pin is the output of a 3.3V regulator on the board. There's a fair chance that regulator won't provide enough current for the ESP32 itself and the 150mA needed by the PN532. ESP32 experts here would need to comment on that.

One other thing. You need to see how much current the ESP32 draws even when it's in deep sleep. I think these radio chips don't sleep very soundly.

I have no direct experience with esp32 either, only esp8266. Neither esp32 or esp8266 have a 3.3V regulator. Boards based on those chips normally do, but the model of regulator depends on the board, and they won't all be the same. Both esp8266 and esp32 are capable of very low power sleep, but again, the board they are on may not have been designed with that in mind. Caveat emptor! Maybe post a link to the board you plan to use and perhaps we can advise.

Thank you all for your comments! I'm planning to use the EZSBC esp32_bat board (https://www.ezsbc.com/index.php/products/wifi01-bat.html). According to the specs, it should draw around 10μA from the LiPo battery in deep sleep mode. I'll need to turn off WiFi and maybe more before entering deep sleep, I'll get to that in due course.

I've already powered the PN532 board from the 3.3V of the EZSBC board without problems other than using the right value for the pull-up resistors on the I2C lines (3k3 seems to work fine). I've run the board using my firmware (GitHub - janpascal/rfidpad: Hardware, firmware, and Home Assistant integration for an ESP32 based device to enable and disable a Home Assistant alarm system) and it seems to work alright.

I've updated the schematic following your suggestions. Could you please have a final look? Have I taken the right values for R1 and R2?

Thanks again!

100R and 10K will be fine, the values are not critical. The model of p-channel mosfet is the important choice, and as I said, I'm no expert on them.

The esp32 board sounds like a great choice, if that 10uA is accurate. Let us know what you find.

Your link to the ESP32 module has the schematic under Downloads, and it shows the regulator as the Holtek HT7333. That regulator is rated at 250mA, which I would think is pretty close to the combined current draw of your devices when both are active. But if they are only on intermittently, or not at the same time, it may work ok. The test would be whether there is any sag on the 3.3V pin when everything is on, and whether the regulator gets hot.

In your drawing you have the mosfet upside down. The source should connect to the ESP32, and the drain to the PN532.

Also, the gate series resistor should be connected directly to the GPIO port, then the series resistor should be placed after that connection. So in effect the pullup would become 10.1K. The way you have it now, the gate is in the middle of a voltage divider when the GPIO goes low, so it never quite gets to ground. With the selected resistor values, it probably doesn't matter, but you might as well do it the right way.

Thank you all for your most valuable suggestions! The final (hopefully) schematic should be this:


The whole system will only be on for at most 15 seconds at a time, so I wouldn't expect the voltage regulator to overheat. I've ordered a few of the NDP6020P FETs to experiment with. I'll report back here on the current drawn by the ESP32 board in deep sleep, and I'll check if the 3.3V of the ESP32 board is stable when the PN532 board is powered from the board. Thank you all again!

Finally got some time to spend on this project. The board is fine, without the PN532 connected it indeed draws around 10μA in deep sleep. The circuit also effectively cuts power to the PN532, but I just discovered that even in deep sleep there is still a 70μA current though each of the I2C lines (which goes away if I disconnect the IO pins), bringing the total up to 150μA again. Not bad, but could be better. The GPIO32 and 33 lines should be disconnected/high impedance when the ESP32 board goes to deep sleep, I'll check if there's still something fishy thereabouts.

Maybe there are some pull-up resistors on the i2c pins of the esp32_bat board. I can't see the schematic that ShermanP mentioned, I just get "page not found" errors from that whole site.

70uA would be a 47K pullup resistor - somewhere. Either inside the ESP32 or on its board. Also, maybe the ESP32 is different, but the AVR processors maintain their state in sleep mode. If that's true, you could turn off I2C and set those lines active low before going to sleep, or even just make them inputs.

There indeed seems to be some internal pull-up resistors that are enabled when I2C is active on the pins, and that are not disabled automatically when the board enters deep sleep.

They can de disabled manually with

  wire.~TwoWire();
  pinMode(PIN_SDA, INPUT);
  pinMode(PIN_SCL, INPUT);

The entire circuit now draws around 9.1μA from the LiPo battery in deep sleep. That's five years deep sleep time for a 400 mAh LiPo, not bad at all! Thank you all again for your help!