Attiny85 route vcc though output pin I'm still learning the basics so please bare with me if something seems unclear ;-)

I want to hook up an Attiny85 to a WiFi module (esp8266) and 2 sensors. The VCC will be provided by a battery pack and a step-up/step-down converter to ensure steady voltage without too much efficiency loss. Right now the modules are all hooked up to the VCC rail, together with the Attiny85 in one circuit.

I would like to take a sample, and then make as much of the circuit power down until the next reading with a 2 minute interval or so.

While looking for power saving modes for the esp8266 and struggling a bit with it, it got me thinking. What if I let Attiny85 handle the WiFi and sensors circuit via an OUTPUT pin and just turn that high or low. I read somewhere that an OUTPUT pin would not be able to supply as much current as if it was directly connected. That would probably be the case for me here since the WiFi module draws significant current.

Maybe using a transistor to "flip the switch" be a good solution instead if that is the case?

So my question is, is my way of thinking here even viable? How do I know what kind of max current can go through an OUTPUT pin?
What you want is a P-channel MOSFET to control the power. Something with a nice low "logic level" gate threshold.







simulate this circuit &ndash; Schematic created using CircuitLab

R1 keeps it switched off.  Set the output to LOW to pull the gate down and enable the MOSFET.

Be sure to "stop" your Serial connection and set both TX and RX pins to INPUT to prevent damage to the ESP8266 (or ATTiny) while powered off.