Putting several sensors on the same input

Hi

I am currently creating an alarm system.

I know that the best practice would make me assign every sensor to a dedicated pin, and this would also let me know which sensor is triggered, but when it comes to cost killing, is it a good idea to put something like 10 magnetic door opening sensors on one pin (maybe with diodes to prevent signal from going into other sensors) ?

Don't stone me :o .

Thanks

Google "Arduino port expander".
Leo..

For multiple switches on one input there is this technique for using one analog input for multiple switches.

It's not very important to be able to identify each sensor.

I may wire them in parallel or in series with NC (closed when magnetic field is there) and detect voltage change.

Thanks for the help

JeanneD4RK:
It's not very important to be able to identify each sensor.

I may wire them in parallel or in series with NC (closed when magnetic field is there) and detect voltage change.

Thanks for the help

The purely on/off conditions of the series approach should be more reliable, and less prone to false triggers. Parallel wiring will not have a "full swing" response for a single switch. You could use that effect though, to determine how many of the switches are open, for example.

JeanneD4RK:
It's not very important to be able to identify each sensor.

Well, I didn't see this until after I put in the work to give a comprehensive answer to this, so for others who might "tune in" later, here goes.
First, I agree with ChrisTenone: serial is probably more reliable.

Here's the most basic system:


Just simple switches with no tamper detection. 5V at the Analog Input means, all is armed and well. 0V means a violation of the perimeter!

To defeat this, all a potential burglar has to do is short across one or more switches [i.e. *tamper with the switch*] and the premises can be entered from that protal [e.g. door, window, etc], without tripping the alarm. This could be done during "business hours" when the system is not armed, and when the "store" is open to the public.

To add tamper detection, resistors are added:

Notice how, with one of the Switch Assemblies shorted out, the voltage at the Analog Input is 2.58V, instead of 2.08V. When the Arduino script sees this, it can know that one of the switch assemblies was tampered with, and this can be presented to the User [i.e. the owner of the alarm system]. The typical algorithm would inform the User that the Alarm can't be set, because of tampering. The User would, then, walk the "perimeter" and try to find where the tampering occured, and remove it. Also, [not shown here], when one of the switches opens [perimeter violation], the voltage at the Analog Input goes to 0.

If this is a large facility, then the usual strategy is to divide the area into zones. If only one switch is used on each zone, then it's a simple matter to locate the tampering. But, if the Alarm Box has limited zones, and more zones are needed than the box can provide, then more than one switch can be used, in the manner shown, above -- in other words, what is shown in the schematics, above, is one zone, with three protected entities.

There is something called zone multiplication, which basically allows one zone to be multiplied into more than one zone. What that really means is, one set of terminals on the Alarm Box, can, by using this technique, be converted into more than one zone [if the box has this feature]. But, since we are the designers of the "box" we get to do this ourselves. And, here's how:

The different resistor values for R4, R5 & R6, result in different voltage levels, at the box, for different sub-Zone violations [a sub-Zone, in this case, are the zones that are created by zone multiplication [typically zone doubling, or zone tripling, etc.].

Notice how the voltage at the Analog Input is 4.13V when the system is armed, and there are no faults [i.e. all switches closed, and no tampering]. Watch what happens as the different sub-Zones are violated:

And, the voltage when one of the sub-Zones is tampered with:

By watching for these different voltages, you can interpret what is happening on the loop.

  • 2.98V [or analogRead = 609] means sub-Zone 1 was violated [i.e. a door was opened, a window opened, or a window was broken, etc.]
  • 2.61V [or analogRead = 534] means sub-Zone 2 was violated
  • 2.26V [or analogRead = 462] means sub-Zone 3 was violated
  • 4.38V [or analogRead = 896] means sub-Zone 2 was tampered with
  • 4.13V [or analogRead = 844] means No Faults (everything's hunky-dory)

So, because we can tell which switch was opened [by a perimeter violation], this can be considered a zone because we know which switch it was [zones are all about being able to locate the activity].

And, in reality it is wise to allow for noise and resistor tolerance [probably best to use 1% resistors]. You can do this by watching a voltage range, making sure the range doesn't overlap one of the other voltage ranges. For instance, instead of just watching for 4.38V -- instead, watch for the range 4.28 to 4.4V [875 to 900].

Here's a schematic showing a full system with input protection:

A note about the switch assemblies: I never understood the practice of having the the Reed Switch terminals exposed! This, it seems to me, defeats the purpose of the tamper sensing resistors. All the potential burglar needs to do is place a short across the switch terminals, and the whole tamper sensing system is defeated!! These resistors really need to be inside a box that can't be easily opened -- like a potted "brick". If I were to actually build this thing, I would use epoxy putty to encase the resistors--just putty them to the side of the reed switch that the terminals are on, covering those terminals in the process. Two wires would extend out of the epoxy, and those wires would, then, be wire-nutted to the feed line that connects it to the other switches, and/or to the Alarm Box.

@ReverseEMF thank you for in detail explanation. It helped me a lot to understand the concept. But also arises this question in my mind, let's say we have 50 of these reed switches. with zone in mind it is not a big deal by grouping them into 5-10 zones. but then how we can identify which reed is triggered. yes we know zone 1 is violated, but which switch?

You mentioned at some point something called zone multiplication or zone doubling. I think that's what I am actually looking for. Do you mind to explain that a little more. All the examples I see online are max 3 reed switches on different ports. this is the best so far that can be extended multiple zones. but I don't think treating each switch as a zone for 50 switches reasonable. the reading ranges will be very close in that case I believe.

but then how we can identify which reed is triggered. yes we know zone 1 is violated, but which switch?

If you want to know the individual switch then you need an input for each switch or a resistor ladder feeding into an analogue input.

Sorry for being really uneducated and noob in this case. I am a programmer for many years and never really had a chance to sit and study electronics, I should have. From my question above, would this schema makes sense. I probably have bunch of mistakes but overall, I want to connect 26 ( made 30 for expansion ) reed diodes all around the house from old non-working burglar alarm system to arduino. Initially I thought it made more sense to collect them all in A1 but then for simplification I thought it is better to assign each zone to an analog port so if two or more zones fault or tempered I can get zones at the same time each gate has problem with. ( also will help to bypass individual gates if necessary rather than entire zone )

Again schema is solely something I put together from above post and resistor latter link. So I am pretty sure many things are wrong. and that's the reason I wanted to post here to find those and correct them. It sounds weird to me that I need 66 resistors.

also is it even possible ( or how it is possible ) to do same thing over single analog port ( maybe adding different unique value resistors at the end of each zone?) so I don't just use entire analog block and maybe spare some for other purposes/sensor readings etc.

R4, R2, R6, R10 and R12 should be different values so you can tell them apart. R1, R3, R5... may not be necessary.

If you are happy with the old zones and don't need to detect which door in the zone is open then you don't need all the resistors.

I was going to counter with the digital port expander already mentioned but then I realized that we are looking for 3 states on each switch (open/closed/tampered) and analog would actually be appropriate.