How to detect a voltage input high 1.93V and voltage input low 1.25V

Thread Starter

tofulover

Joined Jun 6, 2020
10
Hi, on my equipment, the voltage across 2 ports is 1.93VDC when the equipment is active and the voltage drop to 1.25VDC when it is not. Could I please get a steer as to the best way for me to detect this via the arduino/ESP8266 for output to MQTT? all the guides I have read have a much wider difference between the active and unactive voltage for voltage detection. In my case the difference is only 0.7V or so.

Any ideas and thoughts would be most appreciated.

Thanks
 

LesJones

Joined Jan 8, 2017
4,174
I am not clear what you mean by "voltage across 2 ports " Is this a differential signal and if so what is it's nominal voltage with respect to ground or does the sensing device have to be floating with respect to ground ? (Or do you mean two channels referenced to ground ?)

Les.
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
I am not clear what you mean by "voltage across 2 ports " Is this a differential signal and if so what is it's nominal voltage with respect to ground or does the sensing device have to be floating with respect to ground ? (Or do you mean two channels referenced to ground ?)

Les.
Apologies I should have given more context to my question. The equipment I am referring to are actually PIR sensors that are installed as part of a home alarm system. From the main PCB board of the home alarm system, there are 4 cables to each PIR sensor. 2 of these cables are 12VDC for the power supply of the PIR itself and the other 2 cables are for the normally closed contacts of the PIR. I am mainly interested in the 2 cables for the normally closed contacts.

When the PIR is activated, the contact will be open. when the PIR is not activated, the contact will be closed.

So I measured the voltage at the main PCB board side of the alarm panel across these 2 cables. When the PIR contact is closed (i.e. no detection happening), the voltage I measured is 1.25V to 1.26V thereabout.

When the PIR contact is open (i.e. the PIR detected something), the voltage of these 2 cables become 1.95V thereabout.

What I would like to achieve is to get the PIR activated/not activated signal to be sent to my home automation system via MQTT. I just could not figure out the way to achieve this as the voltage differential between the 2 states above is just 0.7V.

I hope I give a better picture? let me know if I need to clarify more?

Thanks
 

crutschow

Joined Mar 14, 2008
34,285
Use a differential-input comparator (e.g. LM339/393) with a reference voltage about 1.59V to the (-) inputs, with the signals to the positive input.
The outputs are open-collector so need a 10kΩ pullup resistor to the V+ Arduino supply.
What is that supply voltage?

Below is the LTspice simulation of such a circuit for a 5V supply voltage.
The output (yellow trace) goes high when the input voltage (blue trace) is above 1.59V and low when the input is below 1.59V.

1591448393784.png
 

SamR

Joined Mar 19, 2019
5,031
Check out: 7665S CMOS Micropower Over/Under Voltage Detector DIP Chip

Not only detects but has settable alarm outputs.
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
Use a differential-input comparator (e.g. LM339/393) with a reference voltage about 1.59V to the (-) inputs, with the signals to the positive input.
The outputs are open-collector so need a 10kΩ pullup resistor to the V+ Arduino supply.
What is that supply voltage?

Below is the LTspice simulation of such a circuit for a 5V supply voltage.
The output (yellow trace) goes high when the input voltage (blue trace) is above 1.59V and low when the input is below 1.59V.
Thanks crutschow! sounds great with this solution. If i understand this correctly, if the voltage measured is 1.59v and above, it will be seen as a High and anything less will be seen as a Low. is that corrrect?

The supply voltage for the comparator circuits if possible i would like to use 12V just to avoid any other step down circuitry but if this has to be matched with arduino/esp8266 which works only on 5V then i will have to stick to that then.

Supplementary questions: is there a 12V capable ESP8266 that I can use? I read the Wemos D1m actually can take 12V but many sites say otherwise. In addition, is there a Shield that i can get for the comparator circuits you described?

p.s. forgot to mention that i actually have 8 of these PIR circuits that i would like to monitor. So a shield type device would be very handy!

Thanks for your help!
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
I have an idea but not sure if this is at all workable?

I have 8 x circuits to monitor so that means i need something that can process 8 x analogue inputs.

So if I use something like the Arduino Mega should have 14 analogue inputs, and then given that Vil is 0.3 x Vcc = 0.3 x 5V = 1.5V, anything below 1.5V will be treated a a Low. So whilst i can't detect Vih since this is defined to be min 0.6 x VCC which is going to be higher than the 1.9v that i measured on the alarm panel, i may be able to reliably detect Vil.

So if this is the case, then in MQTT i can just detect the low input.

What do you guys think of this approach? is it feasible at all?
 

LesJones

Joined Jan 8, 2017
4,174
If you are using analogue inputs you don't need any level conversion. Just read the ADC input value and compare it with the number that corresponds to a voltage of 1.59 volts is software. My original understanding was that you were using a digital input so wanted a swing between about zero and +5 volts. (Or + 3.3 volts.) All the alarm PIRs I have seen have actual relay contacts as the outputs. Are your's normal alarm type PIRs ?

Les.
 

crutschow

Joined Mar 14, 2008
34,285
The supply voltage for the comparator circuits if possible i would like to use 12V just to avoid any other step down circuitry but if this has to be matched with arduino/esp8266 which works only on 5V then i will have to stick to that then.
Yes, it will run on 12V but the reverence and output resistor networks need to be changed, simulation below.

1591460127357.png
 
If this is just a relay contact on the PIR sensor, you may benefit from a pull up resistor to 5v on one lead and a GND connection on the other. Both of these go on the sensing side. Measure the voltage on the pull up resistor leg to tell if the PIR relay is open or closed.

Otherwise, what is generating the voltage?
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
If you are using analogue inputs you don't need any level conversion. Just read the ADC input value and compare it with the number that corresponds to a voltage of 1.59 volts is software. My original understanding was that you were using a digital input so wanted a swing between about zero and +5 volts. (Or + 3.3 volts.) All the alarm PIRs I have seen have actual relay contacts as the outputs. Are your's normal alarm type PIRs ?
Thanks LesJones. Yes these are normal type alarm PIRs and they do have internal relay contacts but the contacts are within the PIR itself and these contacts are the ones that actually switching the 2 wires at the alarm panel. What you have mentioned is a GREAT idea. Rather than trying to make a distinction using hardware what voltage level is deemed High and what voltage is deemed Low, we could just read the actual voltage level and pass that value via MQTT so that i can pro grammatically determine if the PIR is activated or not by using the voltage. So assuming this is also what you mean, do I just use a voltage divider to connect to the 2 wires of the alarm panel and then feed into something like the Arduino Mega?

Yes, it will run on 12V but the reverence and output resistor networks need to be changed, simulation below.
Thanks crutschow. Good to know that 12V can be used directly if i need to use a comparator circuit.

If this is just a relay contact on the PIR sensor, you may benefit from a pull up resistor to 5v on one lead and a GND connection on the other. Both of these go on the sensing side. Measure the voltage on the pull up resistor leg to tell if the PIR relay is open or closed.
Thanks StayatHomeElectronics. I "think" I know what you mean but (correct me if i am wrong), this essentially require me to install the resistors and wirings at the PIR end, not the alarm panel end? My preference is to install the equipment at the alarm panel end for ease of logistics and troubleshooting.

The Arduino has a built-in comparator module. Can't you use that? Doesn't the ESP8266 have one as well?
Thanks upand_at_them. I actually don't have that kind of intimate knowledge on electronics like the ESP8266 but thanks for that, I will read that up.
 

LesJones

Joined Jan 8, 2017
4,174
I was initially thinking that one side of the PIR contacts was connected to logic ground on the alarm panel. There is a good chance that this is NOT the case. This is how the input circuit on my alarm panel is designed. One side of the alarm contact goes to +5 volts via a 10K resistor. The other side goes to a 100K pull down resistor to logic ground. It also goes via a 1 meg ohm resistor to the input of a Schmitt trigger input gate. (CD4093). Are you attempting to measure the voltage with respect to logic ground of ONE of the two input connections to the PIR or are you attempting to measure the voltage between the two connections to the PIR contacts ? It would be helpful if you could post voltage readings with respect to logic ground to both connections to a PIR both with the PIR contacts closed (Not activated.) and open (Activated.) (Or trace out the schematic of the input circuit of one input channel of your alarm panel.) (All channels will probably be the same.))

Les.
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
I was initially thinking that one side of the PIR contacts was connected to logic ground on the alarm panel. There is a good chance that this is NOT the case. This is how the input circuit on my alarm panel is designed. One side of the alarm contact goes to +5 volts via a 10K resistor. The other side goes to a 100K pull down resistor to logic ground. It also goes via a 1 meg ohm resistor to the input of a Schmitt trigger input gate. (CD4093). Are you attempting to measure the voltage with respect to logic ground of ONE of the two input connections to the PIR or are you attempting to measure the voltage between the two connections to the PIR contacts ? It would be helpful if you could post voltage readings with respect to logic ground to both connections to a PIR both with the PIR contacts closed (Not activated.) and open (Activated.) (Or trace out the schematic of the input circuit of one input channel of your alarm panel.) (All channels will probably be the same.))
This is how the PIRs are being wired. Each PIR has 4 wires back to the alarm panel. wire #1 and #2 are 12VDC and Ground.

Wire #3 goes to a zone terminal (say zone 1 for discussion purposes). Wire #4 goes to a "common" terminal which is essential the at the same voltage reference as wire #2. The other PIRs will go to zone 2, zone 3, etc.

I use a voltmeter to measure across wire #3 terminal and wire #4 terminal.

When the PIR is active, this voltage reads 1.95V thereabout.
When the PIR is not active, this voltage reads 1.25V thereabout.

The alarm panels has no 5V supply anywhere (it is essentially a 12V panel with a 12V sealed lead acid battery). The circuit board may have internal resistors but it is not a resistor that i can "unplug" if u know what i mean.

What are your thoughts?
 

LesJones

Joined Jan 8, 2017
4,174
From what you say it looks like one side of the inputs to the panel is at ground level which makes reading the voltage easier.
If I was doing what you are trying to do I would use comparator ICs (As crutschow suggested.) connected to inputs on the Arduino configured as digital rather than analogue.

Les.
 

Thread Starter

tofulover

Joined Jun 6, 2020
10
From what you say it looks like one side of the inputs to the panel is at ground level which makes reading the voltage easier.
If I was doing what you are trying to do I would use comparator ICs (As crutschow suggested.) connected to inputs on the Arduino configured as digital rather than analogue.
Is there a tutorial/guide that you can point me to achieving this? I will go read up.
 

peterdeco

Joined Oct 8, 2019
484
I haven't read every post in this thread but referring to your 1st post, I am doing something very similar with a battery charging circuit. I use an 8 pin PIC microcontroller with an ADC input to monitor small changes in voltage. It is powered with 3.3V. If the ADC is configured as a byte variable with 256 steps, each step is 3.3/256 = .012V (approx). If configured as a word variable with 1024 steps, each step is 3.3/1024 = .003V (approx). Either one should have an ample amount of difference for the ADC to detect an off or on condition.
 

LesJones

Joined Jan 8, 2017
4,174
In post #10 crutschow has given you the schematic to interface your + 1,25 to 1,95 voltage transition to a zero to +4.5 volt signal for the digital input on the Arduino. (Assuming a 5 volt version of the Arduino.) If you are using a 3.3 volt version of the Arduino then just adjust the resitor values on the output of the comparator. If you use the LM339 then you will need two of them for your eight channels as each one contains four comparators. If you don't want to build the interface then using analogue inputs will work. What peterdeco says in post #10 about PICs applies just the same to Atmel chips used in the Arduinos.

Les.
 
Top