ESP32 KY-020 Tilt Switch Module

KY-020 Tilt Switch Module image

KY-020

Protocol: Digital

Overview

The KY-020 is a tilt switch module that detects changes in orientation. It provides a digital signal output, making it suitable for applications like motion detection, security systems, and tilt-based controls.

About KY-020 Tilt Switch Module

The KY-020 Tilt Switch Module is designed to detect orientation or inclination. It contains a metallic ball that connects or disconnects the circuit depending on the module’s tilt angle. When tilted, the ball moves, closing or opening the circuit, which can be read as a digital signal by microcontrollers like the Arduino or ESP32. This module operates at voltages between 3.3V and 5V, making it versatile for various projects.

Where to Buy

KY-020 Tilt Switch 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 - 5V
Output Type Digital
Dimensions 19 x 15 x 5 mm

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 (-): Connects to ground (GND).
  • Pin (middle): Connects to VCC (3.3V to 5V).
  • Pin (S): Outputs the digital signal; connect to a digital input on your microcontroller.

Wiring with ESP32

  • KY-020 Pin (-): Connect to ESP32 GND.
  • KY-020 Pin (middle): Connect to ESP32 3.3V.
  • KY-020 Pin (S): Connect to a digital GPIO pin on ESP32 (e.g., GPIO4).

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-020 Tilt Switch 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.