RalfyM
Posts: 5
Joined: Sun Jan 14, 2018 12:28 pm

Alarm voltage detection

Sun May 20, 2018 11:14 am

Hello,
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?

Regards

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: Alarm voltage detection

Sun May 20, 2018 11:49 am

Hi ralfyM,

Did you connect the alarm gnd and pi gnd together?
I should use an optocoupler. Google for examples.
Success with your project!
Ferdinand

RalfyM
Posts: 5
Joined: Sun Jan 14, 2018 12:28 pm

Re: Alarm voltage detection

Sun May 20, 2018 12:41 pm

OK, that's cool. I haven't yet come across optocouplers yet, and the fact you can make your own is even better. I'll give that a go since I have the parts.

Moe
Posts: 230
Joined: Sun Jan 25, 2015 2:44 pm

Re: Alarm voltage detection

Sun May 20, 2018 8:12 pm

It sounds like you're trying to measure a voltage that is not referenced to the measuring device. You need to connect the grounds together.

An optocoupler will do it but unless there is a specific reason the alarm circuit needs to 'float', then it's a very roundabout and complicated way of doing something very simple.
Submarine communication systems engineer and amateur robot enthusiast.

RalfyM
Posts: 5
Joined: Sun Jan 14, 2018 12:28 pm

Re: Alarm voltage detection

Mon May 21, 2018 8:42 am

This is where my current lack of understanding comes in. I wasn't sure if it was safe to connect the ground from the Pi with the ground from the alarm given I was seeing a fluctuating voltage. I thought it would be safe but I wasn't 100% sure.

I like the idea of the optocoupler simply because it gives me something else to play around with. Especially since eventually I'll need this for the other automation ideas I want to implement.

Thanks for the advice peeps.

Moe
Posts: 230
Joined: Sun Jan 25, 2015 2:44 pm

Re: Alarm voltage detection

Mon May 21, 2018 11:51 pm

Voltage is the potential difference between two points in the same circuit/system, so you weren't measuring a fluctuating 'voltage' as such, just witnessing the meter's attempts to interpret the electrical potential of two isolated systems floating relative to each other. By connecting the meter (which has a very high but finite impedance) you were creating a connection and affecting the result.

Think of it as trying to measure the length of a stick by comparing one end of it with the other end of another stick, when you have no idea how far away the other stick is. Except in this case, the act of measurement will tend to reduce the distance between the sticks by an amount that is also unknown. Basically, the results are meaningless. You need to fix the two sticks together.

OK, rubbish analogy :( sorry
Submarine communication systems engineer and amateur robot enthusiast.

User avatar
rpdom
Posts: 12648
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: Alarm voltage detection

Tue May 22, 2018 5:42 am

Moe wrote:
Mon May 21, 2018 11:51 pm
OK, rubbish analogy :( sorry
Actually, I quite liked it. It has potential. ;-)

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 11 guests