← index #5216PR #6639
Likely Duplicate · medium · value 3.221
QUERY · ISSUE

ESP32 Pulse Counter Driver

openby nevercastopened 2019-10-16updated 2021-12-13
port-esp32

Add a driver for ESP32 Pulse Counter Hardware.

Related to: #5214

CANDIDATE · PULL REQUEST

ESP32: New hardware PCNT Counter() and Encoder().

closedby IhorNehrutsaopened 2020-11-20updated 2025-08-13
port-esp32

This PR consistent to
docs\machine: Add Counter and Encoder classes #8072

ESP32 Pulse Counter
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/pcnt.html

Wrapped around
https://github.com/espressif/esp-idf/blob/master/components/driver/include/driver/pcnt.h
https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/pcnt_types.h
https://github.com/espressif/esp-idf/blob/master/components/driver/pcnt.c

See also
https://github.com/espressif/esp-idf/tree/master/examples/peripherals/pcnt/pulse_count_event

ESP32 Quadrature Encoder based on Pulse Counter(PCNT)
Based on
https://github.com/madhephaestus/ESP32Encoder
https://github.com/bboser/MicroPython_ESP32_psRAM_LoBo/blob/quad_decoder/MicroPython_BUILD/components/micropython/esp32/machine_dec.c

See also
https://github.com/espressif/esp-idf/tree/master/examples/peripherals/pcnt/rotary_encoder

If your port does not support hardware encoder use machine.Pin() Interrupt-based MicroPython quadrature incremental encoder

UPDATE:
This pull request is not possible to rebase on master.
Please switch to the
ESP32: Add Quadrature Encoder and Pulse Counter classes. https://github.com/micropython/micropython/pull/8766

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied