ESP32 KY-031 Knock Sensor Module

KY-031 Knock Sensor Module image

KY-031

Protocol: Digital

Overview

The KY-031 is a knock sensor module that detects physical impacts or vibrations. Upon detecting a knock, it outputs a digital signal, making it suitable for applications like interactive projects, security systems, or any setup requiring tap detection.

About KY-031 Knock Sensor Module

The KY-031 Knock Sensor Module is designed to detect knocks or vibrations. When subjected to such physical impacts, the sensor’s internal contacts momentarily connect, sending a digital signal. This module is ideal for projects that require tap or knock detection, such as interactive interfaces or security systems.

Where to Buy

KY-031 Knock Sensor Module

Starting from

1$ per unit

Amazon com
Amazon.com Ships worldwide
View Price
Amazon de
Amazon.de Ships to EU
View Price
Aliexpress
AliExpress Best value
View Price

Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.

Technical Specifications

Operating Voltage 3.3V to 5V
Output Type Digital
Dimensions 19mm x 15mm x 10mm
Weight 2g

Pinout Configuration

The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32.

  • Pin S (Signal): Outputs a digital signal when a knock is detected.
  • Pin middle (+): Connects to the power supply (3.3V or 5V).
  • Pin - (GND): Connects to the ground of the circuit.

Wiring with ESP32

  • Pin S: Connect to a digital input pin on the ESP32 (e.g., GPIO16).
  • Pin middle (+): Connect to ESP32 3.3V or 5V.
  • Pin -: Connect to ESP32 GND.

Troubleshooting Guide

Common Issues

❌ No Response from Sensor

⚠️ False Triggering

Debugging Tips

🔍 Serial Monitor

⚡ Voltage Checks

Code Examples

Arduino Example

C++
🔧

ESP-IDF Example

C++
🏠

ESPHome Example

YAML
🛠️

PlatformIO Example

C++
🐍

MicroPython Example

Python

Conclusion

The ESP32 KY-031 Knock Sensor Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.

For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.

Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.