I have an ultrasonic sensor connected with my ESP32-CAM AI Thinker which is powered by an ESP32-CAM-MB. I am pretty new to Arduino, so my sensor is connected to 5v, ground, trigger to gpio13 and echo to gpio15. I am using the sensor to measure distance between an object, once the object is near, the camera takes an image and preferably save it to the SD card.
However when my sensor is connected, the SD card mount fails. Exiting with sdmmc_io: sdmmc_io_reset: unexpected return: 0x108. After some tests, if I remove the echo pin cable from the board according to the pinout it's the hs2-cmd, the SD card will mount properly. How can I actually connect the sensor to the board without loosing the SD card functionality? Will I need to use some sort of Master/Slave approach if so how ?
Hi,
When using sd card on the esp32cam there are very limited spare gpio pins.
pin 13 is used by the sd card but you can get round this by putting the sd card in "1 bit mode", this then leaves pins 12 and 13 available (12 must not be high at boot).
see my sketch below which demonstrates using 1 bit mode and the gpio pins
Note: I have been told reading the sd card in 1 bit mode can be an issue, I have only written to it myself