user77936: I want to rewire a battery powered LED strip (as shown in the picture below) to power via an ESP32's GPIO pin. I have a ESP32 NodeMCU Development Board, powered via USB.
The LED strip has specified 3,2V/20mA for the 100 LEDs. It originally uses three AA batteries. From what I've gathered the ESP32 should have a max current output of 40mA.
Other than the LED strip, the ESP32 uses WiFi and addresses a DHT22.
The goal would be to turn the LEDs on/off via a GPIO, for example:
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
digitalWrite(4, LOW);


Would it be safe to power the LED strip via a GPIO pin?

user20245: Quick answer is probably not.  Why?  The numbers don't add up:

...3,2V/20mA for the 100 LEDs...

From here we find this comment:

Most common LED’s require a forward operating voltage of between
approximately 1.2 to 3.6 volts with a forward current rating of about
10 to 30 mA, with 12 to 20 mA being the most common range.

(Actually there are low current LED on the market now that only need about 3mA to operate.  Let us assume this is what you have for our calculations.)
So, given the above is true, and if your string of LEDs were all in parallel and had average specifications, we calculate the current and voltage of the string of 100 LEDs:
Current: 100 x 3mA = 300mA or 0.3 Amps
Voltage: About 2 Volts. 

(Note: When designing with LED you should always refer to that LED's specification.  The above 30mA and 2 Volts is only a guess.)
So, even if your LEDs are of the low current type, you can see a string of 100 such LED in parallel exceeds the initial expected current for the entire string of 100 LEDs.
This assumes the LEDs are in parallel and the power source is a constant voltage.  What if the LEDs are in series?  Then you would need a constant current power source.  Again let's assume the individual LED specifications are 2 Volts and 3 mA.  Now the calculations might look like this:
Current: About 3mA.
Voltage: 100 x 2 Volts = 200 Volts

Obviously the voltage far exceeds the capability of three 1.5 Volt batteries.
Ah!  Bigclivedotcom gives us some insight in his 2017 youtube video about repairing several variations of low voltage LED strings. The 3 different strings he uses in his video address how these LED strings can be made such that different voltage and current sources can be used to power them.
In conclusion it is likely your string of LED will require more current to power then a GPIO pin who's maximum current rating is only 40mA can provide safely.

77936: <p>I want to rewire a battery powered LED strip (as shown in the picture below) to power via an ESP32's GPIO pin. I have a ESP32 NodeMCU Development Board, powered via USB.</p>
<p>The LED strip has specified 3,2V/20mA for the 100 LEDs. It originally uses three AA batteries. From what I've gathered the ESP32 should have a max current output of 40mA.</p>
<p>Other than the LED strip, the ESP32 uses WiFi and addresses a DHT22.</p>
<p>The goal would be to turn the LEDs on/off via a GPIO, for example:</p>
<pre><code>pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
digitalWrite(4, LOW);
</code></pre>
<p><a href="https://i.stack.imgur.com/HmoYh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HmoYh.jpg" alt="LED strip" /></a></p>
<p>Would it be safe to power the LED strip via a GPIO pin?</p>
 20245: <p>Quick answer is probably not.  Why?  The numbers don't add up:</p>
<blockquote>
<p>...3,2V/20mA for the 100 LEDs...</p>
</blockquote>
<p>From <a href="https://www.electronics-tutorials.ws/diode/diode_8.html" rel="nofollow noreferrer">here</a> we find this comment:</p>
<blockquote>
<p>Most common LED’s require a forward operating voltage of between
approximately 1.2 to 3.6 volts with a forward current rating of about
10 to 30 mA, with 12 to 20 mA being the most common range.</p>
</blockquote>
<p>(Actually there are <a href="https://www.digikey.com/en/product-highlight/s/sunled/ultra-low-current-leds" rel="nofollow noreferrer">low current LED on the market</a> now that only need about 3mA to operate.  Let us assume this is what you have for our calculations.)</p>
<p>So, given the above is true, and if your string of LEDs were all in parallel and had average specifications, we calculate the current and voltage of the string of 100 LEDs:</p>
<pre><code>Current: 100 x 3mA = 300mA or 0.3 Amps
Voltage: About 2 Volts. 
</code></pre>
<p>(Note: When designing with LED you should always refer to that LED's specification.  The above 30mA and 2 Volts is only a guess.)</p>
<p>So, even if your LEDs are of the low current type, you can see a string of 100 such LED in parallel exceeds the initial expected current for the entire string of 100 LEDs.</p>
<p>This assumes the LEDs are in parallel and the power source is a constant voltage.  What if the LEDs are in series?  Then you would need a constant current power source.  Again let's assume the individual LED specifications are 2 Volts and 3 mA.  Now the calculations might look like this:</p>
<pre><code>Current: About 3mA.
Voltage: 100 x 2 Volts = 200 Volts
</code></pre>
<p>Obviously the voltage far exceeds the capability of three 1.5 Volt batteries.</p>
<p>Ah!  <a href="https://www.youtube.com/watch?v=DoRbHYJAwis" rel="nofollow noreferrer">Bigclivedotcom gives us some insight in his 2017 youtube video about repairing several variations of low voltage LED strings</a>. The 3 different strings he uses in his video address how these LED strings can be made such that different voltage and current sources can be used to power them.</p>
<p>In conclusion it is likely your string of LED will require more current to power then a GPIO pin who's maximum current rating is only 40mA can provide safely.</p>
