Problem with SDCard

I’m having some problems creating files on an SD card. I’m using a Niclavision with OPENMV 4.5.1 software. My system collects the values from the IMU at a frequency of 104Hz. It stores the data in array and after two seconds stores the data in a new .txt file on an SD card.

However, I have a few problems:

  • Firstly, each new cycle a new text file is created on the SD card. The more time passes, the longer it takes to create this text file in the SDcard. Are there any solutions to this problem? I got the same probleme when i save à picture into the SDcard with

  • When I try to use os.umount(path), an error is displayed: “AttributeError: ‘VfsFat’ object has no attribute ‘umount’”.

  • Finally, the /vsfat library for vsfat.mount and vsfat.umount is available on openMV?

If you have any idea how to solve the probleme, thank you in advance.

Here is my code :


      #Init timestamp
      if(Valuetime ==1):
            tick = time.ticks_ms()
            Valuetime =0

      #Store IMU data into array
      if INT_MODE:
            if INT_FLAG:
                RTCAccGyr = rtc.datetime()

                INT_FLAG = False

      #After 2seconds store the data into a txt file
      if(time.ticks_ms() - tick >= 2000):
                 for x in range(len(ACCX)):
                     Total = '{:>8.3f},{:>8.3f},{:>8.3f},{:>8.3f},{:>8.3f}  {:>8.3f}  {:>8.3f} {:>8.3f}  {:>8.3f}  {:>8.3f} \n'.format(Heure[x] , Minute [x] , Seconde [x] , Milliseconde[x], ACCX[x] ,ACCY[x],ACCZ[x],GYRX[x] ,GYRY[x],GYRZ[x])

                 fn = "/sd/GyrAcc"+str(i)+"_.txt"

                 #Write IMU data into SDCARD
                 with open(fn, "w") as f:

                 List = list()
                 ACCX = array.array('f')
                 ACCY = array.array('f')
                 ACCZ = array.array('f')
                 GYRX = array.array('f')
                 GYRY = array.array('f')
                 GYRZ = array.array('f')
                 Heure = array.array('f')
                 Minute = array.array('f')
                 Seconde = array.array('f')
                 Milliseconde = array.array('f')
                 Valuetime = 1



Hi, the NiclaVision doesn’t have an SD card…

So, how are you using it with an SD card?

Are you talking about the internal flash? If so, you never need to unmount it. And yes, FAT Filesystems take longer to operate as you create more files in a directory. If you want things to be faster, you need to use folders to have a tree-like structure.

Almost every operation has to scan the folder you are in to do anything linearly. So, if you have 1000 files in a folder then you have to scan 1000 files to see a name is not in use before creating a new file. etc.

Hello, thank you for your quick reply.
I use an SD card reader that communicates in SPI with the niclavision and allows me to write data inside (I use the SDcard library).

Concerning the use of the os.umount function, is it normal that I get the error indicated on the post above when I want to use it?

Thank you in advance.

Ah… I don’t have experience with the pyb SD card code.

We don’t publish any info on that feature in our documentation as it’s not something we really support. That said, while it is enabled you may use it.

Can you share the code on how you mount/unmount? Alternatively, the MicroPython discord is active and you can get help there on this if you join: Discord

As for the time it takes to access files on the disk, my previous explanation answered that.


Thank you very much your first post was the solution

I wish you an excellent day