Running 5V device from digital pin

I have a project that I am trying to run from an 18650 lipo battery. The project needs to wake up and measure a temperature with a DS18B20 and then also measure a sonic distance with a HC-SR04 sonic sensor. Since it is battery powered I need the power draw to be as little as possible, because of this, I am running the temp sensor off of a digital pin so I can shut it on and off. This is working beautifully. The problem that I am having is the HC-SR04 is a 5v powered sensor and because I’m powering the photon through the VIN pin with a 3.7 volt LI-Ion battery I do not have a 5v source to power the sensor. So I purchased this little board from amazon…

The board works great if I hook it up to the 3.3 pin but then it is powered and wasting battery when the photon is asleep. It will not power up if I try running it off a digital pin switched high. I assume it doesn’t have enough juice to run the board. The HC-SR04 is only supposed to need a few miliamps at 5v so there has to be a better more way to power this from a digital pin. So any ideas for this?

I would power the board from the battery with a MOSFET switch in between that you could use to turn off the board when the Photon is asleep. The gate of the MOSFET would be connected to one of the Photon’s digital IO pins.


Would this have a similar or way less of a drain as I currently have? I was looking at this one

do you have an example or better example in mind? Sorry for all the questions Im a hobbyist learning as I go and I’ve never used one of these before.

nvm some reading has cleared the air on what these do and I think this looks more simple and all I need. Looks like I could use them for lots of things!!! Ive always used relays even with DC haha these seem way easier for simple small DC switch!!

1 Like

Those are the ones I usually use too.

good to know! I knew I could count on this forum again. Thanks for your help I’ll get these ordered up!