# Magnetic Contact Sensor + Boron

**URL:** <https://community.particle.io/t/magnetic-contact-sensor-boron/57709>\
**Category:** Getting Started\
**Created:** [September 10, 2020, 4:50pm UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709 "2020-09-10T16:50:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oraclerouter](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/oraclerouter/32/30494_2.png) [@oraclerouter](https://community.particle.io/u/oraclerouter)\
**Post date:** [September 10, 2020, 4:50pm UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709/1 "2020-09-10T16:50:46Z")

</div>

Not sure if this is the right place to ask this question but just thought I would start here.

How many magnetic contact sensors potentially I can have connected to a single digitalPin on the Boron?  
I’m not looking to monitor the individual sensors I just need to know if when any of them are triggered.

I have one end connected to GND and the other to PIN4. Aside from cable lengths, what are the other variables that may affect the number of sensors on a single pin?

---

<div class="post-metadata">

**Author:** ![dreamER](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dreamer/32/26550_2.png) [@dreamER](https://community.particle.io/u/dreamER)\
**Post date:** [September 12, 2020, 8:31pm UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709/2 "2020-09-12T20:31:12Z")

</div>

Hi,  
What do you mean by “magnetic contact sensor” ? , reed switch ?  
you can have ∞ value of reed switches connected to 1 digital pin, all of them will be connected in parallel to each other and you can get status of just one of them. Make sure that if you connect one end of them to GND you will use pull-up in setup eg:

```auto
int reed_sw = D4; // reed switch is connected to D4

void setup()
{
  pinMode(reed_sw, INPUT_PULLUP); // sets pin as input with internal pull-up resistor
}

```

[ref](https://docs.particle.io/reference/device-os/firmware/photon/#pinmode-)

Hope this help,  
Best regards

---

<div class="post-metadata">

**Author:** ![oraclerouter](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/oraclerouter/32/30494_2.png) [@oraclerouter](https://community.particle.io/u/oraclerouter)\
**Post date:** [September 13, 2020, 1:07am UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709/3 "2020-09-13T01:07:36Z")

</div>

Thanks @dreamER. Is cable length something I have to worry about in this case?

---

<div class="post-metadata">

**Author:** ![dreamER](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dreamer/32/26550_2.png) [@dreamER](https://community.particle.io/u/dreamER)\
**Post date:** [September 14, 2020, 5:38pm UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709/4 "2020-09-14T17:38:22Z")

</div>

Hi,  
Yup you are absolutely right wire length and fact that is just 3.3V (Boron GPIO are not 5V tolerant !!!) can be a little headache.  
I’ll use optocoupler in this circuit and try ( personalty I’m not sure if this boosters work but is worth to try for $8 🙂 ) DC/DC booster  
to pull up a little (eg: to 12V) the voltage for reed switches. I’know this is Boron project and probably you would like to save energy  
consumption as much as possible, but you will use booster just to power up the LED inside the optocoupler which shouldn’t consume too much energy (just couple mA). Thanks to the higher voltage, even if you gonna get some voltage droop, on long wires the circuit should be still stable and work fine. Also the optocoupler will provide you safe separation between your boron and reed switches.  
here is some theory about optocouplers:

[https://www.electronics-tutorials.ws/blog/optocoupler.html](https://www.electronics-tutorials.ws/blog/optocoupler.html)

and here is the DC/DC booster which can do the job:

> **[Yeeco DC Boost Converter Step Up Voltage Converter Module DC-DC 2-24V to 5-28V...](https://www.amazon.ca/Yeeco-Converter-Regulator-Stabilizer-Adjustable/dp/B011EBSKK0)**
>
> Yeeco DC Boost Converter Step Up Voltage Converter Module DC-DC 2-24V to 5-28V 1A Voltage Regulator Booster Module Adjustable Voltage Step Up Power Supply Module: Amazon.ca: Tools & Home Improvement

Also if you don’t want to over complicate the things and you have direct 12V DC available regarding to this [post](https://community.particle.io/t/powering-boron-using-12v/46838/12) you can power the Boron on VUSB pin directly from 12V and then use the same power supply for reed switches and optocoupler circuit.

Here is some drawing :

 ![opto](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/b/8/b83e35f565b988832ea5915f23eb27eb2d5ae136.gif)

Hope this help.  
Best regards

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/6/4/64635adccc35238caa19e9b553ec3e98b163d026.png) [@system](https://community.particle.io/u/system)\
**Post date:** [March 16, 2021, 5:38am UTC](https://community.particle.io/t/magnetic-contact-sensor-boron/57709/5 "2021-03-16T05:38:36Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
