Maybe something like this:
Notice, for
Q2, I used a MOSFET -- Much better choice, in my opinion. Also, I left out the
Flyback Diode, normally placed across the motor. The choice for
Q2 will depend on the demands of that motor, but whatever MOSFET is used, must have a
very low Gate Threshold voltage -- on the order of
2V or below. Or, some sort of Gate Driver will be needed. Why? Because, for the
ESP8266, running at a mere
3.3V, will only be able to apply around 3.3 - 0.7 ≈
2.6V because of the
1N914 diode drop.
GPIO2, via Q1, is for locking out control from the Arduino. When GPIO2 goes HIGH, it causes Q1 to clamp Q2's gate LOW. When that happens, nothing the Arduino throws at the gate will change that LOW condition. When GPIO2 is LOW, Q1 becomes a high impedance path, which allows both the Arduino and the ESP8266, to control the motor.
C1 supplies supplemental current during WiFi transmit bursts. The value may need to be adjusted, depending on actual conditions. I figured on 3mS bursts of 200mA, causing an approximate 130mV droop -- using a back-of-envelop calculation:
[b]C1[/b] = IT/V = 200mA * 3mS / 0.13V = [b]4615µF[/b]
-- so, you know... 4700µF
The voltage of C1 depends on what voltage is supplied to the Arduino Vin pin.
If Q2 needs to be some mega-current handling beast [with a very high Gate Capacitance], then, the values of R2 & R3 may need to be lowered to something more like 10k or even, heck, 1k ['cuz the those outputs can take it, after all]. Tweak as needed