Wifi_Lora_32_V3.1 SD Card

I have read every post regarding how to add an SD card reader and soldered many many times to various pins.

But I have never managed to get the SD Card reader to mount.

I would be very grateful if someone would please help, that has managed to get one working on the V3.1 version.

I’m using Ve 3.3v turned on by VextOn

I have not tested a SD card on any Heltec board but have used them on many ESP32 only (no LoRa) projects.

Here is what I have found successful but still never 100% reliable:

  • Start with a small sample program and focus on SD only. Nothing else. Build on that once you have the SD Card working.

  • Use smaller cards. I think the software has limits to the card size.

  • Get a variety of cards to test with. Different sizes, different manufactures.

  • Run a scan disk on the card on a Windows computer. Many times when the card won’t mount the file systems is messed up in some way.

  • Write to the card only in one function of your program.

  • On the most reliable setup, I have a switch that when I turn it on, will inhibit the code from writing to the card and power off the SD Card. Press the switch before any software reloads of the board or power down’s. With the Vext ability that might be a way of doing it. In my project I use a transistor controlled by a GPIO pin to remove power from the SD card when the software senses the switch has been pressed. Never want to interrupt a write to the card with a reboot/power cycle.

  • I use Platformio for development and when you start a compile, it will reset the board and the board will start again and depending on how long the compile takes may interrupt the SD card. This is what lead me to install the switch and always turn off the SD card before reloading the board.

1 Like

Thank you very much for your advice, however my problem is that I am having trouble actually mounting the device.

Many people claim that they have done it with various different pins, but the pin outs have changed on version v3.1 of the Heltec and everything I have tried fails.

What pins connections have you tried? Post a sample code too.

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

#define SD_SCLK 18 // SCK
#define SD_MISO 19 // MISO
#define SD_MOSI 23 // MOSI
#define SD_CS 5 // CS

SPIClass sd_spi(VSPI);

void setup() {
Serial.begin(115200);

// Initialize SPI with custom pins
sd_spi.begin(SD_SCLK, SD_MISO, SD_MOSI, SD_CS);

// Attempt to initialize the SD card
if (!SD.begin(SD_CS, sd_spi)) {
Serial.println(“Card Mount Failed”);
while(1) {}
}

Serial.println(“Card initialized.”);
}

void loop() {
// Your main code here
}

I have tried all the combinations on this forum. The SD card works fine on Arduino Uno

Are you referring to this board? https://resource.heltec.cn/download/WiFi_LoRa_32_V3/HTIT-WB32LA(F)_V3.png The GPIO’s you mention 18 & 23 are on the headers.

Am I looking at the same board that you are referring to?

This code doesn’t enable Vext which is disabled by default.

Yes it’s the correct board, I agree with you that the GPIO’s are NOT on the headers, which is obviously why that combination doesn’t work, but as mentioned I’ve tried so many combinations, too many to list. None seem to work.

That’s an interesting point, do I need to enable Vext for SPI to function?

If the SD card module is connected to Vext - yes!

Ha I answered the question myself shortly after posting and checked my code again. I had enabled Vext. But problem still there, spent hours soldering to various gpio combinations trying to get it to mount the SD, always failed.

What is your complete code for testing, then? Surely not the one above as that doesn’t include Vext handling. Please also attach a picture of your wiring.