KY-031 Knock/Vibration Sensor Module – Digital Impact Detector (Hit)

SKU: FA3046
Module Model

KY-031

Sensor Type

Spring-based vibration / knock sensor

Output Type

Digital (pulse when impact detected)

Operating Voltage

3.3V – 5V DC

Detection Method

Mechanical spring contact

Indication

LED indicator

Pin Count

3 pins (VCC, GND, OUT)

Module Dimensions

Compact PCB with mounting holes

The KY-031 Knock / Vibration Sensor Module is a compact, low-cost impact detection board designed for Arduino, ESP32, Raspberry Pi, STM32, and other microcontroller projects. It uses a spring-based vibration sensor to detect knocks, taps, impacts, and vibrations, providing a clean digital output that can trigger alarms, count events, or activate actions in your project. It is an ideal solution for knock-activated switches, vibration monitoring, tamper detection, and interactive electronics.

At the heart of the module is a spring-type vibration sensor (also called a shock sensor or knock sensor). The sensor consists of a conductive spring surrounding a central metal pin. In the resting state, the spring does not touch the central pin, so the circuit is open. When the module is tapped, knocked, or subjected to vibration, the spring momentarily contacts the central pin, closing the circuit and generating a brief digital pulse. This simple mechanical design provides reliable impact detection without the need for complex calibration.

The module includes signal conditioning circuitry that converts the brief contact pulses into a clean digital output compatible with microcontroller logic levels. The output is typically LOW when no vibration is detected and pulses HIGH (or LOW, depending on variant) when a knock or impact occurs. The pulse duration depends on the intensity and duration of the vibration, but is generally short (milliseconds). An LED indicator provides visual feedback when an impact is detected, making it easy to verify operation during setup and troubleshooting.

The module features a 3-pin interface (VCC, GND, OUT) for easy connection to microcontrollers. The OUT pin can be connected directly to a digital input or interrupt pin on your microcontroller, allowing you to count impacts, trigger alarms, or wake the MCU from sleep. The compact form factor with mounting holes allows easy integration into door knockers, security devices, and interactive installations.

The KY-031 operates from a 3.3V to 5V DC supply, making it compatible with both modern low-power microcontrollers and traditional 5V systems. The low power consumption makes it suitable for battery-powered vibration monitoring projects.

The KY-031 is widely used in knock-activated switches, vibration monitoring systems, tamper detection, impact counters, interactive toys, security alarms, wearable devices, and educational STEM projects. It is also popular in DIY electronics and maker projects where impact or vibration detection is required.

Important Note: The KY-031 uses a mechanical spring sensor, so it may produce multiple pulses from a single knock due to contact bounce. Implement a debounce routine in your code or use a hardware debounce circuit to count impacts reliably. The sensor is not waterproof and should be kept dry. Avoid exposing the module to extreme shock or continuous vibration, as this may cause the spring to deform or fail over time.

Whether you are building a knock-activated light, a vibration alarm, or an impact counter, the KY-031 Knock / Vibration Sensor Module provides a reliable, affordable solution for impact detection. It is suitable for individual makers, students, and businesses purchasing in bulk for product development or educational programs.

Features

  • Spring-based vibration sensor — Detects knocks, taps, impacts, and vibrations

  • Digital output — Clean HIGH/LOW pulse for easy MCU integration

  • Interrupt-friendly output — Suitable for wake-on-impact and event counting

  • LED indicator — Visual feedback when impact is detected

  • Wide voltage range — 3.3V to 5V DC, compatible with Arduino, ESP32, Raspberry Pi

  • Low power consumption — Suitable for battery-powered applications

  • Compact form factor — With mounting holes for easy integration

  • Simple interface — 3-pin connection (VCC, GND, OUT)

  • Wide application range — Knock switches, vibration monitoring, tamper detection, interactive toys

  • Cost-effective — Affordable solution for impact detection in volume production

Technical Specifications 

# Parameter Specification
1 Module Model KY-031
2 Sensor Type Spring-based vibration / knock sensor
3 Output Type Digital (pulse when impact detected)
4 Operating Voltage 3.3V – 5V DC
5 Detection Method Mechanical spring contact
6 Indication LED indicator
7 Pin Count 3 pins (VCC, GND, OUT)
8 Module Dimensions Compact PCB with mounting holes

Usage

Getting Started

  1. Connect power — Supply 3.3V or 5V DC to the VCC pin and GND to ground.

  2. Connect the output — Connect the OUT pin to a digital input or interrupt pin on your microcontroller (e.g., D2 on Arduino).

  3. Upload a test sketch — Read the digital output and observe the state change when the module is tapped or vibrated.

  4. Implement debouncing — Add a debounce routine to filter out multiple pulses from a single impact.

  5. Implement control logic — Use the output to trigger alarms, count impacts, or wake the MCU from sleep.

Pin Connections

Module Pin Function
VCC Power (3.3V–5V)
GND Ground
OUT Digital output (pulses when impact detected)

Example Arduino Code (Knock Detection)

cpp
#define KNOCK_PIN 2

int knockCount = 0;

void setup() {
  Serial.begin(9600);
  pinMode(KNOCK_PIN, INPUT);
  attachInterrupt(digitalPinToInterrupt(KNOCK_PIN), countKnock, RISING);
}

void countKnock() {
  knockCount++;
}

void loop() {
  if (knockCount > 0) {
    Serial.print("Knock detected! Total: ");
    Serial.println(knockCount);
    knockCount = 0;
  }
  delay(100);
}

Typical Applications

  • Knock-activated switches — Turn lights or devices on with a knock

  • Vibration monitoring — Detect abnormal vibration in equipment

  • Tamper detection — Detect unauthorized opening or movement

  • Impact counters — Count hits or drops for testing

  • Interactive toys — Sound and light effects triggered by tapping

  • Security alarms — Detect forced entry or breakage

  • Wearable devices — Step counting or gesture detection

  • Educational STEM projects — Teaching vibration sensing and interrupt handling

Notes for Business Buyers

  • Simple mechanical sensor — No calibration required; works out of the box.

  • Debouncing required — Mechanical contacts produce multiple pulses per impact.

  • Low power — Suitable for battery-powered vibration monitoring.

  • Suitable for bulk purchasing — Ideal for security device manufacturers, toy makers, and educational institutions.

Q: What is the KY-031 Knock/Vibration Sensor Module used for?

It is a vibration and impact detection module for knock-activated switches, vibration monitoring, tamper detection, and interactive electronics.

Q: How does the sensor work?

The module uses a spring-based sensor. When tapped or vibrated, the spring momentarily contacts the central pin, closing the circuit and generating a digital pulse.

Q: What voltage does the module require?

It operates from 3.3V to 5V DC, making it compatible with Arduino, ESP32, Raspberry Pi, and other microcontrollers.

Q: Why does my module produce multiple counts from one knock?

The mechanical spring sensor produces contact bounce, resulting in multiple pulses per impact. Implement a debounce routine in your code or use a hardware debounce circuit.

Q: What is the output logic?

The OUT pin pulses when an impact is detected. The resting state is typically LOW (or HIGH, depending on variant).

Q: Can I use this module with an Arduino?

Yes. Connect VCC to 5V, GND to GND, and OUT to a digital pin (e.g., D2). Use digitalRead() or an interrupt to detect impacts.

Q: Can I use this module to wake my microcontroller from sleep?

Yes. The digital output can be connected to an interrupt-capable pin to wake the MCU from deep sleep on impact.

Q: Is the module waterproof?

No. The module is not waterproof and should be kept dry.

Q: How sensitive is the sensor?

The sensitivity depends on the intensity of the vibration. Light taps may not trigger, while strong knocks will. The sensor is not adjustable.

Q: Can I purchase in bulk for a product development project?

Yes. This module is suitable for both individual users and business purchasing, including security device manufacturers, toy makers, and educational institutions.