Error: 'GPIO_REG_READ' was not declared in this scope

Hello, Does someone know where is GPIO_REG_READ macro #defined?

What board are you using? Is this error coming from your code, a library or some core module? What sketch are you trying to compile.

More info please.

I'm trying to read GPIO values directly from registers. I found sample code here:

and I'm trying to compile it now.

Currently I'm working with ESP32 Dev Module but I'm looking for a solution that would work on every ESP32 board.

Basically, what I want to do is read GPIOs regardless of how they are configured (as INPUT as OUTPUT or PWM), without changing the configuration.

WIth IDF 4.x the following did it:

PIN_INPUT_ENABLE (GPIO_PIN_MUX_REG [gpio_pin]);
digitalRead (gpio_pin);

But this doesn't seem to work with IDF 5.x any more.

First, instead of using GPIO_REG_READ we can use READ_PERI_REG, which is not really important for the original question.

And the answer to the original question: the reading of OUTPUT and PWM GPIOs is solved here:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.