I have a project that can read data coming from a serial port, which is a CO2 detector, and save this data to an SD card. At the end of this phase of reading and saving data from the CO2 detector, I want to transfer these saved files from the SD card to the USB stick.
Is it possible to do this? I've researched, but I couldn't determine its feasibility.
I tried that kind of research. But it is not just a "USB stick + Arduino". It's a "USB stick + Arduino + SD Card". And I guess that formation of setup is kind of complicated.
Yeah, it's possible, just might be a bit tricky. Here are my quick thoughts on how you could do it.
Have the SD card on the SPI bus, like normal.
Have the CH375 connected to one of the 3 spare hardware UART ports on the Mega. The CH375 could go on the same SPI bus as the SD card, but the benefit of having it connected to a UART is that you wouldn't have to continually open and close the files when you switch from one slave to another.
Open the text file on the SD card and transfer all the data into a temporary buffer on the Mega. Depending on how large the text files are, you might need to have it transferred in multiple packets.
Then write the temporary buffer to the CH375 module.
I will try that tricky solution. It sounds like it will work. My setup can create approximately 100 kb each run of my cycle duty. I can transfer that file to a USB stick from the temporary buffer as you said.
So each file will be around 100 kilobytes max in size? You will have to split that into multiple transfers then, as the mega will not have enough enough SRAM to store the whole file in the buffer. Shouldn't be too hard though.