50mA peak from digital pin on Electron

I have a sensor which I want to power from my electron.

It draws average 2.1mA at 3.3V, Peak 50mA

I’ve had it working powered straight from the 3.3v on the electron but I want to be able to control when it is powered and not. Can I power it from a digital I/O pin, I’ve read that these can only supply 20mA?

If theoretically it cannot provide enough power, would I do any damage if I were to attempt to power it from a digital pin and see whether it still works?

Alternatively I guess I just have to connect an NPN transistor from a digital pin to the sensor and up to the 3.3v and gnd pins. Any problems with that and does anybody have any suggestions for good transistors.

Thanks

If theoretically you wouldn't survive being shot, would you still risk it? You can always try and see if you walk away from it, but it might not be the best of ideas.

The limits are there for a reason, and breaching those is at your own risk with increased chances of failure. I'd go with a transistor and be on the safe side, they're a lot cheaper than an electron :wink:

1 Like

Agreed! Using a simple transistor is best practice versus powering the sensor directly with the GPIO of the Electron. Better not to risk it :slight_smile: