Read analog values in ESP32 Cam

Posts: 1
Joined: Tue Oct 15, 2019 6:39 pm

Read analog values in ESP32 Cam

Postby tanay_esp » Tue Oct 15, 2019 7:05 pm

Hi folks,

I started tinkering with ESP few days earlier. I tried following few example codes and was able to got the camera feed up and running. But for a project, I need to access an analog input as well along with the camera feed.

Is there any concrete example to refer to regarding ESP32 CAM module? I found several for generic ESP 32. I have tried few references from here and there but no luck. Moreover looks like not every adc supporting pin is available on this board.

Few stuffs that I have tried -

Code: Select all

    pinMode(mPin, INPUT);
    analogRead(mPin); /* << Gives a fixed output of 40XX */

Code: Select all

    int read_raw;
    adc2_config_channel_atten( ADC2_CHANNEL_7, ADC_ATTEN_0db );
    esp_err_t r = adc2_get_raw( ADC2_CHANNEL_7, ADC_WIDTH_12Bit, &read_raw);
    if ( r == ESP_OK ) {
        printf("%d\n", read_raw );
    } else if ( r == ESP_ERR_TIMEOUT ) {
        printf("ADC2 used by Wi-Fi.\n");
    } /* << Compiles successfully, but crashes while flashing. */

Board in use
Something like this one - ... rehouse=CN

Has anyone faced or have similar experience in fetching analog value along with wifi cam stream?

Who is online

Users browsing this forum: No registered users and 8 guests