KY-036 Metal Touch Sensor Module
The KY-036 is a metal touch sensor module that detects touch via its metal tip, offering both analog and digital outputs. With adjustable sensitivity, it's ideal for interactive applications and touch-based controls.

On this page
KY-036 pinout
The KY-036 is a 4-pin capacitive touch sensor module:
| Pin | Type | Description | Notes |
|---|---|---|---|
| GND | Power | Ground connection | |
| +V | Power | Power supply | 3.3V or 5V |
| D0 | Communication | Digital output | HIGH when touch detected |
| A0 | Communication | Analog output | Voltage reading of touch sensor |
Interface: Dual output (analog + digital with comparator)
Sensor: Capacitive touch detection via metal probe
Analog Output: Continuous capacitance measurement
Digital Output: Threshold-based trigger (adjustable via potentiometer)
Power: 3.3V or 5V operation
Sensitivity: Adjustable via onboard potentiometer
LED Indicators: Power LED and touch detection LED
Applications: Interactive installations, touch switches, proximity detection, human interface
Wiring the KY-036 to ESP32
To interface the KY-036 with an ESP32 for touch detection:
| KY-036 pin | ESP32 pin | Purpose |
|---|---|---|
| GND | GND | Ground |
| +V | 3.3V or 5V | Power supply |
| D0 | GPIO15 | Digital input (any GPIO) · optional |
| A0 | GPIO34 | Analog input (ADC pin) · optional |
Digital Mode: Use D0 for simple on/off touch detection
Analog Mode: Use A0 for proximity sensing or pressure measurement
ADC Pins: Use GPIO32-39 for analog input on ESP32
Voltage: 3.3V recommended for ESP32 ADC compatibility
Adjustment: Turn potentiometer to set touch sensitivity threshold
Touch Probe: Metal tip detects body capacitance when touched
Grounding: User must be grounded (touching ground or standing on floor) for reliable detection
LED Feedback: Status LED lights when touch detected
KY-036 code examples
KY-036 Arduino example
Copy// Declaration and initialization of the input pins
int analog_input = 34; // Analog output of the sensor (GPIO34, matches the wiring above)
int digital_input = 15; // Digital output of the sensor (GPIO15)
void setup() {
pinMode(digital_input, INPUT);
Serial.begin(115200);
Serial.println("KY-036 Touch Recognition");
}
void loop() {
// Read current values and convert to voltage (ESP32: 12-bit ADC, 3.3V)
float analog_value = analogRead(analog_input) * (3.3 / 4095.0);
int digital_value = digitalRead(digital_input);
Serial.print("Analog voltage value: ");
Serial.print(analog_value, 4);
Serial.print(" V, Threshold value: ");
if (digital_value == 1) {
Serial.println("reached");
} else {
Serial.println("not reached");
}
Serial.println("-------------------------------");
delay(1000);
}This Arduino code initializes the analog and digital input pins connected to the KY-036 sensor. It reads the analog voltage and digital state, printing the analog voltage and whether the threshold set by the potentiometer has been reached to the serial monitor every second.
KY-036 ESP-IDF example
Copy#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/adc.h"
#include "driver/gpio.h"
#define ANALOG_PIN ADC1_CHANNEL_6 // GPIO34
#define DIGITAL_PIN GPIO_NUM_15
void app_main(void) {
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_config_channel_atten(ANALOG_PIN, ADC_ATTEN_DB_11);
gpio_set_direction(DIGITAL_PIN, GPIO_MODE_INPUT);
printf("KY-036 Touch Sensor Test\n");
while (1) {
int raw = adc1_get_raw(ANALOG_PIN);
float voltage = raw * (3.3 / 4095.0);
int digital_state = gpio_get_level(DIGITAL_PIN);
printf("Analog Voltage: %.2f V, Threshold: %s\n", voltage, digital_state ? "reached" : "not yet reached");
vTaskDelay(pdMS_TO_TICKS(1000));
}
}This ESP-IDF code configures GPIO34 as an analog input and GPIO15 as a digital input for the KY-036 sensor. It reads the analog voltage and digital state, printing the voltage and whether the threshold has been reached to the console every second.
KY-036 ESPHome example
Copysensor:
- platform: adc
pin: GPIO34
name: "KY-036 Touch Sensor Analog"
update_interval: 1s
filters:
- multiply: 3.3
- lambda: |-
return x * 1000; // Convert to millivolts
binary_sensor:
- platform: gpio
pin:
number: GPIO15
mode: INPUT_PULLUP
name: "KY-036 Touch Sensor Digital"This ESPHome configuration sets up the KY-036 sensor with both an analog and digital sensor. The analog value from GPIO34 is converted to millivolts, while the digital sensor on GPIO15 acts as a binary sensor to indicate touch detection.
KY-036 PlatformIO example
Copy[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino#include <Arduino.h>
#define ANALOG_PIN 34
#define DIGITAL_PIN 15
void setup() {
pinMode(DIGITAL_PIN, INPUT_PULLUP);
Serial.begin(115200);
Serial.println("KY-036 Touch Sensor Test");
}
void loop() {
int raw_value = analogRead(ANALOG_PIN);
float voltage = raw_value * (3.3 / 4095.0) * 1000; // Convert to millivolts
int digital_value = digitalRead(DIGITAL_PIN);
Serial.printf("Analog Voltage: %.2f mV, Digital State: %s\n", voltage, digital_value ? "Touched" : "Not Touched");
delay(1000);
}This PlatformIO code sets up GPIO34 as an analog input and GPIO15 as a digital input for the KY-036 sensor. It reads the analog voltage and digital state, logging the voltage and touch detection status to the serial monitor every second.
KY-036 MicroPython example
Copyimport machine
import time
ANALOG_PIN = machine.ADC(machine.Pin(34))
ANALOG_PIN.atten(machine.ADC.ATTN_11DB)
DIGITAL_PIN = machine.Pin(15, machine.Pin.IN, machine.Pin.PULL_UP)
while True:
analog_value = ANALOG_PIN.read()
voltage = (analog_value / 4095) * 3300 # Convert to millivolts
digital_value = DIGITAL_PIN.value()
print("Analog Voltage:", voltage, "mV", "| Digital State:", "Touched" if digital_value == 1 else "Not Touched")
time.sleep(1)This MicroPython script configures GPIO34 as an ADC input and GPIO15 as a digital input for the KY-036 sensor. It continuously reads the sensor values and prints the voltage and touch state every second.
KY-036 specifications
About the KY-036
The KY-036 isn’t a capacitive touch sensor in the way a dedicated chip like a TTP223 is. Touching its exposed metal probe doesn’t measure a change in capacitance directly - instead, the body acts as a small antenna that picks up the faint 50/60 Hz hum radiated by nearby AC wiring and mains-powered equipment, and a high-gain Darlington transistor on the board amplifies that tiny induced signal enough for an LM393 comparator to square it up against a threshold set by the onboard potentiometer. It’s a clever trick, but it means detection quality depends on how much ambient mains hum is around: touch sensitivity in a room full of AC-powered gear is usually solid, while battery-powered, electromagnetically quiet, or outdoor setups can make the sensor sluggish or unreliable in ways a true capacitive IC wouldn’t be.
Both the analog and digital pins come off that same comparator stage, so the “analog” output is really just the pre-threshold amplified hum signal rather than a calibrated measure of touch pressure or contact area. For projects that need touch detection to work consistently regardless of the electrical environment - portable or battery-powered builds especially - a dedicated capacitive touch IC is the more dependable choice; the KY-036 is best treated as a fun, quirky sensor for AC-powered desktop projects rather than a general-purpose touch input.
KY-036 troubleshooting
No Response from Sensor
›
Issue: The sensor does not respond to touch.
Solutions:
- Ensure the module is properly powered with the correct voltage.
- Verify all connections are secure and correctly wired.
- Adjust the sensitivity using the onboard potentiometer.
False Triggering
›
Issue: The sensor triggers without being touched.
Solutions:
- Reduce the sensitivity using the potentiometer to prevent false triggers.
- Ensure the environment is free from electrical noise or interference.
- Check for any conductive materials accidentally touching the sensor's metal tip.
Where to buy the KY-036

Resources
Similar sensors





