Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Available GPIO pins that can be used while using the camera #4

Open
iweave1 opened this issue May 5, 2023 · 2 comments
Open

Available GPIO pins that can be used while using the camera #4

iweave1 opened this issue May 5, 2023 · 2 comments

Comments

@iweave1
Copy link

iweave1 commented May 5, 2023

Hi. I want to add an external SD card reader to my project and need to know which GPIO pins I can use for this.
In the pinout image there doesn't seem to be more than two unused GPIO pins.
This doesn't seem correct.
Would you please help me to know which pins I should use?

@Zhentao-Lin
Copy link
Member

On our board, if the pin has a horizontal wire, it means that it is the pin of the camera, please avoid using it. I recommend using HSPI pins to read and write SD cards.

#include <Arduino.h>
#include <SPI.h>
#include "SD.h"

#define HSPI_MISO 12 //External circuits cannot have pull-up resistors
#define HSPI_MOSI 13
#define HSPI_SCLK 14
#define HSPI_SS 15

SPIClass hspi(HSPI);

void setup(){
Serial.begin(115200);
pinMode(HSPI_SS, OUTPUT);
hspi.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_SS);
if (!SD.begin(HSPI_SS, hspi)) {
Serial.println("Card Mount Failed");
return;
}

uint8_t cardType = SD.cardType();
if (cardType == CARD_NONE) {
Serial.println("No SD card attached");
return;
}

Serial.print("SD Card Type: ");
if (cardType == CARD_MMC) {
Serial.println("MMC");
} else if (cardType == CARD_SD) {
Serial.println("SDSC");
} else if (cardType == CARD_SDHC) {
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}

uint64_t cardSize = SD.cardSize() / (1024 * 1024);
Serial.printf("SD Card Size: %lluMB\n", cardSize);

Serial.printf("Total space: %lluMB\r\n", SD.totalBytes() / (1024 * 1024));
Serial.printf("Used space: %lluMB\r\n", SD.usedBytes() / (1024 * 1024));
}

void loop() {

}

I used a 16GB SD card,and esp32 print the contents by serial port:
SD Card Type: SDHC
SD Card Size: 15193MB
Total space: 252MB
Used space: 53MB

@iweave1 iweave1 closed this as completed May 6, 2023
@iweave1 iweave1 reopened this May 7, 2023
@iweave1
Copy link
Author

iweave1 commented May 7, 2023

I tried to use this with a known good SD card reader board.
I had to remove the connection to get the program uploaded because pin 12 is the bootstrap pin.
Once I uploaded the program, it failed to detect the SD card reader.
I took the SD card reader and connected it back up to another microcontroller and it still works there.
Are there any other pins that can be used? Pin 12 is definitely problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants