I am building an ESP8266 device that uses RFID but need to conserve battery power.
The ESP is a Wemos D1 Mini and the RFID module is a RC522 (still waiting for it to arrive), which needs 3.3 V. I'm powering the ESP with a battery shield and 3.3 V.
But I don't want to connect the RFID module directly to the battery shield because it will be sucking voltage constantly. Instead, I want to be able to control its power using the ESP.
So I thought the easiest would be simply to connect the RC522's 3v3 line to one of the ESP's available GPIO pins, set it to output, and when I need RFID, set the GPIO pin high, to turn on the RFID module.
Is this an acceptable solution, or do I need to wire in a transistor and capacitor somewhere?
1 Answer 1
No, this is not an acceptable solution. The RC522 needs in excess of 100mA to operate, and an ESP8266's GPIO pin can only supply 12mA maximum. You will damage the ESP8266.
You need to use a P-channel MOSFET with the gate pulled HIGH as a high side switch.
schematic
simulate this circuit – Schematic created using CircuitLab
Set the GPIO to LOW to turn on the MOSFET. Set it HIGH or to INPUT to turn off the MOSFET.
Note 1: Set the communication IO pins to INPUT before powering off otherwise they could back-power the target device through the ESD diodes in the IO pins.
-
Thanks. I don't have a mosfet lying around. Can't I achieve the same with a transistor (seeing I can make the GPIO pin HIGH to turn it on, and LOW to turn it off again? eg: groovy.globi.ca/img/…Andreas Huttenrauch– Andreas Huttenrauch07/18/2018 13:47:47Commented Jul 18, 2018 at 13:47
-
@AndreasHuttenrauch Only if the RC522 is OK running at (say) 2.6V. The PNP will impose a voltage drop that the MOSFET would minimise.Majenko– Majenko07/18/2018 13:51:13Commented Jul 18, 2018 at 13:51
-
And yes, it must be a PNP not an NPN transistor. You can't use an NPN as a high side switch like that.Majenko– Majenko07/18/2018 13:53:31Commented Jul 18, 2018 at 13:53
-
So I just need to move the NPN to the low side? (sorry - code veteran but arduino n00b :-) - eg: groovy.globi.ca/img/…Andreas Huttenrauch– Andreas Huttenrauch07/18/2018 13:56:51Commented Jul 18, 2018 at 13:56
-
No, that would be almost as bad - the ground would then be offset and communication may fail. It really wants to be a MOSFET.Majenko– Majenko07/18/2018 14:06:01Commented Jul 18, 2018 at 14:06
it will be sucking voltage constantly
.... not voltage ....current
orpower