Trouble enabling webusb in chrome

Fabiano Taioli picture Fabiano Taioli · Dec 1, 2016 · Viewed 7.5k times · Source

I'm trying to enable webusb feature in chrome to test it. I' tryng to run this demo (https://github.com/webusb/arduino) locally on my webserver but it does not work, instead the version published on github works.

My setup:

  • Apache webserver virtual host with ssl support with self signed certificate
  • Last Google Chrome with webusb and experimental api flags enabled
  • Imported selfsigned certificate in Chrome to made it trust it like a valid cerficate
  • Remove origin trials meta from demo

But when I access the demo page I got javascript error because navigator.usb is undefined.

What's wrong in my setup, why navigator.usb is not enabled in my local setup but is enabled when I surf the online demo from the same browser?

Answer

Joris Blaak picture Joris Blaak · Dec 5, 2016

To get it up and running you have to enable Experimental Web Platform features, you can find these in the Chrome flags:

chrome://flags/#enable-experimental-web-platform-features

Now navigator.usb will be available, however, if you're developing on localhost you wont see any devices. To get devices showing up you should boot Chrome with --disable-webusb-security which will produce a notification announcing that security will suffer and allow you to see al your attached devices. For more extensive explanation take a look at https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web