Working With Files

When you write Python code in CodeSpace it is stored on your CodeAIR filesystem. Your Python code can also create, read, and write files of its own.

You’ve probably noticed when you plug your CodeAIR in to the USB port of a computer that it shows up as a mass-storage device, like a flash drive. This can be really useful! For example, your Python code can log sensor data to a CSV file, which you can later access with a PC through the USB-attached filesystem.

By default the USB-accessible filesystem is read-only, so a PC can’t for example copy new Python files onto the CodeAIR, or edit existing ones. But if you want to do such things, there’s a way to change it so the filesystem can be written to “like a flash drive”. Note that while it’s in this mode your Python code (and CodeSpace) will see the filesystem as read-only. You can’t have it writable from both directions.

The following bootup key-combination will make the filesystem writable as a USB mass-storage device until the next reset of CodeAIR.

  1. Press and hold button B1 and keep holding it down

  2. Briefly press the RST button.

  3. Keep holding button B1 until you hear a short two-tone beep!

  4. Release B1 immediately.

  5. The filesystem is now in USB-writable mode.