Robot Pi Shop

KY-020 Ball Switch Module

$1.25

Shipping calculated at checkout.

Quantity

KY-020 Ball Switch Module – Digital Tilt Sensor for Arduino & ESP32

The KY-020 Ball Switch Module is a compact tilt detection sensor designed to detect changes in orientation and movement using a mechanical ball switch.

The module contains a small conductive metal ball inside a sealed switch housing. When the sensor is tilted, the ball moves and opens or closes the electrical contacts, producing a digital signal that can be detected by a microcontroller.

The KY-020 is ideal for Arduino, ESP32, Raspberry Pi, robotics, tilt alarms, orientation detection, and DIY electronics projects.

Key Features

  • Model: KY-020
  • Sensor Type: Mechanical Ball Tilt Switch
  • Detection Method: Tilt and Orientation
  • Output Type: Digital (HIGH/LOW)
  • Operating Voltage: Typically 3.3V–5V DC
  • Switch Technology: Conductive Metal Ball
  • Mercury-Free Design
  • 3-Pin Interface: Signal (S), VCC (+), GND (-)
  • Simple ON/OFF Tilt Detection
  • Compact and Lightweight PCB
  • Suitable for Arduino, ESP32, and Raspberry Pi Projects

Technical Specifications

Parameter Specification
Model KY-020
Product Type Ball Switch Sensor Module
Sensor Technology Mechanical Ball Switch
Detection Type Tilt / Orientation
Operating Voltage Typically 3.3V–5V DC
Output Type Digital
Output States HIGH / LOW
Switching Mechanism Conductive Metal Ball
Number of Pins 3
Pin Configuration S / + / -
Mercury Content None
Board Dimensions Approximately 18.5 × 15mm
Interface Digital GPIO
Measurement Type Binary Tilt Detection

Pin Configuration

Pin Function
S Digital Signal Output
+ Power Supply
- Ground

Arduino Connection Example

KY-020 Arduino Uno
S D3
+ 5V
- GND

The Arduino monitors the digital output to determine whether the ball switch is open or closed.

Arduino Example Code

const int tiltPin = 3;

void setup() {
  pinMode(tiltPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  int tiltState = digitalRead(tiltPin);

  if (tiltState == HIGH) {
    Serial.println("Switch HIGH");
  } else {
    Serial.println("Switch LOW");
  }

  delay(100);
}

The HIGH and LOW states depend on the sensor's orientation and the module's internal circuit.

Applications

  • Tilt and Orientation Detection
  • Arduino and ESP32 Projects
  • Raspberry Pi GPIO Input
  • Robotics and Automation
  • Tilt-Activated Alarm Systems
  • Equipment Position Monitoring
  • Movement Detection
  • DIY Security Projects
  • Educational STEM Projects
  • Electronic Prototyping

Important Notes

  • The KY-020 provides binary tilt detection and cannot measure the exact tilt angle.
  • It is not an accelerometer or gyroscope.
  • Unlike mercury-based tilt switches, the KY-020 uses a mechanical metal ball and contains no mercury.
  • The activation angle depends on the switch's orientation and internal construction.
  • Mechanical contact bounce may occur during movement. Software debouncing can improve signal stability.
  • The module may produce intermittent signals when subjected to vibration.
  • For ESP32 and Raspberry Pi, ensure the digital output does not exceed 3.3V.
  • Use an appropriate pull-up or pull-down resistor if required by the module circuit.
  • Verify the pin configuration and switching behavior of the supplied version before wiring.
  • The module is intended for low-voltage signal detection, not direct switching of high-power loads.

Package Includes

1 × KY-020 Ball Switch Module