Upload compiled hex files to your boards directly from a webpage. (Chrome only)
Try it now without having to install anything at https://dbuezas.github.io/arduino-web-uploader/ (Chrome only, any pc OS. Android, not yet)
Currently supports these boards:
Just add the following to the head of your HTML:
<script src="https://github.com/dbuezas/arduino-web-uploader/releases/download/v1.0.0/main.js"></script>
And add some buttons with their corresponding attributes
<button
arduino-uploader
hex-href="https://github.com/dbuezas/arduino-web-uploader/blob/master/[path to your hex file]"
board="[name of the board]"
[optional]verify
[optional]port-filters='[{"usbProductId":46388,"usbVendorId":1241}]'
>
> Upload blinker to lgt8f328p and verify uploaded code
<span class="upload-progress"></span>
</button>
arduino-uploader
]indicates to the library that it should attach the functionality to this button
hex-href
]is the url of the hex file to upload. Let me know in the issues if you have a use case to let the user select a hex file from their own computer.
board
]can be any of these:
"lgt8f328p"
"nanoOldBootloader"
"nano"
"uno"
"proMini"
(here are the definitions: https://github.com/dbuezas/arduino-web-uploader/blob/master/src/index.ts#L13-L44. You can see that nano, uno and proMini have the same parameters.)
verify
]Is optional, so you can chose to leave that attribute out or write it there. In my experience, uploads never get corrupted and removing verification makes it twice as fast.
(here are the definitions: https://github.com/dbuezas/arduino-web-uploader/blob/master/src/index.ts#L13-L44. You can see that nano, uno and proMini have the same parameters.)
port-filters
]Optional, used to limit the devices shown in the connection popup. To find out the IDs of a device, enter this in the browser console
port = await navigator.serial.requestPort({})
console.log(JSON.stringify([port.getInfo()]))
<span class="upload-progress"></span>
Is a placeholder element where progress percentage will be shown
<button arduino-uploader hex-href="https://github.com/dbuezas/arduino-web-uploader/blob/master/blinker.nano.hex" board="pro-mini">
Upload blinker to pro-mini and don't verify (faster)
<span class="upload-progress"></span>
</button>
see more examples in https://github.com/dbuezas/arduino-web-uploader/blob/master/index.html
use the hex WITHOUT the bootloader.
npm install arduino-web-uploader
or
yarn add arduino-web-uploader
usage:
import { upload, boards } from 'web-arduino-uploader'
document.addEventListener('button', async () => {
const onProgress = (percentage) => {
console.log(percentage + '%')
}
const verify = false // optional
const portFilters = {} // optional, e.g. [{"usbProductId":46388,"usbVendorId":1241}]
console.log('starting')
await upload(boards.nanoOldBootloader, 'http://your-site.com/hex-file.hex', onProgress, verify, portFilters)
console.log('done!')
})
also check the code of the stand alone html plugin: https://github.com/dbuezas/arduino-web-uploader/blob/master/src/test.ts
dist/
: typescript transpiled to javascript files for npmsrc/index.ts
: uploader codesrc/Serial.ts
: a wrapper of navigator.serial which also emulates a node stream for compatibilitysrc/test.ts
: a wrapper of the lib to use in HTML without writing javascript (for lazy people like https://github.com/seisfeld :D)test/*
: some test html file. The file src/test.ts
is also bundled there by webpackhttps://tooomm.github.io/github-release-stats/?username=dbuezas&repository=arduino-web-uploader
It looks like gihub pages lags by one commit.
MIT License
Copyright (c) 2020 David Buezas
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.