How to get digital input from ADC pins?

sittingduck
Posts: 5
Joined: Thu Mar 28, 2019 9:35 am

How to get digital input from ADC pins?

Postby sittingduck » Mon Nov 09, 2020 8:25 pm

I would like to use my pins, which are able to do ADC1, as general GPIO pins to read digital values. This is somehow not possible using this config:

Code: Select all

    gpio_config_t io_conf;

    // configure interrupt pins
    // set as input mode
    io_conf.mode = GPIO_MODE_INPUT;
    // interrupt
    io_conf.intr_type = GPIO_INTR_DISABLE;
    // bit mask of the pins
    io_conf.pin_bit_mask = (BIT(39) | BIT(36) | BIT(34));
    // dis pull-down mode
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
    // disable pull-up mode
    io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
    esp_err_t ret_gpio = gpio_config(&io_conf);
Do I need to deactivate ADC somehow? What is the reason, why I cannot read their digital values with:

Code: Select all

gpio_get_level(36);
//...

chegewara
Posts: 1318
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to get digital input from ADC pins?

Postby chegewara » Mon Nov 09, 2020 8:37 pm

Code: Select all

io_conf.pin_bit_mask = (BIT(39ULL) | BIT(36ULL) | BIT(34ULL));
or something like that:

Code: Select all

  gpioConfig.pin_bit_mask = ((1ULL<<GPIO_NUM_19) | (1ULL<<GPIO_NUM_18) | (1ULL<<GPIO_NUM_17) | (1ULL<<GPIO_NUM_16));

sittingduck
Posts: 5
Joined: Thu Mar 28, 2019 9:35 am

Re: How to get digital input from ADC pins?

Postby sittingduck » Mon Nov 09, 2020 8:59 pm

What a fail... That's it! Thank you very much. It works...

Who is online

Users browsing this forum: AlexESP32, BergLoewe and 56 guests