I’m working on a project where I need to create a file on a USB pendrive using the CH376 USB module connected to my ESP32 via SPI. Despite verifying my connections multiple times, I’m unable to create any files on the pendrive.
I’m using the Ch376msc library and running the example project provided, but it's not working as expected as it shows Attach flash drive first! even though my pendrive is connected to the module. I changed the CS pin in the code to my ESP32 CS pin. Also I tried changing the module and even checked the voltages of the INT pin and Supply pins and they were proper. Has anyone here successfully worked with creating files on a USB pendrive through the ESP32 using the CH376 module?
Switching to an SD card is not an option due to project constraints, so I must use a USB pendrive. Any advice or troubleshooting tips would be greatly appreciated!
What firmware does the CH376 have, because the library you linked has this in the library description.
Some of these chips are shipped with old firmware( revision number less than 0x43), with these modules you will faces some issues like doesn't recognize a flash drive or it will be unreadable the file created with this chip for Windows and vice versa. For more details click here.
In working with the CH376S, any firmware version 0x41, the USB flash drive HAS to be formatted under Windows XP, FAT 32, default allocation size.
for CH3776S firmware 0x42 and 0x44, you can format the USB flash drive FAT32 under WinXP, or Win7x64 or Win10.
Also had to add a delay in void setup() after both Serial.begin(115200); and
flashDrive.init();
Code Snippet
void setup()
{
Serial.begin(115200); // setup serial with a baud rate of 115200
delay(6000);
pcf.init(); //initialize the PC8563 RTC
pinMode(entSwA2, INPUT); // sets the Analog Input pin A2 as Input
flashDrive.init();
delay(2000);
fDMessage = flashDrive.checkIntMessage();
fDDevStat = flashDrive.getDeviceStatus();
fDChipVer = flashDrive.getChipVer();
fDReady = flashDrive.driveReady();
Serial.print("flashDrive.checkIntMessage() = ");
Serial.println(flashDrive.checkIntMessage());
Serial.print("flashDrive.getDeviceStatus() = ");
Serial.println(flashDrive.getDeviceStatus());
Serial.print("CH376 Chip Version = ");
// CH376 Chip Version = 68 = 0x44 in hex
// CH376 Chip Version = 65 = 0x41 in hex not good with win 7 formatted usb drives
// CH376 Chip Version = 68 = 0x44 in hex 5 new units from aliexpress 11/25/24
Serial.println(flashDrive.getChipVer()); // CH376 Chip Version = 65 = 0x41