Have you ever wondered if there was a way to store and retrieve data from a USB stick with an Arduino UNO?
Most people choose SD cards to store their project data, but you may be surprised there IS a way!
IC Station have a nice little module which allows you store and retrieve your Arduino (or other MCU) project data to a USB stick.
I am not too sure why USB storage is not widely used in Arduino projects? These modules are not expensive, they have been around for quite a while, and are relatively simple to use.
You do not need any libraries to get them to work, however, I must say that documentation for this module is not that easy to find.
This site and this document proved to be very useful in my endevour to get this module working, and I hope my tutorial below will help you get started and bridge some of the information gaps.
The "CH376S USB read/write module" has a CH376S chip onboard which does most of the hard work for you.
All you have to do is send the module some commands from the Arduino and the CH376S chip will do the rest.
You can communicate with the module in three different ways:
- Parallel communication
- SPI communication
- and Serial (UART) communication.
This project will show you the connections and code for the Serial (UART) communication method only.
Parts Required:
- Arduino UNO or compatible board
- CH376S USB Read Write Module
- Female to Male jumper wires
- Breadboard (optional)
- USB stick
- LED + 330 ohm resistor (optional)
Remove the Jumper
When the CH376S USB module arrives in it's package, it will have a jumper between the TXD pin and GND. You will need to remove this jumper to make the necessary connections between the Arduino UNO and the CH376S USB module.
Fritzing Sketch
Please note, that the Arduino Sketch makes use of the Arduino UNO's onboard LED on digital pin 13. The Fritzing sketch below shows an LED + 300 ohm resistor on a breadboard. This is optional. The LED is not a necessary component of CH376S module communication.
Also be aware that the CH376S USB module has an onboard LED just above the TXD and GND pins near the USB port.
This LED will only turn on providing the CH376S module is in USB mode AND a USB device has been inserted into
the USB port. Both conditions must be met before the module's onboard LED will illuminate. You will not
see the LED turn on just by powering the board.
The wire diagram below is the correct setup for Serial communication between an Arduino UNO and the CH376S module.
If you wish to use SPI or Parallel communication, you will need to refer to the datasheet.
Arduino Sketch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
/* =============================================================== Project: CH376S USB Read/Write Module testing ground Author: Scott C Created: 1st May 2015 Arduino IDE: 1.6.2 Website: http://arduinobasics.blogspot.com/p/arduino-basics-projects-page.html Description: This project will allow you to perform many of the functions available on the CH376S module. Checking connection to the module, putting the module into USB mode, resetting the module, reading, writing, appending text to files on the USB stick. This is very useful alternative to SD card modules, plus it doesn't need any libraries. ================================================================== */ #include <SoftwareSerial.h> byte computerByte; //used to store data coming from the computer byte USB_Byte; //used to store data coming from the USB stick int LED = 13; //the LED is connected to digital pin 13 int timeOut = 2000; //TimeOut is 2 seconds. This is the amount of time you wish to wait for a response from the CH376S module. String wrData = "What is the meaning of life ?"; //We will write this data to a newly created file. String wrData2 = "42"; //We will append this data to an already existing file. SoftwareSerial USB(10, 11); // Digital pin 10 on Arduino (RX) connects to TXD on the CH376S module // Digital pin 11 on Arduino (TX) connects to RXD on the CH376S module // GND on Arduino to GND on CH376S module // 5V on Arduino to 5V on CH376S module //============================================================================================================================================== void setup() { Serial.begin(9600); // Setup serial communication with the computer (using a baud rate of 9600 on serial monitor) USB.begin(9600); // Setup serial communication with the CH376S module (using the default baud rate of 9600) pinMode(LED,OUTPUT); // Define digital pin 13 as an OUTPUT pin - so that we can use it with an LED digitalWrite(LED,LOW); // Turn off the LED } //================================================================================================================================================ void loop() { if(Serial.available()){ computerByte = Serial.read(); //read any incoming bytes from the Serial monitor, and store this byte in the variable called computerByte if(computerByte==49){ //1 //If you send the number 1 from the serial monitor, the arduino will read it as digital number 49. Google "ascii table" for more info. printCommandHeader("COMMAND1: CHECK CONNECTION"); checkConnection(0x01); // Check for successful connection and communication with the CH376S module. } if(computerByte==50){ //2 printCommandHeader("COMMAND2: set_USB_Mode"); set_USB_Mode(0x06); // Code used to enable read/write communication and monitoring of the USB stick } if(computerByte==51){ //3 printCommandHeader("COMMAND3: resetALL"); resetALL(); // Reset the USB device } if(computerByte==52){ //4 printCommandHeader("COMMAND4: Create and Write to File : TEST4.TXT"); writeFile("TEST4.TXT", wrData); // Create a file called TEST4.TXT and then Write the contents of wrData to this file } if(computerByte==53){ //5 printCommandHeader("COMMAND5: Read File: TEST4.TXT"); readFile("TEST4.TXT"); // Read the contents of this file on the USB disk, and display contents in the Serial Monitor } if(computerByte==54){ //6 printCommandHeader("COMMAND6: Append data to file: TEST4.TXT"); appendFile("TEST4.TXT", wrData2); // Append data to the end of the file. } if(computerByte==55){ //7 printCommandHeader("COMMAND7: Delete File: TEST4.TXT"); fileDelete("TEST4.TXT"); // Delete the file named TEST4.TXT } if(computerByte==56){ //8 printCommandHeader("COMMAND8: Read File: TEST2.TXT"); readFile("TEST2.TXT"); // Read the contents of the TEST2.TXT file on the USB disk, and display contents in the Serial Monitor } if(computerByte==57){ //9 printCommandHeader("COMMAND9: Read File: TEST3.TXT"); readFile("TEST3.TXT"); // Read the contents of the TEST3.TXT file on the USB disk, and display contents in the Serial Monitor } } if(USB.available()){ // This is here to capture any unexpected data transmitted by the CH376S module Serial.print("CH376S has just sent this code:"); Serial.println(USB.read(), HEX); } } //END OF LOOP FUNCTION ======================================================================================================================================== //print Command header void printCommandHeader(String header){ Serial.println("======================"); Serial.println(""); Serial.println(header); Serial.println("----------------------"); } //checkConnection================================================================================== //This function is used to check for successful communication with the CH376S module. This is not dependant of the presence of a USB stick. //Send any value between 0 to 255, and the CH376S module will return a number = 255 - value. void checkConnection(byte value){ USB.write(0x57); USB.write(0xAB); USB.write(0x06); USB.write(value); if(waitForResponse("checking connection")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==(255-value)){ Serial.println(">Connection to CH376S was successful."); blinkLED(); //blink the LED for 1 second if the connection was successful } else { Serial.print(">Connection to CH376S - FAILED."); } } } //set_USB_Mode===================================================================================== //Make sure that the USB is inserted when using 0x06 as the value in this specific code sequence void set_USB_Mode (byte value){ USB.write(0x57); USB.write(0xAB); USB.write(0x15); USB.write(value); delay(20); if(USB.available()){ USB_Byte=USB.read(); //Check to see if the command has been successfully transmitted and acknowledged. if(USB_Byte==0x51){ // If true - the CH376S has acknowledged the command. Serial.println("set_USB_Mode command acknowledged"); //The CH376S will now check and monitor the USB port USB_Byte = USB.read(); //Check to see if the USB stick is connected or not. if(USB_Byte==0x15){ // If true - there is a USB stick connected Serial.println("USB is present"); blinkLED(); // If the process was successful, then turn the LED on for 1 second } else { Serial.print("USB Not present. Error code:"); // If the USB is not connected - it should return an Error code = FFH Serial.print(USB_Byte, HEX); Serial.println("H"); } } else { Serial.print("CH3765 error! Error code:"); Serial.print(USB_Byte, HEX); Serial.println("H"); } } delay(20); } //resetALL========================================================================================= //This will perform a hardware reset of the CH376S module - which usually takes about 35 msecs ===== void resetALL(){ USB.write(0x57); USB.write(0xAB); USB.write(0x05); Serial.println("The CH376S module has been reset !"); delay(200); } //readFile===================================================================================== //This will send a series of commands to read data from a specific file (defined by fileName) void readFile(String fileName){ resetALL(); //Reset the module set_USB_Mode(0x06); //Set to USB Mode diskConnectionStatus(); //Check that communication with the USB device is possible USBdiskMount(); //Prepare the USB for reading/writing - you need to mount the USB disk for proper read/write operations. setFileName(fileName); //Set File name fileOpen(); //Open the file for reading int fs = getFileSize(); //Get the size of the file fileRead(); //***** Send the command to read the file *** fileClose(0x00); //Close the file } //writeFile======================================================================================== //is used to create a new file and then write data to that file. "fileName" is a variable used to hold the name of the file (e.g TEST.TXT). "data" should not be greater than 255 bytes long. void writeFile(String fileName, String data){ resetALL(); //Reset the module set_USB_Mode(0x06); //Set to USB Mode diskConnectionStatus(); //Check that communication with the USB device is possible USBdiskMount(); //Prepare the USB for reading/writing - you need to mount the USB disk for proper read/write operations. setFileName(fileName); //Set File name if(fileCreate()){ //Try to create a new file. If file creation is successful fileWrite(data); //write data to the file. } else { Serial.println("File could not be created, or it already exists"); } fileClose(0x01); } //appendFile()==================================================================================== //is used to write data to the end of the file, without erasing the contents of the file. void appendFile(String fileName, String data){ resetALL(); //Reset the module set_USB_Mode(0x06); //Set to USB Mode diskConnectionStatus(); //Check that communication with the USB device is possible USBdiskMount(); //Prepare the USB for reading/writing - you need to mount the USB disk for proper read/write operations. setFileName(fileName); //Set File name fileOpen(); //Open the file filePointer(false); //filePointer(false) is to set the pointer at the end of the file. filePointer(true) will set the pointer to the beginning. fileWrite(data); //Write data to the end of the file fileClose(0x01); //Close the file using 0x01 - which means to update the size of the file on close. } //setFileName====================================================================================== //This sets the name of the file to work with void setFileName(String fileName){ Serial.print("Setting filename to:"); Serial.println(fileName); USB.write(0x57); USB.write(0xAB); USB.write(0x2F); USB.write(0x2F); // Every filename must have this byte to indicate the start of the file name. USB.print(fileName); // "fileName" is a variable that holds the name of the file. eg. TEST.TXT USB.write((byte)0x00); // you need to cast as a byte - otherwise it will not compile. The null byte indicates the end of the file name. delay(20); } //diskConnectionStatus================================================================================ //Check the disk connection status void diskConnectionStatus(){ Serial.println("Checking USB disk connection status"); USB.write(0x57); USB.write(0xAB); USB.write(0x30); if(waitForResponse("Connecting to USB disk")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful Serial.println(">Connection to USB OK"); } else { Serial.print(">Connection to USB - FAILED."); } } } //USBdiskMount======================================================================================== //initialise the USB disk and check that it is ready - this process is required if you want to find the manufacturing information of the USB disk void USBdiskMount(){ Serial.println("Mounting USB disk"); USB.write(0x57); USB.write(0xAB); USB.write(0x31); if(waitForResponse("mounting USB disk")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful Serial.println(">USB Mounted - OK"); } else { Serial.print(">Failed to Mount USB disk."); } } } //fileOpen======================================================================================== //opens the file for reading or writing void fileOpen(){ Serial.println("Opening file."); USB.write(0x57); USB.write(0xAB); USB.write(0x32); if(waitForResponse("file Open")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful Serial.println(">File opened successfully."); } else { Serial.print(">Failed to open file."); } } } //setByteRead===================================================================================== //This function is required if you want to read data from the file. boolean setByteRead(byte numBytes){ boolean bytesToRead=false; int timeCounter = 0; USB.write(0x57); USB.write(0xAB); USB.write(0x3A); USB.write((byte)numBytes); //tells the CH376S how many bytes to read at a time USB.write((byte)0x00); if(waitForResponse("setByteRead")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==0x1D){ //read the CH376S message. If equal to 0x1D, data is present, so return true. Will return 0x14 if no data is present. bytesToRead=true; } } return(bytesToRead); } //getFileSize()=================================================================================== //writes the file size to the serial Monitor. int getFileSize(){ int fileSize=0; Serial.println("Getting File Size"); USB.write(0x57); USB.write(0xAB); USB.write(0x0C); USB.write(0x68); delay(100); Serial.print("FileSize ="); if(USB.available()){ fileSize = fileSize + USB.read(); } if(USB.available()){ fileSize = fileSize + (USB.read()*255); } if(USB.available()){ fileSize = fileSize + (USB.read()*255*255); } if(USB.available()){ fileSize = fileSize + (USB.read()*255*255*255); } Serial.println(fileSize); delay(10); return(fileSize); } //fileRead======================================================================================== //read the contents of the file void fileRead(){ Serial.println("Reading file:"); byte firstByte = 0x00; //Variable to hold the firstByte from every transmission. Can be used as a checkSum if required. byte numBytes = 0x40; //The maximum value is 0x40 = 64 bytes while(setByteRead(numBytes)){ //This tells the CH376S module how many bytes to read on the next reading step. In this example, we will read 0x10 bytes at a time. Returns true if there are bytes to read, false if there are no more bytes to read. USB.write(0x57); USB.write(0xAB); USB.write(0x27); //Command to read ALL of the bytes (allocated by setByteRead(x)) if(waitForResponse("reading data")){ //Wait for the CH376S module to return data. TimeOut will return false. If data is being transmitted, it will return true. firstByte=USB.read(); //Read the first byte while(USB.available()){ Serial.write(USB.read()); //Send the data from the USB disk to the Serial monitor delay(1); //This delay is necessary for successful Serial transmission } } if(!continueRead()){ //prepares the module for further reading. If false, stop reading. break; //You need the continueRead() method if the data to be read from the USB device is greater than numBytes. } } Serial.println(); Serial.println("NO MORE DATA"); } //fileWrite======================================================================================= //are the commands used to write to the file void fileWrite(String data){ Serial.println("Writing to file:"); byte dataLength = (byte) data.length(); // This variable holds the length of the data to be written (in bytes) Serial.println(data); Serial.print("Data Length:"); Serial.println(dataLength); delay(100); // This set of commands tells the CH376S module how many bytes to expect from the Arduino. (defined by the "dataLength" variable) USB.write(0x57); USB.write(0xAB); USB.write(0x3C); USB.write((byte) dataLength); USB.write((byte) 0x00); if(waitForResponse("setting data Length")){ // Wait for an acknowledgement from the CH376S module before trying to send data to it if(getResponseFromUSB()==0x1E){ // 0x1E indicates that the USB device is in write mode. USB.write(0x57); USB.write(0xAB); USB.write(0x2D); USB.print(data); // write the data to the file if(waitForResponse("writing data to file")){ // wait for an acknowledgement from the CH376S module } Serial.print("Write code (normally FF and 14): "); Serial.print(USB.read(),HEX); // code is normally 0xFF Serial.print(","); USB.write(0x57); USB.write(0xAB); USB.write(0x3D); // This is used to update the file size. Not sure if this is necessary for successful writing. if(waitForResponse("updating file size")){ // wait for an acknowledgement from the CH376S module } Serial.println(USB.read(),HEX); //code is normally 0x14 } } } //continueRead()================================================================================== //continue to read the file : I could not get this function to work as intended. boolean continueRead(){ boolean readAgain = false; USB.write(0x57); USB.write(0xAB); USB.write(0x3B); if(waitForResponse("continueRead")){ //wait for a response from the CH376S. If CH376S responds, it will be true. If it times out, it will be false. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful readAgain=true; } } return(readAgain); } //fileCreate()======================================================================================== //the command sequence to create a file boolean fileCreate(){ boolean createdFile = false; USB.write(0x57); USB.write(0xAB); USB.write(0x34); if(waitForResponse("creating file")){ //wait for a response from the CH376S. If file has been created successfully, it will return true. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful createdFile=true; } } return(createdFile); } //fileDelete()======================================================================================== //the command sequence to delete a file void fileDelete(String fileName){ setFileName(fileName); delay(20); USB.write(0x57); USB.write(0xAB); USB.write(0x35); if(waitForResponse("deleting file")){ //wait for a response from the CH376S. If file has been created successfully, it will return true. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful Serial.println("Successfully deleted file"); } } } //filePointer======================================================================================== //is used to set the file pointer position. true for beginning of file, false for the end of the file. void filePointer(boolean fileBeginning){ USB.write(0x57); USB.write(0xAB); USB.write(0x39); if(fileBeginning){ USB.write((byte)0x00); //beginning of file USB.write((byte)0x00); USB.write((byte)0x00); USB.write((byte)0x00); } else { USB.write((byte)0xFF); //end of file USB.write((byte)0xFF); USB.write((byte)0xFF); USB.write((byte)0xFF); } if(waitForResponse("setting file pointer")){ //wait for a response from the CH376S. if(getResponseFromUSB()==0x14){ //CH376S will send 0x14 if this command was successful Serial.println("Pointer successfully applied"); } } } //fileClose======================================================================================= //closes the file void fileClose(byte closeCmd){ Serial.println("Closing file:"); USB.write(0x57); USB.write(0xAB); USB.write(0x36); USB.write((byte)closeCmd); // closeCmd = 0x00 = close without updating file Size, 0x01 = close and update file Size if(waitForResponse("closing file")){ // wait for a response from the CH376S. byte resp = getResponseFromUSB(); if(resp==0x14){ // CH376S will send 0x14 if this command was successful Serial.println(">File closed successfully."); } else { Serial.print(">Failed to close file. Error code:"); Serial.println(resp, HEX); } } } //waitForResponse=================================================================================== //is used to wait for a response from USB. Returns true when bytes become available, false if it times out. boolean waitForResponse(String errorMsg){ boolean bytesAvailable = true; int counter=0; while(!USB.available()){ //wait for CH376S to verify command delay(1); counter++; if(counter>timeOut){ Serial.print("TimeOut waiting for response: Error while: "); Serial.println(errorMsg); bytesAvailable = false; break; } } delay(1); return(bytesAvailable); } //getResponseFromUSB================================================================================ //is used to get any error codes or messages from the CH376S module (in response to certain commands) byte getResponseFromUSB(){ byte response = byte(0x00); if (USB.available()){ response = USB.read(); } return(response); } //blinkLED========================================================================================== //Turn an LED on for 1 second void blinkLED(){ digitalWrite(LED, HIGH); delay(1000); digitalWrite(LED,LOW); } |
If you copy and paste this code directly into the Arduino IDE; you may get a warning like this when you compile the code:
"Low memory available, stability problems may occur".
I managed to run the sketch without any issues, however, I did experience problems with some of the methods when I had
made further memory hungry modifications. If you do encounter problems, I would recommend that you eliminate any
methods which you do not plan to use, and perhaps reduce the number of Serial.print statements throughout the code.
However, please note that some of the methods will not work unless the module is in the correct state, so be careful which methods you delete.
For example, I found that I could get some simple functionality without the "USBdiskMount()" method. However, I could not
read/write data beyond a certain length without this method.
Also please note, that some of the methods called within the reading and writing sequence
do not need to be called every time. They can be called once in setup, while other methods within the sequence will need to be called every time.
I grouped them all together for simplicity.

Serial Commands
Have a look at the following presentation for a summary of the Serial commands used in this tutorial:
Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.
However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.
Sir is it possible to copy a file from 1 flash drive to another using two ch376s and arduino atmega 2560? Thanks. I hope for your response
ReplyDeleteHi Cris,
DeleteI guess it is possible, but not sure why you wouldn't just use a computer ?
I have not tested this with anything but "*.txt" files. I don't know if you can copy any file type??
There isn't much information about this module on the internet at the moment, so sorry for my vague answers... if I get a chance, I might try this, but it might be a while until I get round to it.
Because i wish to make a portable file transfer device for a project using two of ths chips.
ReplyDeleteThanks anyway! :)
That makes sense Cris. What kind of files?
DeleteAll types of files.or at least ms offi e type of files.i have ch375b right now.
DeleteDid you get it to work ?
DeleteYou don't need anything special for this, just two modules and a MCU with two UARTS.
DeleteJust read one file bytes and send them to write to the other module.
Hi Cris,
DeleteWere you able to make a portable file transfer device? If yes, please help me out.
Hi Cris,
DeleteWere you able to make that portable file transfer device . If yes then please reply me on shailesh.welcome@gmail
Nice Job. Thank you
ReplyDeleteI have a question.
It's possible to write a file to usb key without user interaction.... for example.
Starting without an usb inside the module, i put in the usb disk and automatically the code inside arduino intercept the event and write the file.
Thanks
Luca
Hi Luca,
DeleteOnce you put the module into USB mode (i.e Command Sequence #2),
you can see from the video around (3:12), that the module will monitor the USB port.
So when you insert a USB drive into the module, it will send (0x15) to the Arduino.
It will also notify the Arduino when the USB is removed by sending this byte code (0x16)
Here is the link to the relevant part of the video which shows this in action:
VIDEO LINK
Once you receive this command within the Arduino, you can then get it to do whatever you need it to.
Hi
ReplyDeletei want to use a barcode scanner to get the barcode number and use that number to open an image with the same name. is this doable?
if so how?
Hi Anonymous,
DeleteI have not tried to open an image with this module, but I assume that it is possible, providing you have the necessary hardware to display the image. There are so many ways you could tackle this project. Is it doable? I guess yes, but it depends on how you want to do it. The things you would have to think about are:
1. Is this a portable project ? Connected or not connected to a computer?
2. How do you plan to display the image?
3. What is the size and format of the image?
4. The format of the barcode? Can you decipher it?
5. What modules you have or plan to buy?
6. The memory limitations of the Arduino and which Arduino you plan to use?
7. Powering the project (including the barcode reader)
How you would do it , and whether it is possible will depend on your specific project requirements.
I have been looking at this project with interest. I would like to create a portable backup device for a digital camera. Connect the camera to one of the USB boards and a large USB pen in the second USB board.
ReplyDeleteAnybody done anything like this and would like to share experiences.
That would be turtle slow! We are talking about 9600 baud rate! That is sending a picture via IR port, very slow IR port.
DeleteHello sir :) great tutorial...Is it possible to view directories inside the flash drive?Can you give me some suggestion if there is any chip that can accomplish this task as well???
ReplyDeleteHi vindude,
DeleteIt may be possible, but I have not tried it.
It probably will not be straight forward.. and would probably need a bit of programming to accomplish. The only commands available to you are within this document:
http://www.mpja.com/download/ch376ds1.pdf
As for any other chips that are capable - I am not sure either.
Sorry.
yes i have seen document and couldn't find any thing of help,,,if you could come up of something please inform :) thank you
DeleteSure - I will let you know if I ever come across the solution (if there is any).
DeleteCan I power this with 3.3 volts? do you know if i could hook this up to an ESP8266 to make it like a WiFi USB drive?
ReplyDeletethanks
According to the ICStation CH376S U Disk Read Write Module webpage - you can power it with 3.3V. I guess you could make like a WiFi USB drive - but access to the drive may prove challenging. Don't expect a windows like interface.
DeleteBut you could read and write to it just like you would to an SD card.
Greatjog Scott. I have a problem with the CH376EVT board. The board with USB and SD.
ReplyDeleteYour test program works fine on my Arduino Mega. The problem is that my PC cannot see the TEST4.TXT file create on the Arduino and the Arduino cannot see the files TEST2.TXT and TEST3.TXT created on the PC.
The USB drive is a Patriot 32GB drive freshly formatted with FAT32 and 16kB clusters.
Any suggestions?
Thank you
Jon W
Hi Jon,
DeleteTry using a smaller or different brand of USB stick. I am not sure, but there seems to be an issue with some brands. I used a SanDisk USB stick without any problem. Please let me know how you go.
Hi Scott
DeleteGot something figured out: No problem when disk is formatted on Windows XP with default allocation size 4096. Problem when formatted on Windows 10.
Wondering if Windows 10 was causing problems I fired up an old computer with Windows XP. Formatted the Patriot stick and put a TEST2.TXT and a TEST3.TXT on it. Over to the Arduino, ran your test 4 (OK), 8 and 9 (both OK). Now to the Windows 10 PC. All three files visible and readable.
To check if the Windows 10 allocated size of 16k the problem was, I I formatted with 4k and 2k. Both experienced the original problem.
So the formatting on Windows 10 creates the problem.
Do you have any suggestions for a third party formatting program that I can test on Windows 10?
Jon W
Hi Jon,
DeleteThis info is good to know.
According to ICStation, the module supports the FAT32, FAT16 and FAT12 file formats (up to 32GB). So not sure why your attempts to format using windows 10 is causing issues??
This is the only program that I could find on the internet so far:
https://miapple.me/windows-10-format-external-hard-drives-fat32/
I have not tried it so please make sure you do a virus scan (etc etc).
Regards
Scott
I forgot to mention that I use Windows 7 - and have no issues, so not sure whether this issue also exists on Windows 8 ??
DeleteHi Scott
DeleteThe program you suggested works great. Formatted my Patriot stick with both 4k and 16k allocation units and both tests do not show the problem I experienced with the Windows 10 formatter.
To make sure the problem is not related to the 3Gb Patriot stick, I repeated the test with an 8Gb Kingston stick. Same problem: On a stick formatted with Windows 10, files created on the PC are not visible on the Arduino and the other way around. I even tried a 32kb allocation size without problems.
I have no way to test on Windows 8.
My project is a small box to create backups of the pictures on our smart phones and cameras during our long travels.
SD/Stick to SD/Stick. Our Android phones generate long file names containing date and time. The CH376 is not suitable for long file names and walking a directory tree with unknown file names. The CV376EVT will be the output side. Your test as basis will be converted to support the SD functions and SPI interface.
Thanks for creating this great tool.
Jon W
This comment has been removed by the author.
DeleteHello Scott and hello Jon,
DeleteFirst thanks for this tutorial.
I am trying to use the module ch376 controlled by spi using a Pic24 so i rewrote the program. The communication with the module works, i am able to mount the disk and receive response but i am not able to open the file for read. I think i am having a problem related to the usb formatting. I used a unbranded usg 4gb formatted fat32 using windows 7. What specific tool could i use for format the flash drive?
"What specific tool could i use for format the flash drive?"
DeletePerhaps the one mentioned in the comment above ?
Having said that, I did not need to use that program. I just used a new SanDisk USB stick as seen in the pictures/video.
Are you getting any error messages when trying to open the file for reading?
Please read all comments, as some people have identified better methods for reading from the text file.
Hi Sir Scott,
ReplyDeleteI'm a student...I want to create a 'device' that can read the contents of a flash drive and it has a screen to display the files and also can navigate through the existing files....
this device will be connected to a printer and will send a command to a printer to print....
so can I use CH376S for my project? will you give me some help?
it would really be a great help...
-Glen
I have no idea how you would attach your device to a printer, and I have no exposure with that kind of thing. The only help I can give you is within this tutorial - this is all I know..
DeleteHi. I just followed all these instructions, but when I send 1 using serial monitor I get "TimeOut waiting for response: Error while: checking connection". I triple checked wiring. I suspect that my CH376S board is defective. Any suggestions?
ReplyDeleteI don't know why you are getting this error - as that is not programmed into the Arduino Code?? Have you tried using other Serial commands to the Arduino before (without the CH376S module) to see if that part is working ok ??
DeleteThere were some soldering issues. Right now I'm resoldering everything. This is the first, and will be the last time I buy already soldered board :D better to do it myself.
DeleteThanks for your attention, keep up sharing a knowledge. There is a saying in my country, it says knowledge reduces when you dont share and increases when you do.
I think you must have been unlucky. Out of all the pre-soldered boards I have bought, there has only been one or two that have not worked properly. The rest have been fine. But I guess there is a certain level of knowledge gained by soldering it up yourself.. it just depends on how much time you have or are willing to spend doing that. So did you end up getting it to work ?
DeleteI get the same error. It looks like it is in the code in the waitFor Response function called from the checkConnection function. I am stuck at step 1 . What does it want?
DeleteHi Roja, you are right.
DeleteWhen you send a command message to the module, the module will respond with an appropriate response. If it times-out, it will produce the error as stated above, plus it tells you what part of the process it was trying to do at the time it expected a message back from the module. Ensure the connections to the module are correct, and ensure that the commands sent to the module are correct... It expects a certain number of bytes before a response is generated.
hi sir,
ReplyDeletei have a problem in writing process,
when i write my data in file, i get this message in serial terminal:
The CH376S module has been reset!
set_USB_Mode command acknowledged
USB is present
Checking USB disk connection status:
>Connection to USB OK
Mounting USB disk>USB Mounted - OK
Setting filename to:test4.txt
Writing to file:
may name is alex
Data Length:16
Write code (normally FF and 14): 10,14
Closing file:>File closed successfully.
why i get 0x10insted of 0xFF,
please help me,
sorry for my englsih
I am not sure:
DeleteThis is the only technical document that I have access to:
http://www.mpja.com/download/ch376ds1.pdf
Make sure the USB is blank.
DeleteI did experience some bugs during testing, but it was a while ago now, and I cannot remember why they occurred or how I fixed it. But use that document that I listed above. It is likely to help you.
I found an interesting thing. Command returns not 0xFF, it returns the number of bytes written. And what is important: When you record a lot of data, if the next line exceeds the block size of 512 bytes (512 in my case), it is written only that part that fit into the 512 bytes, the rest is cut off.
ReplyDeleteTo avoid this, I changed a little bit recording function. I publish an example of its use:
..........
String senda = "2016,3,22,18,33,NAN,NAN,NAN,NAN,38.0,22.0,0\n";
byte ttl = senda.length();
for (int i=0; i<120; i++)
{
byte sv = fileWriteAppendix(senda); //Write data to the end of the file
if (svwrite(0x57);
USB->write(0xAB);
USB->write(0x3C);
USB->write((byte) dataLength);
USB->write((byte) 0x00);
if(waitForResponse("setting data Length")){ // Wait for an acknowledgement from the CH376S module before trying to send data to it
if(getResponseFromUSB()==0x1E){ // 0x1E indicates that the USB device is in write mode.
USB->write(0x57);
USB->write(0xAB);
USB->write(0x2D);
USB->print(data); // write the data to the file
if(waitForResponse("writing data to file")){ // wait for an acknowledgement from the CH376S module
}
dataLength = USB->read();
USB->write(0x57);
USB->write(0xAB);
USB->write(0x3D); // This is used to update the file size. Not sure if this is necessary for successful writing.
if(waitForResponse("updating file size")){ // wait for an acknowledgement from the CH376S module
}
USB->read();
delay(100);
}
}
return dataLength;
}
I have gotten my code to work as desired and writing to the USB with the Arduino (Mega) still attached to the computer and sending Serial.print statements to the Serial monitor. I have tried to get it to run stand alone by commenting out all of the Serial.print lines. Then it seems to have problems writing and/or skipping write to usb lines. Is there a proper way to modify code so the Arduino can write to the USB unplugged from the computer?
ReplyDeleteThanks Roja
That is a good question. I have never really tested this project with the Arduino's USB cable unplugged from the computer. There are a couple of things that come to mind...
Delete1) Perhaps try to slow down the write speed somehow (e.g by increasing the delay between each line being written) - or any other way you can think of.
2) There may be a grounding/power supply requirement for proper operation. Most of the time when I encounter a difference between connected Arduino and standalone Arduino - it is because of a power supply issue. How are you powering the Arduino when it is standalone? Don't use 9V battery. If you have to use a battery, use 4xAA batteries. But even better, use a power source that is connected to the wall (eg. wall-wart/Plugpack or something similar)http://www.altronics.com.au/p/m8925a-powertran-9v-dc-2a-appliance-plugpack/
I am using a wall transformer 7VDC. I have tried adding in delay statements but nothing works so far. Sometimes it will create a valid file (although missing data) once after I unplug the cable to my computer, and after that it does not work. I need to get this to write reliably while unplugged for my project to function. Thanks,
DeleteRoger
How do I set the device to use hardware serial, since I am using a MEGA board. Maybe that will help?
DeleteI was able to set up the USB module on the MEGA Serial2. No improvement to my problem. I did realize that a successful USB write seems to depend on the IDE serial window being open at the time of the write, not just that the programming cable is plugged in to the computer and the IDE open. What does that mean? Thanks,
ReplyDeleteRoger
I have no idea - perhaps take this one to the Arduino.cc forum. Someone with a bit more knowledge than me may be able to help you. But I don't understand why that is happening?
DeleteI found that if i put the USB in and reset the Arduino, then files will write properly (un tethered from the computer)as long as it is not taken out. Each re insertion of the USB stick requires a reset. Don't know why, but it seems to work.
DeleteRoger
Each time the USB is connected, you probably need to put it through the initialisation sequence - or reset the module?? It has been a while since I used it, but from memory, I thought the module sent a message when a USB was connected and disconnected. Perhaps you could use this to automatically reset/reinitialize?
Deletewould it be possible to read certain data in usb flash disk and use it to trigger the output? and when that data not detected(usb unplug) it will trigger the output to be off with delay.
ReplyDeletehi, i can txt file but this txt file doesn't view on computer. Used space of usb drive increases but i can't see this txt file. why?
ReplyDeleteI don't know?
DeleteMake sure your file name is all caps.
Deletei did all caps but i still same,as well arduino doesn't read txt file created on pc. My purpose, some datas saved usb drive with arduino and i take this datas on pc. is there another method or devices like ch376?
DeleteHi scott, do you have the fritzing sketch?
ReplyDeleteHi Miguel - I don't save my Fritzing sketches - they take about 5-10 minutes to make. I make them from scratch each time.
DeleteHello and thank you for your wonderful job!!
ReplyDeleteI tried the above sketch, I have problem with writing, I got:
COMMAND4: Create and Write to File : TEST4.TXT
----------------------
The CH376S module has been reset !
set_USB_Mode command acknowledged
USB is present
Checking USB disk connection status
>Connection to USB OK
Mounting USB disk
>USB Mounted - OK
Setting filename to:
File could not be created, or it already exists
Closing file:
>File closed successful
there is no file'name after "Setting filename to:", after investigating for a while, I noticed that if wrData is short (just 5 characters) it works, otherwise no.
what's wrong? (using W7-x64, arduino 1.6.9)
thanks
Not sure - that might be a limitation of the module... I have no idea. Perhaps there is something within this document that may help you?
Deletehttp://www.mpja.com/download/ch376ds1.pdf
See the section named: "5.15. CMD_SET_FILE_NAME"
Hello! Maybe you have some sample code for CH375B?
ReplyDeleteNo - unfortunately not.
DeleteHave never come across the CH375B before, but I am guessing that you would operate it in a similar way??
This may help: ftp://imall.iteadstudio.com/Modules/IM131009001/DS_IM131009001.pdf
File Size Definition procedure is incorrect.
ReplyDeletePlease, replace everywhere
int fs = getFileSize(); //Get the size of the file
to
unsigned long int fs = getFileSize(); //Get the size of the file
and
unsigned long int getFileSize(){
unsigned long int fileSize=0;
Serial.println("Getting File Size");
USB.write(0x57);
USB.write(0xAB);
USB.write(0x0C);
USB.write(0x68);
delay(100);
Serial.print("FileSize =");
if(USB.available()){
fileSize = fileSize + USB.read();
}
if(USB.available()){
fileSize = fileSize + (USB.read()*256);
}
if(USB.available()){
fileSize = fileSize + (USB.read()*256*256);
}
if(USB.available()){
fileSize = fileSize + (USB.read()*256*256*256);
}
Serial.println(fileSize);
delay(10);
return(fileSize);
}
Thanks anonymous,
DeleteYou could have just said to change all ints to unsigned longs
But still, thanks for the feedback...
Not only change all ints to unsigned longs, but change
ReplyDelete...
(USB.read()*256*256*256);
...
instead
...
(USB.read()*255*255*255);
...
Thanks
Excellent - Thanks Anonymous - I missed that in your original post.
DeleteThanks for picking this up.
Hello, I use ch376s module to save data into USB memory stick but using this, I have some difficulties
ReplyDelete1st, now I save data in main root of USB memory but I'm trying to make a folder in main root and make files in that folder. So, I wonder how I can make folder and create file to save data.
2nd, now I make a file using writeFile function and through appendFile function, write data sequentially. Size of one data is 21 byte and I save data in alternate lines.
But when arduino send 100 of data, only 80 of data are saved in USB memory. So, I wonder what reason of this data loss
Thank you .
1. Don't know how to make folders on this module... so cannot help you.
Delete2. Don't know why it is not saving all of your data.
Sir I have problem about why after power connecting ch375 module & i am insert usb pen drive but not turn on ch375 module led how to power on module???
ReplyDeleteHi Ravindra,
DeleteYou have to send a few commands to the CH375 module before it starts monitoring the USB port. Try commands 1 and then 2 as described in the tutorial above - please watch video for demonstration.
Hello Scott,
ReplyDeleteI've found about your page while trying to solve issues with my CH376 module.
I can create, write, edit directory info (file date) without error but when looking at the result on a computer, created files are visible but of size 0 byte and cannot be opened by windows ("file not found" error when clicking on the file). More over, the file date is 2004 which means the directory info edit wasn't too effective.
I've dumped the flash drive data (raw data of the flash memory) and I can see the file data is actually saved to the flash drive but failed to be connected to the directory data.
I've tried with three flash drives of different capacity, state and manufacturing date, same issue.
Is that something you experienced before? I would expect such IC to have much greater compatibility than this. So far it's 0% compatibility for me. I'm sort of thinking that module is glitchy/junk and I wonder if any alternatives available.
Thank you.
Daniel
Hi Daniel,
DeleteI know that you have to do each task in a particular order, otherwise it has issues. Also I think it has issues with some file names. I cannot really remember because it has been a long while since I have done this tutorial. Also - have you tried creating a blank text file in windows and then try to append to that file... does that work ?
There may also be some stipulation with regard to the file format used on the USB stick (FAT16 and FAT32??). You may need to format the USB drive in this file format ??
What message are you getting from the Serial monitor when writing to the USB stick?
And lastly, I think there are some slightly different models floating around on the internet, which look "almost" identical, but are not. I got mine from ICStation - you can find the link in the "Parts Required" section of this tutorial.
It is reading, writing and appending TEST4.TXT on serial window but not creating text file on pendrive.
ReplyDeletethat right, it not creating text file. it say "File could not be created, or it already exists". any solution? tq.
DeleteCOMMAND4: Create and Write to File : TEST4.TXT
----------------------
The CH376S module has been reset !
set_USB_Mode command acknowledged
USB is present
Checking USB disk connection status
>Connection to USB OK
Mounting USB disk
>USB Mounted - OK
Setting filename to:
File could not be created, or it already exists
Closing file:
>File closed successfully.
Maybe it already exists ?
DeleteMaybe try deleting the file and then creating it again.
Hello, have you tried writing (saving into the USB drive) for several times (> 10 times) and check if there's any data missing?
ReplyDeleteI've faced this problem that my data went missing (15 characters sent, left 10... returning error code 0x1E) if I save it for more than 10 times.
I tried to reduce the number of characters.. but still, the problem did not go away.
Are you [opening file, saving characters, closing file] on each occasion?
DeleteWorks or Not works ?
ReplyDeleteI wan to use it
It worked for me.. But I guess it depends on your particular application.
DeleteHi Scott,
ReplyDeleteI wanna use this code by Arduino mega2560
at the first step I receive this Error:
COMMAND1: CHECK CONNECTION
----------------------
TimeOut waiting for response: Error while: checking connection
Is there anything that I should changed when useing Mega 2560??
If you are using the Arduino Mega, then there is probably no need to use Software Serial. The Mega has three additional serial ports. It would probably be better if you used them.
DeleteSee:
https://www.arduino.cc/en/reference/serial
So you would need to change this line (and all the lines related):
SoftwareSerial USB(10, 11);
You would use one of the other Serial pins instead.
hai sir,
ReplyDeletei really use your artcle,
i have small clarification if i use any another micro controller is it work? except arduino
I assume so. Providing that microcontroller is capable of Serial communication with other modules.
Deletethank you sir,
Deleteis it available ch376s module ic in market.i didnt found if have that please forward link.or details about that.
The module link is in the "Parts List section". But where would you get the IC on it's own?... have no idea. But Google might.
Deletehi scott,
ReplyDeleteI get problems if i read data longer than 40 bytes.
You wrote :
"//continue to read the file : I could not get this function to work as intended."
Does this mean it is not possible ?
No - it does not mean that it is not possible. It just means that I could not figure out how to do it?? Hoping that someone out there figures it out and lets me know :)
DeleteHi, probably i can help if you don`t found the solution yet. But i still experimenting with the code.
DeleteThanks - that would be great. Yes - please let me know.
DeleteWhat i found, the problem is in read data function(0x27) and in reading sequence.In the read data function the first incoming byte is the lenght of data block.That means if your request is 64byte but you get 8byte data block lenght then you request just 8 bytes instead of 64. The sequence is incorrect. 1,Set bytes to be read(0x3A) -- 2,Read data(0x27) -- 3,Update pointer for reading(0x3B).
DeleteThe CH376 chip read the data to buffer(512 byte), that 512 byte we read out with 1(0x3A), 2,(0x27) and when the last byte is read out then we call 3,(0x3B) that command load the next 512 byte to buffer and we start again the 1,2 sequence. I hope is it understandable :) . If not then i can draw some flowchart
I think I understand what you mean. But if you could draw a flowchart, I think it would be very helpful. Thank you for your insight.
DeleteMaybe is it better if i attach the code.
Delete//input byte number request to read, power of 2
void CMD_BYTE_READ(byte b_num){
int i_step = 0;
int i_stepToEnd = 512/b_num; // after that steps we need to request a next 512 byte in to the buffer
boolean b_read = true;
do {
if((i_step == i_stepToEnd)){
sendCommand(0x3B); // request the next 512 byte to the buffer
adatUsbTol(); // wait for data from CH376
i_step = 0;
}
b_read = requestByte(b_num); // 0x3A
CMD_RD_USB_DATA();
i_step ++;
} while(b_read);
CMD_FILE_CLOSE();
}
byte CMD_RD_USB_DATA(){ // read from CH376 and send it out over serial
sendCommand(0x27);
byte adatHossz = adatUsbTol(); // the first byte shows the bytes number which is allowed to read
byte szamlalo = 0; // counter
while(szamlalo < adatHossz){
Serial.print(char(adatUsbTol()));
szamlalo ++;
}
return adatHossz;
}
Thanks Gyorgy,
DeleteOk - I think I understand what you mean now.
This should help others looking to read large amounts of data.
One day I may go back and revisit and test it out.
Thank you for solving this piece of the puzzle.
Hi, Thanks much for this tutorial. Best resource I got so far regarding the possibility of file transfer from my data logger into a stick drive. Multiple resources regarding data logging in SD but all sketches I looked into so far are either real-time monitoring hooked in a computer, or practically prying out the SD Card from the data logger shield and then reading it via usb/SD adapter. My project would require placing the arduino and data logger et al hardware in a semi-permanent enclosure. It would store time/temperature data of a usual 3-4 hour cycle. From your point of view Scott, would it be possible to insert a SD stick in a USB port and the sketch inside the arduino automatically copy/transfer files from the SD card in the data logger. This would eliminate the need to open up the enclosure and pull out the arduino and pry out the SD card from the data logger, every 4-hour cycle or so. Would greatly appreciate your insight on this, and maybe guidance to get me to the right direction.
ReplyDeleteHi Nestor,
DeleteI think it would be good to include a button in the Arduino sketch to signal your intention to copy the data. But I think it should be possible to transfer the data from the SD card to the USB thumb drive. However, I have never done that myself - so I am just speculating.
Hi, really a great job. I want to implement this. I want to send data available on serial monitor of master arduino to slave arduino using this. I dont want to write to any file just want to send data from master to slave. Is it possible to do so..?
ReplyDeleteYes - it is possible to send data from master Arduino to slave Arduino. However, I would ask you to please post questions about your project in the forum. Thanks
DeleteHi Scott, thank you for sharing!
ReplyDeleteI'm trying send use the same chip (ch376s) to tansfer data from atmegaxxx(I didnt choose which module yet) to usb memory stack and PC. so can I do this, and I need in the code in order to be able to trasfer data to PC via ch376s?
Hi Samah,
DeleteI am not clear on what you are trying to do.
If you want to transfer data from the Arduino to PC, then just transmit it to the PC using Serial commands and have the Arduino connected via USB. Depending on your setup, you could also do this via ethernet cable, bluetooth or wifi (etc).
In the tutorial above, I show you how to read from the USB stick and transmit it to the computer, which is what I think you are asking how to do ??
Hey! thank you for the reply
DeleteI want my atmega to standalone so I can't use the serial port of Arduino, on other hand, I want to use ch376s chip for two purposes; the first, to use it in USB-Host mode to transfer data to usb disk; the second, to use it in USB-Device mode to communicate with PC and transfer data. My question is: is this possible? and if yes, how can I do it? Because in your code, you mentioned that you sent 0x06 to the chip to activate usb-mode,but according to the datasheet, this activate the USB-Host mode, so logically and according to the same datasheet, I only need to send 0x01 or 0x02 (I'm not sure which one is the right one) to the chip in order to turn the chip to USB-Device mode and start the communication between PC as host, and atmega as a device. So again! is this possible?
Hi Samah,
DeleteIt may be possible, but I am not sure. But you could try and see.
These documents may help:
http://wch-ic.com/download/CH372DS1_PDF.html and http://wch-ic.com/download/CH372DS2_PDF.html.
The datasheet in the tutorial seems to mention compatibility with CH372 when using it in USB-Device mode. Hence the reason I have pointed to those datasheets in my comment above.
What I am not sure, is whether this module is set up for that mode or not. There is very little documentation out there, and I was lucky enough to find what I did.
Another useful source of information on this board is this video on youtube: https://www.youtube.com/watch?v=nafG8N6iefU
Sorry - this is about as much help as I can provide.
I am not an expert on this module or chip, I just read the datasheet and experimented until I got my project to work.
I don't know if the manufacturer has a team that you can contact for further information or help??
thank you for your help, I guess I only have the datasheet to answer my question!
ReplyDeleteThe datasheet is where I find most of my answers, so you are not alone there. You could also try asking the manufacturer as previously suggested, or alternatively trying your luck on the Arduino forum.
Deletehttps://forum.arduino.cc/
Hi
ReplyDeleteCan we connect serial cable to this module like your fdti or cp2102 chip
I can't see why not?
DeleteHello,
ReplyDeleteI am currently working on a few projects involving a SD card, and one with the CH375. I’ve had trouble getting my code to work so far. In the case of the CH375 I am talking to it via a parallel bus and believe the basic communication is working. I can send one of the commands which then triggers an interrupt, and then read the status and see the interrupt signal go in-active. Every time the status is 22 hex.
I’m wondering if part of my problem could be the FAT issue - all of the USB drives I’ve tried were formatted on my Windows 10 PC. I saw mention of the program you used to format a drive to one of the earlier FAT standards. Can you tell me what the exact program name is ? At the link you gave, there is mention of two programs ... so, I just want to make sure I am getting the one you said worked for you.
I did a little search and found this link which explains how to do the format at the DOS command prompt using the MS DISKPART command. I tried it with my SD card project - but still haven’t achieved success. Haven’t had time to use if on my USB drives and my CH375 project.
Here is the link:
http://www.instructables.com/id/Format-USB-Flash-Drive-to-FATFAT16-not-FAT32/
Thanks !
Hi Dave,
DeleteI don't remember having to format the USB Flash drive, but know from the datasheet that it only supports FAT16, FAT32 and FAT12 filesystems. I think there is a link in the comments above that mentions a particular program that you can use, but I have never tried it and cannot verify if it even works... so take normal internet precautions with that one (i.e. Virus scan etc).
My only advice is to try one step at a time, get the basics working, ensure you are getting a response from the module etc. And then increase the functionality from there.
Datasheet URL:
http://www.thaieasyelec.net/archives/Manual/CH376DS1.PDF
I also came across this site: which may help some people:
http://blog.csdn.net/ex_net/archive/2010/01/17/5201941.aspx
Hi Scott
ReplyDeletecan you please give a short tutorial to interface serial cable(cp2012 or ftdi) with ch376s module. please do the needful
greatly appreciate your support.
Hi touseef.
DeleteMaybe one day, but unlikely to be in the near future.
I have moved on to other projects.
But if I had to do it, I would,
1) First learn how to communicate to modules using serial cable.
2) Transmit the serial code as per the datasheet or tutorial.
3) I would probably need to work out what software is required to transmit the necessary code.
It should not be too hard to adapt, but I don't have the time for that particular project right now. Sorry.
Hello,
ReplyDeleteActually im working on Arduino Uno microcontroller and i'm trying to control a vidéo USB Module.
To do that i am using an USB module CH376s which will be the bridge between the Arduino and the Video Module.
Actually the video module is considered like an USB key when i plugeed it to the computer i cant put any folder inside and when i put a video folder and eject (unmount) the module the video is played.
so i'm trying to do that using the arduino but i get a problem, when i try to create a file on the video module i lose the mount.
and what is bizzar to me is that when i stop in the mount step and i don't do anything else the module still mounted but when i send any command via the USB module (CH376) i lose the mount.
when i do the same steps for a normal USB key i don't get any problem.
That's it i'm bloqued and i can't figure out the problem i hope that you get a little idea about my problem and i hope you could help me.
PS : regarding the ch376 datasheet it suport UFI command but i don't know how i could send UFI command through the CH376;
MOMO - sorry - I have no idea.
DeleteMy knowledge is contained in the tutorial.
I haven't done anything more than what you see right here.
The datasheet is the only guide I can point you to.
Unfortunately, the datasheet is not that clear.
Is it possible to get file file and directory names?
ReplyDeleteI think so. This is the document I used to work out the commands for my project.
DeleteI am pretty sure there is a command to enumerate the files and folders in a specified directory.
can u provide the code for ch375b interfaced with arduino uno for sectoerwise read write on usb flash drive
ReplyDeletehola, tengo un problema..., me comunico con la placa.., pero me responde lo mismo...!!!
ReplyDeleteno idea
DeleteI tried to use the module with a pendrive formated in Win7 and all commands were ok, but in windows the file cant see When I format the pendrive in winXp the code works perfect. I used many brands include Kingston for test. But Just WinXP format works...
ReplyDeleteAny idea ?
I have heard some people describing this anomaly. But have no idea why it would happen.
DeleteI used windows 7 without any issues. I have heard some people having issues using Windows 10. But again, I don't know why. Perhaps a hex editor may reveal a possible answer???
I just bought that module....I connected 5v gnd txd rxd to arduino...but my ch376 module wont power up....led is not glowing after i inserted pendrive too....i send the command 1 thru serial monitor it replays msg like this
ReplyDelete======================
COMMAND1: CHECK CONNECTION
----------------------
TimeOut waiting for response: Error while: checking connection
Is it possible to interface a USB mouse with this module
ReplyDeleteNot that I am aware of
Deletehi how can we change a file name (rename) in the usb memory ?
ReplyDeletehi i have this module but in rx , tx ,gnd pins , it have diiffrence
ReplyDeletethere are 6 pins with a jumper . ineed help :(
merry xmas :))
I guess you would have to look for the appropriate data sheet.
DeleteI have 6pin module.
DeleteI tried and worked well.
remove the jumper. hold the module to up side usb base.
left up pin to uno 11
right middle to uno 10
uno 11 -- 11 --usb base---
11-- uno 10
11
hi, I have tested this successfully. working perfectly. thank you.
ReplyDeleteI want to read line by line.
I have to check each line.
How can I do this?it should pause the reading the file while I am checking the line.
I tried several methods. when i checking it is still buffering more data.
please help me.
and I have found the connection for different module that has 6 pin with jumper.
here it is
I have 6pin module.
I tried and worked well.
remove the jumper. hold the module to up side usb base.
left up pin to uno 11
right middle to uno 10
uno 11 -- 11 --usb base---
11-- uno 10
11