Power gsm module through digital pin of arduino

Hello i would like to power up my gsm module from a digital pin on my arduino and not the 5v pin .
I want to do that in order to be able to turn of and on the module whenever i want with digitalWrite().
So i connect the "V_bat" pin of my gsm module which is the positive pin to my digital pin 5 on arduino and my ground to ground obviously.

i use

pinMode(5, OUTPUT);
digitalWrite(5, HIGH);

and my gsm module turns on (1st led turns on on module) .
but then i have to press the power_key on my module in order to start the gsm module (it turns up 2 leds in module when it succeds) but the 2nd led doesnt turn on and the 1st led dims .
So my problem is that the digital pin set to high doesnt give enough power , not the same power as the 5v pin at least.

what can i do in order to fix this ?
I know that the digital pins have the internal pullup resistor but it doesnt activate in OUTPUT.
i measure with a voltometer on my 5 volt pin and i get 4.8 volts and on my d5 pin set to high i get 4.3 volts

(deleted)

thank you for your response .

if i understand correcly with a transistor i put the collector to 5v pin on arduino the base to d5 to set to low and high when i want and the emittor to gsm module v_bat pin.

i used 2n2222 transistor and this seems to be working . is this transistor fine thought ? because the module needs like 2A to work .

i did the connection based on this schematic

Do not switch the power at all! You must switch the GND / ground instead and the reason being that the data pins supply current and if the ground is available on the module, the module may be partially powered and cause a minor power consumption for no reason.

(deleted)

So i have to do the same thing with the transistor but replace the VBAT pin with the ground ?
and when ill set the base to low it will cut the power and high it will enable to flow again ?

i have attached a pdf that has some info of the ai a7 thinker i use.
if you look at the VBAT pin (pin 41,42) it sais it is the power pin and needs (3.5V-4.2V, >2A)

Sorry if i am mistaken with something , I'm pretty noob at this stuff.

A7_(GSM+GPS+GPRS+GPRS)module_Hardware_introduction.pdf|attachment (256 KB)

If you switch the module with a NPN transistor, you need a "common collector" setup:

Module GND -> Transistor Collector
Switch pin -> 1k resistor -> Transistor base
Transistor emitter -> GND

When the switch pin is HIGH, the module will have ground and be active, and when the switch pin is LOW, the module is off. The module seems quite power hungry (up to 2A), so you need a decent size transistor or it will pop.

The module seems quite power hungry (up to 2A), so you need a decent size transistor or it will pop.

Could you tell me a specific transistor or mosfet that you believe it will be fine with this project ?

No, you should ask in the hardware section of the forum for a proper advice on that. Because the transistor is used as GND switch / sink you should be able to use a transistor with rating lower than 2A, something like the commonly used PN2222 or BC337 may be sufficial, but do the math before the fire :wink:

Thanks you i will consider all of these tips :slight_smile: