I need to compile generated source code in js runtime then upload it to my device.


I have found arduino-cli


There is only avrgirl but it doesn't work in browser. What should I do?

  • Arduinos cannot be programmend in Nodejs. You need to write C/C++ or Assembler.
    – chrisl
    Dec 8, 2019 at 15:18
  • @chrisl, it's not about programming (code is c-generated one) it's about calling compiler from js
    – caxapexac
    Dec 8, 2019 at 15:40
  • 1
    Ah, ok. But you can also upload sketches with arduino-cli. If you can use it, you can also upload sketches
    – chrisl
    Dec 8, 2019 at 16:14

1 Answer 1


You can't, and that's a good thing. If the browser could let a Web site access your hardware, that would be a huge security breach. You may be able to bypass this security restriction if you can write an extension (plugin) for your browser.

  • Okay then I will use extension for hex code uploading. Then how can I compile it using only in-browser js?
    – caxapexac
    Dec 8, 2019 at 17:15
  • I mean: source code -> String -> Compiler -> Hex-string -> Extension -> Uploading
    – caxapexac
    Dec 8, 2019 at 17:16
  • @caxapexac: Building a C++ compiler in JavaScript is not a trivial task. You may try to port avr-g++ using Emscripten. Dec 8, 2019 at 17:42
  • Seems for me a weird way to do everything in the browser. Normally in such a situation you are actually building a web service, so the compilation could be done server side by calling avr-g++ or arduino-cli through the nodejs code. Then you only would need to encapsule arduino-cli in an extention for uploading on the local computer
    – chrisl
    Dec 8, 2019 at 20:37
  • I modify the code from js-stk500 to work from browser with web serial API. but I can't makr Arduino CLI to work in browser. Is that possible?
    – M lab
    Nov 22, 2022 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.