// other
KY-040 Rotary Encoder
Incremental rotary encoder w/ push button
€1.20
avg eur
no image
Digital
Pins
5
Specs
4
Libraries
2
Protocols
1
// wiring → esp32 devkit v1
VCC (+)
3V3
EN
GPIO36
VP
GPIO39
VN
GPIO34
GPIO35
GPIO32
GPIO33
GPIO25
GPIO26
GPIO27
GPIO14
GPIO12
GND
GND
GPIO13
ESP32
WROOM-32
devkit v1
USB
VIN
5V
GND
GPIO23
GPIO22
SCL
GPIO1
TX0
GPIO3
RX0
GPIO21
SDA
GPIO19
MISO
DT
GPIO18
SCK
CLK
GPIO5
SS
SW
GPIO17
TX2
GPIO16
RX2
GPIO4
GPIO2
GPIO15
sensor pin (left)
sensor pin (right)
unused
// pinout → esp32
| Sensor Pin | ESP32 Connection |
|---|---|
| VCC (+) | 3.3V |
| GND | GND |
| CLK | GPIO 18 |
| DT | GPIO 19 |
| SW | GPIO 5 (opt) |
// technical specs
Steps
20 per revolution
Output
2-channel quadrature
Button
yes (push)
Voltage
3.3–5V
// github libraries
// notes & warnings
Use interrupts for clean reads. Bouncy — debounce in software or with 0.1µF caps. ESP32 PCNT peripheral works great.
// related sensors · other