Long post, I tried to do the research but want to be sure.
So here we go. I have my esp8266 with an 2n2222 transistor and my 12v LEDs.
I would like to use the 2n2222 as a switch. Looking at the datasheet (included in attachment below)of the 2n2222 this 12v is within range, also the 0.4 amps the LEDs are using is in range. [EDIT]: Not 0.4A but 0.04A, see further posts below.[EDIT]
So this is how I hooked everything up.
[Q1] Is this all good?
If it is, all that rest now is to calculate R1
Using this guide here [ ] link to guide [ ] I think I understand how this goes.
Datasheet 2n2222
My idea of this, looking at the datasheet, saturation at collector current of 150mA / base current at 15mA right?
So, if my collector current will be 400mA (actual mesearments of the LEDs) the base current must be 40mA?
[Q2] Still on the right track?
If so we go on. Looking at the schematics again, at collector current of 500mA the base emitter voltage must be between 0.6 and 2.6. My collector current will be ~400mA. So to be safe let's say I want a base emitter voltage between 0.6 and 1.2.
[Q3] Still good?
Let's hope so, I go on with calculating the value of R1. GPIO2 output is 3.3v. I want a voltage drop if at least 2.1v (3.3v minus the maximum base emitter voltage of 1.2v) and a drop of max 2.7v (3.3v minus the minimum base emitter voltage of 0.6v)
So with ohms law we can calculate that. Max output on the esp8266 pin is 12mA.
For 2.1v drop we need 150ohm
For 2.7v drop we need 192ohm
So, R1 needs to be between 150 and 192ohm!
[Q4] Nothing blown up yet?
I hope you guys can help me out here. I broke it all up in the steps I took, trying to explain how I did everything. Hoping that it will be easier to find errors.