I’m not certain about the ESP32, but I can tell you the Wemos D1 Mini (ESP8266) was rather persnickety about precisely which digital input and output pins you used. Have you tried general digital pins, specifically not already designated to I2C or UART or SPI functions?