I am right at the beginning of learning electronics and definitely at the beginning of connecting circuits to a Pi. Here's what I'm trying to work out. I have an alarm circuit running at 9v with it's own ground. When the alarm is triggered an led lights up. I've taken pin outs from this led so I have a 9v and ground. What I'm trying to do is sense this "9v" using a GPIO IN pin on the rasp pi. I have a voltage divider to convert this 9v into anything less than 3.3v for the GPIO pin (using a potentiometer). If I measure the voltage from the divider to the alarm ground I get 0v/3.3v when the alarm has not/has gone off, but if I measure from the divider to the Pi ground when the alarm has not been activated I get a fluctuating voltage between -0.013v and +0.013v (more or less). This then gives false positives on the Pi.
I could solve the problem with a relay with the alarm controlling the relay and a simple PI button sense circuit. But from my limited understanding keeping a relay open for hours might not be great, i.e. when the alarm goes off it could be hours before it is reset.
So I thought, with my very limited knowledge that an NPN transistor might work as a switch. So I tried feeding the Pi 3.3v into the collector via a resistor, grounding the emitter to the Pi and having the alarm feed the base with something, e.g. > 0.6v (2N222 transistor). Then I tried connecting the GPIO sense pin to either the collector (after the resistor) or the emitter.
Trouble is I can't get it to work. Is it possible? If so what am I missing please?