Skip to content
Branch: master
Clone or download
Latest commit b226ead Nov 7, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode fixing tasks Apr 20, 2017
.gitattributes missing gitattributes May 30, 2017
.gitignore init support for files Nov 2, 2016
.travis.yml added travis file May 23, 2018
LICENSE.txt init support for files Nov 2, 2016 fixed readme Nov 6, 2018
enums.d.ts updated for v1 Nov 6, 2018
files.cpp updated for v1 Nov 6, 2018
files.ts Correct block display from close to flush Jul 18, 2018
icon.png Added icon Apr 20, 2017
pxt.json 0.10.0 Nov 6, 2018
shims.d.ts updated for v1 Nov 6, 2018
tests.ts updated for v1 Nov 6, 2018
tsconfig.json init support for files Nov 2, 2016

File system driver Build Status

To use this package, go to, click Extensions and search for filesystem.

~ hint

BETA - This package is still under development and subject to changes.



The package allows to read and write files to the @boardname@ flash.


The entire file system content is ERASED when a new .hex file is download onto the @boardname@.


Writing data

  • append text and a new line character
files.appendLine("data.txt", "Hello");
  • append text to the file
files.appendString("data.txt", "Hello");
  • append a number (as text) to the file
files.appendNumber("data.txt", 42);

Reading data

  • send the content of a file to serial


The package allows to save and load number settings based on the file system

  • save setting value
files.settingsSaveNumber("calibrated", 1)
  • read setting value
let calibrated = files.settingsReadNumber("calibrated");

File class

The File class allows to keep a file instance open, manipulate the pointer position and read from the file.

  • open, flush or close the file
let f ="data.txt");
  • write strings or buffers
let f ="data.txt");
  • read data
let f ="data.txt");
let buf = f.readBuffer(64);
let c =;
  • set the cursor position
let f ="data.txt");
let pos = f.position();

Example: Writing accelerometer data

The following program allows to collect accelerometer data and save it in a data.csv file. When the user presses button A, the @boardname@ pauses for 3 seconds, then starts collecting 720 acceleration samples. Each sample is written to the file in a format that can be important by spreadsheet programs (CSV).

let file = "data.csv";
input.onButtonPressed(Button.A, () => {    
    files.appendLine(file, "Time\tAcceleration");
    for (let i = 0; i < 100; ++i) {
        let t = input.runningTime();
        let ay = input.acceleration(Dimension.Y);
        files.appendLine(file, t + "\t" + ay);
input.onButtonPressed(Button.B, () => {

Supported targets

  • for PXT/ microbit
  • for PXT/ calliope



Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

You can’t perform that action at this time.