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 ?
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: