10 Reed switches - read states

Hey colleagues,

I've a question concerning a setup with reed switches (window / door sensors).

I've read a lot of threads concerning "how to add one read switch to arduino" - but I'd like to read the state of 10 switches (open/close) with help of arduino.
Each sensor does have two cables.

I would like to use 5V ouput with 10kΩ resistance to protect the sensors.
Since I am a beginner, my questions are:

  • do I need 1 electrical resistance per sensor?
  • how would a simple sample technical drawing look like, if I want to get the state of each of the 10 window states?

I have a arduino uno with a breadboard and a lot of cables...

Any help would be highly appreciated.
Thanks in advance
Osral

Most of the Arduinos (all?) have the opportunity to use a built in pullup resistor activated by INPUT_PULLUP. No need for external resistors. The read switch is the connected to GND and to the digital input. Be aware of contact bounces.
The easiest way is to read each digital input one by one. Using "port access" it can be possible reading 8 switches in one go but not all 10.

Put each one on an ESP8266 and set up a basic website or python program to check them out. Then everything is wireless.

Thanks for your replies and help.
@Railroader , I don't have the need to read all 10 sensor states at once. So one per one would work for me. I would use the resistors very close to the sensors, in order to prevent high peaks / side effects of the cables - so I would assume that I need 10 resistors.
Anyhow, it is not clear to me, how to connect 10 read sensors to arduino at once - do you maybe have comparable sample schematics?

@er_name_not_found I also ordered an ESP8266, but would only use the ESP if I am not able to use my wifi capable arduino.

So in short: I am struggeling with the correct schematic, to connect 10 reed sensors to my arduino (e.g. with help of my breadboard).

Regards
Osral

Are all 10 windows in the same room?

The sensors not - but the cables all end in the same room where my arduino is placed. So, there I have 10 (sensors) x 2 (cables each) = 20 cables in total that I try to somehow connect to the arduino.

How long are the cables, and what type of cables are they?
Pictures?

J-YY 4x2x0.8mm^2. Length between 4 and 18 meters.

Have you tired one sensor at each location, to ensure that it will work over that distance?


Example of one of the cables.

I have checked every sensor with a multimeter at the destination - that did work.

No, what I mean is that you may have issues with operating over that distance. Try using one of the guides that you've found to hook your Arduino to a sensor in each location, through the cable, one at a time. So as to be sure that they will work, before moving on.

Ah I am sorry, my bad. Yes I tried it with the sensor with the longest cable like the following
Arduino-reed-switch

That worked as well.

What's the length of the cables? Okey, long cables might do well with external pullups but remember the I/O pin limit of 20 mA.
High peaks? What's the environment? High power machinery?

Add external pullup resistors close to the Arduino. Use a value like 270 Ohm. Maybe You can find inline resistors having 10 resistors and one common, tied to +5.

Good! If any noise seam to bother You You can use lower resistor values than 10k. Lowest value is some 270 - 330 Ohm.

Alright. I understand. But due to my limited knowhow in electrical engineering I am struggeling with a solution (schematic) how I should connect the wires to the breadboard to have all 10 sensors connected.

To OP. In difficult environments a 2 wire shielded cable can be used. Shield connected to GND near the controller... Many times twisted cables give good results.

1 Like

Make one rail having 5 volt from the controller. Then connect the resistors from that rail out to a point where the read switch is connected, and connect that point to the controller input. Repeat 9 times for the other reads.
Sorry but my graphic options are low for the moment.

1 Like

No worries, I really appreciate the help of you guys. I'll try it directly tomorrow - since we currently have mid of the night in my country ;-).

You mean two wires. As one would expect. :grin: A "cable" is a group of wires in one sleeve as you show in #10.

Now, various clarifications:

The resistors do not "protect" the sensors, they provide a reference voltage for the Arduino to compare.

Yes.

As soon as we see long distance wiring, we suspect the internal pull-ups will be insufficient. Think more of 2k2 pullups - a good 2 mA into the switches.

Probably not a major worry. :thinking:

Sorry, dead wrong! The pull-up resistors go nearest the Arduino itself.

You need one resistor per sensor as you cannot connect one resistor to more than one thing and still have them detected separately.

WiFi capable Arduinos are extremely poor value. If you want WiFi, you use an ESP and forget the Arduino entirely.

No, that was confusing "cables" with "wires". The "Cat 5" cable you show has eight wires (four pairs) and a ground. However you wire it, you always keep the two wires from each sensor together in the same cable.

Yes, but wrong. The resistors go to 5 V and the reed switch goes to ground. Taking your 5 V connection out to the reed switch is a very bad idea.

Why? These are only ever going to be inputs. :astonished:

(Except ...)

Really? :face_with_raised_eyebrow:

Actually, while we would not like you to use a "solderless breadboard" for a serious application, that is exactly what the breadboard is for. It has rails running along the top and bottom that allow you to connect multiple sensor wires and multiple resistors to ground and 5 V respectively.

And another clarification. The switch is a reed switch. The Arduino code can read a "pin" status.

See you in the morning. :sunglasses: