user70843: I use an ESP32-Cam module for a project for which I need both the SD card and the cam. According to this page, the only pins that are not in use by either the camera or the SD card reader are GPIO0, GPIO2 and GPIO16. However, I need to read an analog value, which is only possible with the pins 12-15, 2 and 4, as the Arduino forums state, which are all in use by the SD card reader.
However, I came across a way to make the SD reader leave the GPIO4 pin out, namely by initializing it with
SD_MMC.begin("/sdcard", true);

Now the flashlight does not light up anymore when accessing the SD card, which means that there is no output anymore to GPIO4. However, it still does not allow me to read the pin after the SD card has been initialized. I also tried "converting" the pin to a GPIO through
pinMode(4, FUNCTION_3);

but it did not make a difference.
So my question is: How can pin 4 be used to read analog values while still keeping the SD card reader functional? And if this is not possible, is there any other way to read an analog value into the ESP32-CAM?

user40646: According to the schematic and pin notes, I don't think you can use GPIO4 as an ADC input (it can be used as a GPIO pin and technically it can be configured as an ADC pin), but it has a 47k pull-up resistor on it, making it not possible to be used as an ADC input.
Depend on your hardware wiring skill, one alternative is to use an external ADC chip with i2c interface (such as an MCP3221) and connect it to TWI_SCL and TWI_SDA, but those pins are only available on cam-connector, not on the header pins.

70843: <p>I use an ESP32-Cam module for a project for which I need both the SD card and the cam. According to <a href="https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout/" rel="nofollow noreferrer">this page</a>, the only pins that are not in use by either the camera or the SD card reader are GPIO0, GPIO2 and GPIO16. However, I need to read an analog value, which is only possible with the pins 12-15, 2 and 4, <a href="https://forum.arduino.cc/index.php?topic=634969.0" rel="nofollow noreferrer">as the Arduino forums state</a>, which are all in use by the SD card reader.</p>
<p>However, I came across a way to make the SD reader leave the GPIO4 pin out, namely by initializing it with</p>
<pre><code>SD_MMC.begin(&quot;/sdcard&quot;, true);
</code></pre>
<p>Now the flashlight does not light up anymore when accessing the SD card, which means that there is no output anymore to GPIO4. However, it still does not allow me to read the pin after the SD card has been initialized. I also tried &quot;converting&quot; the pin to a GPIO through</p>
<pre><code>pinMode(4, FUNCTION_3);
</code></pre>
<p>but it did not make a difference.</p>
<p>So my question is: How can pin 4 be used to read analog values while still keeping the SD card reader functional? And if this is not possible, is there any other way to read an analog value into the ESP32-CAM?</p>
 40646: <p>According to the schematic and <a href="https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/docs/esp32cam-pin-notes.md#gpio4---hs_data1" rel="nofollow noreferrer">pin notes</a>, I don't think you can use GPIO4 as an ADC input (it can be used as a GPIO pin and technically it can be configured as an ADC pin), but it has a 47k pull-up resistor on it, making it not possible to be used as an ADC input.</p>
<p>Depend on your hardware wiring skill, one alternative is to use an external ADC chip with i2c interface (such as an <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/20001732E.pdf" rel="nofollow noreferrer">MCP3221</a>) and connect it to TWI_SCL and TWI_SDA, but those pins are only available on cam-connector, not on the header pins.</p>
