I have a circuit running on 12v 8mA and I want to get a signal to a GPIO of an esp8266 when current is running. So for that I tried to use a 2N2222 transistor with vcc of the circuit going to the base and vcc and gpio of the esp connected to collector and emitter. Unfortunately it seems current is not high enough to trigger the transistor. How I can proceed to make it work ?
closed as unclear what you're asking by Elliot Alderson, TonyM, Brian Carlton, Steve G, Finbarr Oct 16 at 15:34
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Ouch. It sounds like you may have fried the input pin of the ESP8266 by applying 12V to it through the BE junction of the 2N2222. If not, you were saved by the fact that the current is limited to 8 mA.
Anyway, your question is ambiguous, so I'll give two answers.
If you just want to sense the presence of +12V, a single transistor and a couple of resistors will suffice:
On the other hand, if you want to sense whether a load is drawing 8 mA of current from your 12 V source, you'll need a second transistor: