Home ยป KY-021 Mini Reed Switch Module Raspberry Pi example

KY-021 Mini Reed Switch Module Raspberry Pi example

by shedboy71

In this example we take a look at the KY-021 Mini Reed Switch Module and connect this to a Raspberry Pi.

Lets speak about the reed switch – from wikipedia

Reed Switch Information

The reed switch contains a pair (or more) of magnetizable, flexible, metal reeds whose end portions are separated by a small gap when the switch is open. The reeds are hermetically sealed in opposite ends of a tubular glass envelope.

A magnetic field (from an electromagnet or a permanent magnet) will cause the reeds to attract each other, thus completing an electrical circuit. The spring force of the reeds causes them to separate, and open the circuit, when the magnetic field ceases. Another configuration contains a non-ferromagnetic normally-closed contact that opens when the ferromagnetic normally-open contact closes.

A thin layer of non-ferromagnetic material is applied to the reed switch contact area to serve as an electrical contact switching (wear) surface and, for normally-open contacts, as a magnetic spacer whose thickness is important in controlling the magnetic field level at which the contact opens (the drop-out).

Reed switch contacts are typically Rh, Ru, Ir, or W. There are also versions of reed switches with mercury “wetted” contacts. Such switches must be mounted in a particular orientation. Otherwise drops of mercury may bridge the contacts even when not activated.

Since the contacts of the reed switch are sealed away from the atmosphere, they are protected against atmospheric corrosion. The hermetic sealing of a reed switch make them suitable for use in explosive atmospheres where tiny sparks from conventional switches would constitute a hazard.

One important quality of the switch is its sensitivity, the amount of magnetic field necessary to actuate it. Sensitivity is measured in units of Ampere-turns (AT), corresponding to the current in a test coil multiplied by the number of turns in the test coil. Typical pull-in sensitivities for commercial devices are in the 10 to 60 AT range.

The lower the AT, the more sensitive the reed switch. Also, smaller reed switches, which have smaller parts, are more sensitive to magnetic fields, so the smaller the reed switch’s glass envelope is, the more sensitive it is.

In production, a metal reed is inserted in each end of a glass tube and the end of the tube heated so that it seals around a shank portion on the reed. Green-colored Infrared-absorbing glass is frequently used, so an infrared heat source can concentrate the heat in the small sealing zone of the glass tube.

The thermal coefficient of expansion of the glass material and metal parts must be similar to prevent breaking the glass-to-metal seal. The glass used must have a high electrical resistance and must not contain volatile components such as lead oxide and fluorides which can contaminate the contacts during the sealing operation.

The leads of the switch must be handled carefully to prevent breaking the glass envelope. The glass envelope can be damaged if the reed switch is subjected to mechanical stress.

 

 

Parts List

Name link
Raspberry Pi 4 Aliexpress product link

Amazon. com link

Ebay search

37 sensor kit AliExpress Product link

Amazon link

ebay link

connecting wire Aliexpress product link

Amazon.com link

Ebay link

 

Layout

We use pin 40 (GPIO 21) in this example, you can use another GPIO pin.

pi and ky-021 layout

pi and ky-021 layout

 

pi and ky-021 schematic

pi and ky-021 schematic

 

 

Code Examples

https://gist.github.com/getelectronics/899190a9830226c0a2881574e7a4d8a9

Download

code on github

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More