Home Code KY-017 Mercury Tilt Switch Module and Raspberry Pi

KY-017 Mercury Tilt Switch Module and Raspberry Pi

by shedboy71

In this example we take a look at the KY-017 Mercury Tilt Switch Module and connect this to a Raspberry Pi.

This info is from wikipedia

Mercury switches have one or more sets of electrical contacts in a sealed glass envelope that contains a small quantity of mercury. The envelope may also contain air, an inert gas, or a vacuum.

Gravity constantly pulls the drop of mercury to the lowest point in the envelope. When the switch is tilted in the appropriate direction, the mercury touches a set of contacts, thus completing an electrical circuit.

Tilting the switch in the opposite direction moves the mercury away from that set of contacts, breaking that circuit.The switch may contain multiple sets of contacts, closing different sets at different angles, allowing, for example, single-pole, double-throw (SPDT) operation.

Advantages

The contacts are enclosed, so oxidation of the contact points is unlikely.
In hazardous locations, interrupting the circuit does not emit a spark that could ignite flammable gases.
Contacts stay clean, and even if an internal arc occurs, the contact surfaces renew on every operation, so they don’t wear out.
Even a small drop of mercury has low resistance, so switches can carry useful amounts of current in a small size
Sensitivity of the drop to gravity provides a unique sensing function, and lends itself to simple, low-force mechanisms for manual or automatic operation.
The switches are quiet, as no contacts abruptly snap together.
The mass of the moving mercury drop provides an over center effect to avoid chattering as the switch tilts.
The envelope can include contacts for two or more circuits.

Disadvantages

Their relatively slow operating rate (due to the inertia of the mercury drop) makes them unsuitable for applications that require many operating cycles per second.
Glass envelopes and wire electrodes may be fragile and require flexible leads to prevent damage to the envelope.
The mercury drop forms a common electrode, so circuits are not isolated from each other in a multi-pole switch.
Their sensitivity to gravity may make them unsuitable in portable or mobile devices that can change orientation or vibrate.
Mercury compounds are highly toxic and accumulate in any food chain, so safety codes exclude mercury in many new designs.

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 13 (GPIO27) for the sensor, one of the examples also has an LED connected to Pin 11 (GPIO17). We have not shown this in the schematic and layout below

 

pi and ky-017 layout

pi and ky-017 layout

 

pi and ky-017 schematic

pi and ky-017 schematic

 

Code Examples

https://gist.github.com/getelectronics/7e4f55280ce8f9e4f133c4448ce87c6a

Download

code download from github

https://gist.github.com/getelectronics/7e4f55280ce8f9e4f133c4448ce87c6a/archive/43cbc5f1e897c65082bf4f961c19e02a0ab2bb4b.zip

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