Replacing reed switch function with an arduino signal?

I'm trying to modify a door sensor that is connected to my alarm system to be triggerable by an arduino.
It works with a reed switch currently, that is easy to remove and fit wit wires.
I'm not savvy enough to know what circuit I need to build to make it work,
so i'm hoping someone can help.

I presume I will need to use a relay, but im not sure what I need to make it happen.
The only relays im familiar with are the large mechanical ones.
Are they overkill for this?

Does anyone know how to close/open a separate low power 3.3v DC circuit,
simply by sending HIGH/LOW over an arduino pin?

You don't need to repkace it!
Just tie one end to GND with a 10k resistor and connect the resistor to a digital input and test for a logic low.
Use this:

I think I didn’t explain it well enough.

I want to turn a reed switch door sensor into an alarm that my arduino can trigger.
So Instead of a magnet closing the circuit, I need arduino to close the circuit.

Like this, except arduino controlling it instead of a water sensor.

You need a relay or opto sensor. If you use an opto sensor ,then the two pads the reed switch was connected to would be connected to a pullup resistor, (1k to 4.7k) which connects to the collector of the
phototransistor in the opto coupler and the emitter of the transistor goes to the second pad the reed switch was connected to:
Like this:
reed switch pad-1 =>resistor=>collector (opto) emitter=>reed switch pad-2

Now, when you turn on the led in the opto (don't forget the current limiting resistor!) the transistor will
turn on connecting pad-1 to pad-2.

alternately, you can use a small 5V relay to connect the two pads.

Wow, that is a simple and compact solution, thanks!
It didn’t even cross my mind that they were in fact tiny relays.

Would this one do the trick?
It says it needs max 1.2v 50mAh to trigger, so if I stuck a 82Ω resistor on signal that should do the trick?
And then jumping the reed switch gap with a 4.7k resistor on the collector side and presto?

You should determine the current flowing through the
reed switch: Is is AC or DC? Is the magnitude like 1 mA
or 10 mA? The switch is likely N.O. held closed by
the magnet.

The unit is powered by a 3.3v button cell normally, so I would assume it's not a whole lot. :wink:
The collector on that opto can take 70v 50mA, id be impressed if the button cell exceeds it.

The unit sends out an alert signal both when it opens and when it closes, so either way would work I think.

As a sidebar; Instead of the buttoncell, would I be able to just pull 3.3v off the mega?
I know it has a 3.3v output on it, but I think it can only provide 50mA?

I don't think you understand what "max" means.
It means the ABSOLUTE MAXIMUM current it can tolerate before frying.
Obviously, it is not common practice to operate at maximum ratings.
Just the opposite. You only need 20 or so mA to turn on the led.
A 220 ohm resistor will work just fine. The very lowest value resistor
you should use for the led current limiting resistor is 180 ohms but don't
try that until you've tried 220 ohms.
I can't tell if you understood what I said.
I specifically said to connect a 4.7k resistor from reed switch pad1 to the collector.
Then connect the emitter to pad2.
Current will flow from pad1 to resistor to collector through the transistor and out the emitter to pad2.
I do not know how much current the circuit needs through the reed switch circuit so it may be
necessary to reduce the 4.7k resistor to 3.3k or 2.2k or 1k.

The voltage drop across the 4.7k resistor devided by 4700 is the current flowing through the transistor(in A).
0.001A = 1mA
A 1k resistor would increase that current to 5mA.
We don't know how much current that circuit needs so you should start at 1 mA and increase it
incrementally until it detects the closed switch.
You shouldn't need to go below 1k.

You need to find out the polarity across the reed switch before you remove it.
This can be done by removing it from the magnet, causing it to open up.
Then put a meter across it to find out WHICH end is POSITIVE.
You can't do this if both pads are shorted by the relay, so either remove the magnet or remove
the relay and find out which pad is more positive.
Call that PAD1.
Call the less positive pad PAD2.
Then the wiring we discussed should work.
If you fail to ascertain polarity first and connect the transistor backwards it won't work.
Another solution would be a small 5V relay but then you would need to run the relay input wires to
the arduino and the relay would need 5V power so that might be more work.

The collector on that opto can take 70v 50mA

Where does it say that ?
There is absolutely NO connection between the 70V and the 50mA, because the 70V is when it is
OFF and the 50mA is when it is ON. Your statement makes as much sense as saying "sunglasses
work best at night "

You need to learn more about electronics before you start making assumptions based on what you
see on a datasheet.
If you looked at the collector power dissipation it is 150mw , or 0.150W.
If you divide that by the collector max current of 50mA(0.050A) you get 3V, NOT 70v !.
The 70V is the max collector-emitter voltage, which is the voltage when the transistor is OFF.
Obviously, when the transistor turns ON, the collector and emitter are SHORTED so there is no
way there is going to be 70V across the collector emitter with 50mA going through it.
(because that would be 4.9W not 150mW !)
It could be 70V when there is NO current going through it.(but that would only occur if you
were operating at maximum operating voltage, which, simply put , would be stupid)
P = IV
0.150W = 0.050A
V => V = 0.150W/0.050A
V = 3V (max collector-emitter voltage drop when On)

The dead giveaway that you have no electronics training is that you suggested operating the
optocoupler at maximum operating current using an 82 ohm resistor.
You might as well scream "I HAVE NO F*CKING IDEA WHAT I'M DOING !"
Start by studying Ohm's Law, then learn to read ALL of the datasheet, instead of just one or
two things in it.

Aha, I was wondering what kind of current that opto needed.
Usually with LEDs they clearly state prefered operating current.
With a 82 ohm resistor it would drop it to 40mA or something,
but if you say prefered current is 10mA then 220ohm makes more sense indeed.
I'll determine which end is positive and then put a resistor on that side.
Unfortunately my current sensing multimeter has broken down, and I only have a dinky backup one.
Luckily I do have a whole slew of common resistors to try, Is there a safe bet value I could start with?

Actually, forget it, no need to get so freaking hostile, bud.
I'm just here trying to learn by doing, because I don't have the time to pick it up as a profession.
If I had a degree in electronics of any kind, I wouldn't be here being screamed at by you.
So if you have a problem helping a hobbyist beginner, just sod off?

I didn't scream at you , 'bud'.
You asked questions , which I answered.
It was only when you started making statements
that were totally wrong that I corrected you,
(which, I am obligated to do).
If you don't want embarass yourself don't
make ignorant statements after briefly
glancing at a datasheet.
You could have have simply asked :
"what does the 70V and 50mA mean ?"
But no, you saw some numbers and jumped to
conclusions. If you post nonsense on the forum
someone is going to call you on it.
Telling you that saying that stuff makes you
look like an idiot should encourage you to
do more research or ask more questions instead
of drawing conclusions based on zero experience.
You should reply:
"thank you for sharing. You have opened my eyes.
But instead you get angry (there was no hostility
in my post. In the contrary, I would call it
technician humor.
If you want to learn, check your ego at the door.
Did I answer all your questions ?

Your tone and manner of speech comes across as extremely unfriendly, in both of my topics now.
If anything, it is discouraging, and extremely disheartening to a beginner to be chewed out like that.
I dont claim to have perfect knowledge of everything, but..

You might as well scream "I HAVE NO F*CKING IDEA WHAT I'M DOING !"

..really? ::slight_smile:

I looked at the datasheet and tried to gleam information to the best of my ability,
being wrong doesn't give you free reign to just belittle me like a child.

I came here to learn, not to be scolded at for making a mistake.

Sorry to offend you. Actually I was trying to
tell you that making uninformed statements reveals
a lack of experience so you don't embarass yourself in the future. Perhaps I was bit harsh.
Hopefully it will encourage you to do your due
dilligence in the future, it least ask questions beforemaking statements. Trust me when I say
techs are even harder on other. techs

I think you FAILed which means Forward Action In Life! At a minimum you learned something did not work. How many tries did Edison have before he had a working light bulb. It took 40 tries to develop WD40. I have been in the electronics industry since the late 60's; I never met anybody who never made a mistake. I have made a lot of them that is how I learned. Yes I am an old timer, when I got into the industry there was no solid state so I had to teach it to myself. If they state they didn't make any mistakes they are spewing terminological inexactitudes! Just a note everybody has to learn, they were not born with the knowledge and realize they are not always right.

Simple solution (there are a lot of possible solutions) is disconnect the switch and place an ohmmeter across the leads, cycle it and you will know. In my home we have both NC and NO so best measure it to be sure and design so you do not get a false alarm if the arduino power fails. For a start use a relay output ( the "large one" to get it working; you will be safe if it either AC or DC. If it is NC you connect the the relay NC contact in series with the switch, if it is NO connect the relay across it, using the same configuration the switch is. If you use an optocoupler drive it with from 50% to about 80% of its maximum rating if a typical is not given. This current determines the transfer characteristics. For a start use a relay output and you will be safe if either AC or DC.
Good Luck, & Have Fun!

Sorry to offend you. Actually I was trying to
tell you that making uninformed statements reveals
a lack of experience so you don't embarass yourself in the future. Perhaps I was bit harsh.
Hopefully it will encourage you to do your due
dilligence in the future, it least ask questions beforemaking statements. Trust me when I say
techs are even harder on other. techs

Making a mistake isn't embarrassing, not learning from them is.
I'll try and be more inquisitive instead of just asserting what I assume to be correct.
Sorry for the clash, I misconstrued your intent.

Just for the record, im familiar with rudimentary electronics, including ohms law; I used to build my own multicopters by flashing DILs and later using arduino pro micro. Reverse engineering a reed switch and replacing it with an optocoupler is a bit of a different bag all together from what i'm used to though.

So to get back on track;
I must first discover positive and negative side, and then use a resistor to match (or get close enough to) the reed switches original resistance, is that correct? Could I establish polarity by simply desoldering one end of the reed switch and then measuring voltage across both pads? And then, after determining polarity, desolder the reed entirely, and measuring its resistance?

We don't care about the reed switch.
It's the circuit that detects it that concerns
us because you don't have the schematic.
If the reed switch is used to change a logic
low to a logic high by disconnecting a pull
down resistor ( or the opposite ) then the
circuit the reed switch was in series with
requires less than 1 mA and the 4.7k
resistor will work.If you were replacing a relay
with a relay then we wouldn't care abut
polarity. The quickest way to establish
polarity is to remove the reed switch
and measure the voltage . The side closest
to the red meter lead when the voltage
is positive on the meter is the positive
side so if the meter reading is negative
when you put the leads across the
reed relay pads then swap the leads
to get a positive meter reading and
then look at the pad touching the
red kead. That is the POSITIVE (I'm
screaming) pad. That's the pad the
collector pullup resistor goes to.
The pad touching the black meter
lead is the pad the emitter goes to.
resistor goes to .
"Live long and prosper..."
"Goodbye and good luck !"
(sorry for being such a dick)

Thank you for being thorough (and clarifying when you are, in fact, yelling).

I've removed the reed switch, and found which side is positive; exactly +1.000V
So a 4.7k ohm resistor should limit it to a 2.1mA current, is that what is desired?
I've tested it briefly by jumping the pads with a 4.7K resistor and it seemed to function.

Finding the correct optocoupler the next challenge.
If im reading the datasheet correctly (big if), it needs 1.2v 20mA to activate, so if I stuck a 190 ohm resistor on the mega output pin, that would do the trick I think?

Thank you for being thorough (and clarifying when you are, in fact, yelling).

I was joking when I said POSITIVE (screaming).

Pin 1 is the Anode
pin 2 is the cathode

arduino digital output pin=>190 ohm resistor=>pin 1
GND=>pin 2.

Voltage drop across resistor gives led current VF = 190*I | VF= Forward Voltage

VF is given as 1.2V typical so 5V-1.2V =3.8V (voltage drop across 190 ohm resistor)

Led current (ILED should be 20mA with 190 ohm resistor

= (5V-VF)/R
= (5V-1.2V)/190
=3.8V/190 ohms
= 0.020 A
ILED= 20mA

Do you understand the meaning of VF ?

If not, you might want to read this
(pay attention to the difference in VF for different colors.
You need to know this to calculate the current limiting resistor for the led.
If you tried to use a white led with the same 190 ohm resistor instead of a 50 ohm resistor you would
only get 5mA instead of 20mA.
Also the CTR (Current Transfer Ratio (usually given as hfe for ordinary transistors) is
the ratio of led current to transistor current.
For ordinary transistor the ffe is give as an integer , not a percent. so 50 means the
collector current is 50 times the base current.
The CTR for optos is given as a percentage, not an integer, so
A CTF of 100% means that 20mA through the led yields 20mA through the transistor.
You need to keep that in mind . Don’t just look at the value, look at the "units " column too.
In your case you only need 2mA through the collector so if you put 4mA through the led you
would get AT LEAST 50% of that through the collector because the CTF (min) is 50%.