Saving To File

Hello everyone. I can successfully save a barcode payload to the SD card on the OpenMV. However, my operating system does not recognize that a file has been saved on the SD card until I reset the open MV. For my application, i want to detect when a new file is present, and then perform an action. I cannot do this correctly because I have to cycle power to the OpenMV camera to recognize that a new file has been created.

Is there a way in Micropython to save to the desktop of the computer that the Open MV is plugged into via the USB? Or, is there a way around having to restart the OpenMV to detect that a new file has been saved to the SD card?


Desktop OSes won’t rescan the flash drive unless plugged in. There’s no fix for this. The camera acting as a USB drive which can create files is not something handled by today’s desktop OS drivers.

You can however manually reset the OpenMV Cam in your script by issuing this command:


An alternative method is just to print out the bardcode value. Anything that opens the OpenMV Cam’s VCP UART will see the print data as text as whatever baud rate they open the OpenMV Cam serial port at. Note that you have to disconnect OpenMV IDE. But, it’s pretty easy to get your script working with print and be good… and then use another program to read the printed data.

What OS do you have? I am on a Mac with macOS High Sierra.

This is what I did. I wrote a program that prints the output:

import pyb

    print("Hello, World")

I saved that to the camera then reset the camera.

I then found out the serial device name. You can do that through OpenMV IDE or by running

ls /dev/cu.*

and finding the USB port.

I used the command

screen /dev/cu.usbmodem1411 115200

to connect to my camera and verified it was printing to that serial port. (Use CTRL-A, then CTRL-\ to quit)

Next, I Google’d how to pipe a serial port and found this: macos - Piping from serial port on Mac OS X - Super User
(There is also using an app called miniterm, but I didn’t try that.)

After some failed attempts, I was able to compile the code using XCode. I created a new project targeted for macOS and pasted the code into the main.cpp file and built the app. In the file viewer on the right I found the executable, found the location and copied it to my directory.

Then run the command

./comm3 /dev/cu.usbmodem1411 115200 > serial_outfile.txt &

. (My project was named “comm3” hence the name of the executable.) I’m piping the output to serial_output.txt and letting that run in the background.

I can then run

tail -f serial_outfile.txt

to watch the file being written.

Hopefully this helps.