{"id":20489279,"url":"https://github.com/kaelhem/avrbro","last_synced_at":"2025-07-30T00:34:43.260Z","repository":{"id":47936230,"uuid":"224005361","full_name":"kaelhem/avrbro","owner":"kaelhem","description":"A tool to upload .hex files on Arduino boards with Serial API","archived":false,"fork":false,"pushed_at":"2024-08-30T06:50:22.000Z","size":459,"stargazers_count":20,"open_issues_count":6,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T01:33:54.834Z","etag":null,"topics":["arduino","avr","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kaelhem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-11-25T17:32:33.000Z","updated_at":"2025-02-25T22:53:58.000Z","dependencies_parsed_at":"2025-04-13T16:34:18.663Z","dependency_job_id":"8051b394-08bd-4b0e-9309-39c134477080","html_url":"https://github.com/kaelhem/avrbro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kaelhem/avrbro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelhem%2Favrbro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelhem%2Favrbro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelhem%2Favrbro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelhem%2Favrbro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaelhem","download_url":"https://codeload.github.com/kaelhem/avrbro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelhem%2Favrbro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785861,"owners_count":24144123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["arduino","avr","javascript"],"created_at":"2024-11-15T17:12:07.514Z","updated_at":"2025-07-30T00:34:43.216Z","avatar_url":"https://github.com/kaelhem.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Avrbro\n\nThis library use the [Serial Api](https://wicg.github.io/serial/) available in Chrome (_with experimental flag enabled_) to upload compiled .hex files on Arduino boards without Avrdude, directly from a web page!\n\n\u003e For the moment it works only with stk500v1 protocol. That means it (_should_) works with _Uno_ and _Nano_ boards, but not with _Leonardo_ or _Mega_ boards). An implementation of stk500v2 protocol seems to live [here](https://github.com/Pinoccio/js-stk500)...\n\n## Install\n\n```bash\n# with npm\nnpm i avrbro --save\n\n# or with yarn:\nyarn add avrbro\n```\n\n## Exemple\n\n```js\nimport avrbro from 'avrbro'\nconst { parseHex, openSerial, flash, reset } = avrbro\n\n// Here's just an helper function to use async/await with FileReader...\nconst readFileAsync = (file) =\u003e {\n  return new Promise((resolve, reject) =\u003e {\n    let reader = new FileReader()\n    reader.onload = () =\u003e {\n      resolve(reader.result)\n    }\n    reader.onerror = reject\n    reader.readAsArrayBuffer(file)\n  })\n}\n\nconst flashMyBoard = async () =\u003e {\n  // connect to device using web serial API\n  const serial = await openSerial()\n  if (serial) {\n  \n    // get .hex buffer\n    const response = await fetch('bin/my-firmware.hex')\n    const data = await response.blob()\n    const fileData = await readFileAsync(data)\n    const hexBuffer = parseHex(new TextDecoder(\"utf-8\").decode(fileData))\n    \n    // reset the board\n    await reset(serial)\n    \n    // upload .hex file\n    const success = await flash(serial, hexBuffer, { boardName: 'nano' })\n    if (success) {\n      console.log('.hex file uploaded on board successfully!')\n    } else {\n      console.log('an error has occurred :(')\n    }\n  } else {\n    console.log('operation canceled by user')\n  }\n}\n\nflashMyBoard()\n```\n\n## Api\n\n#### isAvailable()\n\nAllow to know if the serial API is available.\n\n**Returns**: `Boolean`\n\n---\n\n#### openSerial(options)\n\nOpen serial connection with device. _Once called, the browser will open a dedicated modal window to choose the device._\n\n**Params**\n\n- options `object`\n  - baudRate `Number` - defaults to `57600` (*which is ok for nano boards with old bootloader. You can check [here](https://github.com/kaelhem/avrbro/blob/master/src/boards.js) to find the correct baudRate for yours...*)\n  - filters `Array` - a list of objects containing vendor and product IDs used to search for attached devices. Filters contain the following values:\n    - usbVendorId `String` - an unsigned short integer that identifies a USB device vendor.\n    - usbProductId `String` - an unsigned short integer that identifies a USB device.\n\n\n\n**Returns**: `Object` or `null` if cancelled. The `Object` will match `{port, reader, writer}` where:\n  - port `SerialPort`\n  - reader `ReadableStream`\n  - writer `WritableStream`\n\n---\n#### closeSerial(serial)\n\nClose serial connection with device.\n\n**Params**\n\n- serial `object`\n  - port `SerialPort`\n  - reader `ReadableStream`\n  - writer `WritableStream`\n---\n\n#### parseHex(data)\n\nUse Intel HEX file format to parse given data and prepare buffer for upload.\n\n**Params**\n\n- data `Object` - string in ASCII format or Buffer\n\n**Returns**: `Buffer`\n\n---\n\n#### flash(serial, hexBuffer, options)\n\nFlash the device connected on the given serial port with the given .hex file buffer.\n\n**Params**\n\n- data `Object` - string in ASCII format or Buffer Object\n- hexBuffer `Buffer` - the .hex buffer returned by the _parseHex_ function\n- options `Object`\n  - boardName `String` - Name of the target board (_check `src/board.js` to find available names_)\n  - debug `Boolean` - Allow to display logs during flash process\n\n**Returns**: `Boolean`\n\n---\n\n#### reset(serial)\n\nReset board with cycle DTR.\n\n**Params**\n\n- serial `object`\n  - port `SerialPort`\n  - reader `ReadableStream`\n  - writer `WritableStream`\n\n\n## Contributing\n\nContributions in any form are welcome! If you find a bug, please [file an issue.](https://github.com/kaelhem/avrbro/issues)\n\n## License\n\nThis project is licensed under the MIT license. See the [LICENSE file](./LICENSE) for more details.\n\n## Acknowledgements\n\nAll this stuff was made possible thanks to:\n\u003cul\u003e\n\u003cli\u003ehttps://github.com/bminer/intel-hex.js\u003c/li\u003e\n\u003cli\u003ehttps://github.com/jacobrosenthal/js-stk500v1\u003c/li\u003e\n\u003cli\u003ehttps://github.com/noopkat/avrgirl-arduino\u003c/li\u003e\n\u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelhem%2Favrbro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaelhem%2Favrbro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelhem%2Favrbro/lists"}