KY-002 Vibration switch
This sensor is a module that can sense vibrations and emits a signal at each vibration.
- Arduino
- Raspberry Pi
- Raspberry Pi Pico
- Micro:Bit

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.
Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.
Technical Data | |
---|---|
Operating voltage | 3,3 V - 5 V |
Dimensions | 18,5 mm x 15 mm |
Pin assignment
Arduino | Sensor |
---|---|
Pin 10 | Signal |
5 V | +V |
GND | GND |
Code-Example
To load the following code example onto your Arduino, we recommend using the Arduino IDE. In the IDE, you can select the appropriate port and board for your device.
Copy the code below into your IDE. To upload the code to your Arduino, simply click on the upload button.

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.
Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.
Technical Data | |
---|---|
Operating voltage | 3,3 V - 5 V |
Dimensions | 18,5 mm x 15 mm |
Pin assignment
Raspberry Pi | Sensor |
---|---|
GPIO 24 [Pin 18] | Signal |
3.3 V [Pin 1] | +V |
GND [Pin 6] | GND |
Code-Example
This is an example program that prints a console output when as signal is detected at the sensor.

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.
Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.
Technical Data | |
---|---|
Operating voltage | 3,3 V - 5 V |
Dimensions | 18,5 mm x 15 mm |
Pin assignment
Micro:Bit | Sensor |
---|---|
Pin 1 | Signal |
3 V | +V |
GND | GND |
Code-Example
pins.setPull(DigitalPin.P1, PinPullMode.PullDown)
basic.forever(function () {
serial.writeLine("" + (pins.digitalReadPin(DigitalPin.P1)))
if (pins.digitalReadPin(DigitalPin.P1) == 1) {
serial.writeLine("Shock detected")
} else {
serial.writeLine("No shock detected")
}
serial.writeLine("_____________________________________")
basic.pause(1000)
})
Example program download

The KY-002 shock and vibration sensor is a precise module for detecting shocks and vibrations. It consists of a conductive outer casing and an internal spring. In the event of shocks, the spring closes the contact to the outer casing and thus generates an electrical signal. This simple design enables reliable and fast detection of vibrations.
Technically speaking, the KY-002 operates in the voltage range from 3.3 V to 5 V. The compact design facilitates integration into a wide variety of projects. Thanks to its robustness and ease of use, the KY-002 is ideal for applications in security systems where vibrations on doors and windows need to be detected, as well as in industrial automation for monitoring machines and systems for unusual vibrations. The sensor can also be used to measure vibrations and shocks in the sports and fitness sector.
Technical Data | |
---|---|
Operating voltage | 3,3 V - 5 V |
Dimensions | 18,5 mm x 15 mm |
Pin assignment
Raspberry Pi Pico | Sensor |
---|---|
GPIO26 | Signal |
3.3V | +V |
GND | GND |
Code-Example
This is an example program that counts up and outputs text serially when a signal is detected at the sensor.
To load the following code example onto your Pico, we recommend using the Thonny IDE. All you have to do first is go to Run > Configure interpreter ... > Interpreter > Which kind of interpreter should Thonny use for running your code? and select MicroPython (Raspberry Pi Pico).
Now copy the code below into your IDE and click on Run.