The reed switch is an electrical switch operated by an applied magnetic field. It consists of a pair of contacts on ferrous metal reeds in a hermetically sealed glass envelope. The contacts may be normally open, closing when a magnetic field is present, or normally closed and opening when a magnetic field is applied. The switch may be actuated by a coil, making a reed relay,or by bringing a magnet near to the switch. Once the magnet is pulled away from the switch, the reed switch will go back to its original position.
An example of a reed switch’s application is to detect the opening of a door, when used as a proximity switch for a burglar alarm.
Here is a module that is part of a sensor kit which is sold for use with the Arduino
In this case we have a schematic of the module, so if you wanted to build your own one, you would need the parts in the schematic below
Connection
This is for the module above
A0 -> Not used in this example
G -> Wemos Mini Gnd
+ -> Wemos Mini 3v3
D0 -> Wemos Mini D8 (you could use an digital pin)
Code
Very basic example, when the reed switch is open Wemos Mini pin 8 will be low (0). Place a magnet near the reed switch and it should close which is a high and pin 8 will be high (1)
If you open the serial monitor you will see this
[codesyntax lang=”cpp”]
const int digital = D8; void setup() { pinMode(digital, INPUT); Serial.begin(9600); } void loop() { Serial.println(digitalRead(digital)); delay(1000); }
[/codesyntax]
Links
Under $1 for one of these modules, so again won’t hurt the wallet too much
AliExpress.com Product – Reed switch Module for Arduino UNO
What is the purpose of VR1, please?
This appears to be a universal board meant for optical sensors – with a reed switch in place of the phototransistor.
The pot looks like it’s set up as a voltage divider in order to set the voltage level at which the phototransistor trips the comparator (+) leg, thus setting the optical sensitivity.
The 10K input resistor in series with the phototransistor makes the other voltage divider for the (-) leg.
The capacitor in the feedback loop (-) damps any noise on the input leg. This will probably debounce the reed switch just fine.
With the right thermistor, this could work as a temp switch as well.