The product information on the DIYables water level sensor says it can pull a maximum
of 20 milliamps of current.
The spec on an ESP8266 switched digital output is 12 ma. I wanted to switch the sensor
supply voltage off and only power it during a poll/read. This supposedly helps delay corrosion if in a high humidity environmet, which my sensor will be in. And reading it maybe once every 10 minutes would be sufficient.
I realize that. Attaching it the 3v power pin to constantly power it is not an issue as that pin handles more than a switched digital pin that only handles up to 12 ma.
Since they are so inexpensive I may just power it constantly and not worry about any potential onset of corrosion to the sensor traces. Or look at adding another digital output that controls a small relay through a transistor.
I have this ESP8266 absolutely maxed out on pin use. Hopefully it will take it all in stride.
You can use a MOSFET or relay to power it. This will you to turn it on and off as needed. The MOSFET should be controlled with a digital pin. It translates a voltage and switches the current not the controller. Here is a simple low side and high side switches. Your digital pin will go to the gate. If you want it off during reset etc place a 10K resistor between the portpin that is connected to the mosfet and ground for the low side and Vcc for the high side switch. Hope this helps.
I had that idea as a last resort and it looks like that is the way to proceed.
I was hoping someone might have tried to power one with a digital pin turning off
and on.
I am closing this thread and using your post for a solution.