{"id":23315216,"url":"https://github.com/microbit-foundation/microbit-connection","last_synced_at":"2026-03-15T01:31:29.551Z","repository":{"id":268783256,"uuid":"826808862","full_name":"microbit-foundation/microbit-connection","owner":"microbit-foundation","description":"JavaScript package for micro:bit web browser connectivity (WebUSB, Web Bluetooth)","archived":false,"fork":false,"pushed_at":"2026-01-19T12:28:24.000Z","size":242,"stargazers_count":2,"open_issues_count":12,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-19T19:38:45.072Z","etag":null,"topics":["bluetooth-le","microbit","webusb"],"latest_commit_sha":null,"homepage":"https://microbit-foundation.github.io/microbit-connection/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microbit-foundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-10T12:22:03.000Z","updated_at":"2025-08-28T08:41:09.000Z","dependencies_parsed_at":"2024-12-18T22:34:06.017Z","dependency_job_id":"26cb5025-524e-4856-b906-592b4186a38f","html_url":"https://github.com/microbit-foundation/microbit-connection","commit_stats":null,"previous_names":["microbit-foundation/microbit-connection"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/microbit-foundation/microbit-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fmicrobit-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fmicrobit-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fmicrobit-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fmicrobit-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microbit-foundation","download_url":"https://codeload.github.com/microbit-foundation/microbit-connection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microbit-foundation%2Fmicrobit-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28671261,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T20:48:19.482Z","status":"ssl_error","status_checked_at":"2026-01-22T20:48:14.968Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth-le","microbit","webusb"],"created_at":"2024-12-20T15:33:10.201Z","updated_at":"2026-01-22T21:06:04.428Z","avatar_url":"https://github.com/microbit-foundation.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro:bit connection library\n\n\u003ca href=\"https://microbit-foundation.github.io/microbit-connection/\" class=\"typedoc-ignore\"\u003eThis documentation is best viewed on the documentation site rather than GitHub or NPM package site.\u003c/a\u003e\n\nThis is a JavaScript library for micro:bit connections in browsers via USB and Bluetooth.\n\nThis project is a work in progress. We are extracting WebUSB and Web Bluetooth code from the [micro:bit Python Editor](https://github.com/microbit-foundation/python-editor-v3/) and other projects. The API is not stable and it's not yet recommended that third parties use this project unless they are happy to update usage as the API evolves.\n\n[Demo page](https://microbit-connection.pages.dev/) for this library.\n\n[Alpha releases are now on NPM](https://www.npmjs.com/package/@microbit/microbit-connection).\n\n[micro:bit CreateAI](https://github.com/microbit-foundation/ml-trainer/) is already using this library for WebUSB and Web Bluetooth.\n\n[This Python Editor PR](https://github.com/microbit-foundation/python-editor-v3/pull/1190) tracks updating the micro:bit Python Editor to use this library.\n\n## Usage\n\n### Flash a micro:bit\n\nInstantiate a WebUSB connection using {@link createWebUSBConnection} class and use it to connect to a micro:bit.\n\n```ts\nimport { createWebUSBConnection } from \"@microbit/microbit-connection\";\n\nconst usb = createWebUSBConnection();\nconst connectionStatus = await usb.connect();\n\nconsole.log(\"Connection status: \", connectionStatus);\n```\n\n{@link ConnectionStatus | Connection status} is `\"CONNECTED\"` if connection succeeds.\n\nFlash a universal hex that supports both V1 and V2:\n\n```ts\nimport { createUniversalHexFlashDataSource } from \"@microbit/microbit-connection\";\n\nawait usb.flash(createUniversalHexFlashDataSource(universalHexString), {\n  partial: true,\n  progress: (percentage: number | undefined) =\u003e {\n    console.log(percentage);\n  },\n});\n```\n\nThis code will also work for non-universal hex files so is a good default for unknown hex files.\n\nAlternatively, you can create and flash a hex for a specific micro:bit version by providing a function that takes a {@link BoardVersion} and returns a hex.\nThis can reduce download size or help integrate with APIs that produce a hex for a particular device version.\nThis example uses the [@microbit/microbit-fs library](https://microbit-foundation.github.io/microbit-fs/) which can return a hex based on board id.\n\n```ts\nimport { MicropythonFsHex, microbitBoardId } from \"@microbit/microbit-fs\";\nimport { BoardId } from \"@microbit/microbit-connection\";\n\nconst micropythonFs = new MicropythonFsHex([\n  { hex: microPythonV1HexFile, boardId: microbitBoardId.V1 },\n  { hex: microPythonV2HexFile, boardId: microbitBoardId.V2 },\n]);\n// Add files to MicroPython file system here (omitted for simplicity)\n// Flash the device\nawait usb.flash(\n  async (boardVersion) =\u003e {\n    const boardId = BoardId.forVersion(boardVersion).id;\n    return micropythonFs.getIntelHex(boardId);\n  },\n  {\n    partial: true,\n    progress: (percentage: number | undefined) =\u003e {\n      console.log(percentage);\n    },\n  },\n);\n```\n\nFor more examples of using other methods in the {@link MicrobitWebUSBConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).\n\n### Connect via Bluetooth\n\nBy default, the micro:bit's Bluetooth service is not enabled. Visit our [Bluetooth tech site page](https://tech.microbit.org/bluetooth/) to download a hex file that would enable the bluetooth service.\n\nInstantiate a Bluetooth connection using {@link createWebBluetoothConnection} class and use it to connect to a micro:bit.\n\n```ts\nimport { createWebBluetoothConnection } from \"@microbit/microbit-connection\";\n\nconst bluetooth = createWebBluetoothConnection();\nconst connectionStatus = await bluetooth.connect();\n\nconsole.log(\"Connection status: \", connectionStatus);\n```\n\n{@link ConnectionStatus | Connection status} is `\"CONNECTED\"` if connection succeeds.\n\nFor more examples of using other methods in the {@link createWebBluetoothConnection} class, see our [demo code](https://github.com/microbit-foundation/microbit-connection/blob/main/src/demo.ts) for our [demo site](https://microbit-connection.pages.dev/).\n\n## License\n\nThis software is under the MIT open source license.\n\n[SPDX-License-Identifier: MIT](LICENSE)\n\nWe use dependencies via the NPM registry as specified by the package.json file under common Open Source licenses.\n\nFull details of each package can be found by running `license-checker`:\n\n```bash\n$ npx license-checker --direct --summary --production\n```\n\nOmit the flags as desired to obtain more detail.\n\n## Code of conduct\n\nTrust, partnership, simplicity and passion are our core values we live and\nbreathe in our daily work life and within our projects. Our open-source\nprojects are no exception. We have an active community which spans the globe\nand we welcome and encourage participation and contributions to our projects\nby everyone. We work to foster a positive, open, inclusive and supportive\nenvironment and trust that our community respects the micro:bit code of\nconduct. Please see our [code of conduct](https://microbit.org/safeguarding/)\nwhich outlines our expectations for all those that participate in our\ncommunity and details on how to report any concerns and what would happen\nshould breaches occur.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobit-foundation%2Fmicrobit-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrobit-foundation%2Fmicrobit-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrobit-foundation%2Fmicrobit-connection/lists"}