USB flash drive - how to check mnt directory

Hi all.

I am a noob when it comes to Linux so please keep that in mind.
I’m working on a project that reads sensor data from 6 accelerometers using RPi 4B running DietPi and a custom C program. Right now I’m storing data on SD card. What I want is for the end user to get data on his Windows PC as easily as possible so I was thinking of saving data as it gets recorded to USB flash drive (as txt file). End user wants a simple procedure: record data on a flash drive, import it to Matlab, do analysis.
I am thinking of 2 ways how could this be done but I don’t have the knowledge (yet) to implement it into my project:

1.) In C program do a function that checks if flash drive is inserted and then stores data on a flash drive which is FAT/NTFS formatted. There are 2 issues here: I don’t know how to check if flash drive is inserted on Linux in C and second can I save data to FAT/NTFS formatted flash drive?

2.) Write a script that copies previous file to the flash drive when new file is created.

Any pointers would be helpful.

Hi,

many thanks for your request. Does this RPi4B is connected to a network? Is it accessible from the windows clients?

No, it will be used outdoors without option of any network. I’m kind of using that now in the lab as I program rpi over ssh and I’m constantly downloading files to my laptop. Flash drive is also preferred option by end user.

maybe this could help

https://www.raspberrypi.org/forums/viewtopic.php?t=39234

I tried this method and it works for my needs:
https://www.raspberrypi.org/documentation/configuration/external-storage.md