loading...
Cover image for Web Serial API: The web of tomorrow is everywhere, including the serial port

Web Serial API: The web of tomorrow is everywhere, including the serial port

macargnelutti profile image Matteo Cargnelutti ・2 min read

Allowing the browser to communicate with the serial port? The idea may sound archaic and somewhat silly at first, but that's what the Web Serial API offers: a standard and modern JavaScript API to communicate with serial-based devices, directly from the browser.

The web of tomorrow is everywhere, from NFC to Bluetooth, from USB to serial, and while this API does not sound as "sexy" as others, it has a great potential. What could we do with Web Serial, and why it matters? That's what we are going to talk about in this article.


Potential use cases

While it is likely that your current machine does not have a serial port, it is still widely used in many different scenarios, in which the web platform could both be a facilitator and bring new possibilities.

The first that comes to mind is Arduino and other micro controllers: being able to communicate with those devices from the browser would allow developers to harvest the interoperability and connectivity capabilities of the web, but also reduce the pre-requisites to get started with physical computing, by providing everything needed "out of the box".
A good example of this use case is the Web Serial tutorial Google wrote for the BBC micro:bit micro-computer.

Another important use case that might not be as obvious is being able to develop future-proof software for older hardware. A lot of businesses and science labs rely on extremely old machines and the software that comes with them, sometimes requiring to keep Windows 9X computers around. Being able to write custom software for those devices using the web platform would allow to help make them future-proof, as the web platform now has forward-compatibility principles at its core, guaranteeing that something standard and supported stays usable on the long term.


Current status and support

Part of a Web Platform Incubator Community Group proposal, specifications for navigator.serial are still early drafts.

An implementation of it is available in Google Chrome, behind the #enable-experimental-web-platform-features flag. It appears that the current implementation matches the latest specifications draft overall, but this is not guaranteed.

Finally, the team behind the node-serialport project created a wrapper for their library mimicking navigator.serial, aptly named navigator.serial, allowing to get a taste of what the Web Serial API could be like in NodeJS and Electron.

In any case, the current specifications and implementations of Web Serial are too experimental at the moment to be used in a production context.


Conclusion

The Web Serial API has a great potential, but a long way to go to become a standard, which is in itself not guaranteed. We have just enough information and partial implementations to experiment with it, get excited about it, and get involved to help make it happen!


Photo source: Pixabay

Posted on by:

macargnelutti profile

Matteo Cargnelutti

@macargnelutti

CTO & Software Developer at Grafton Studio, Boston MA. Interested in everything Web standards, Python, Javascript. He/Him, πŸ‡ΊπŸ‡ΈπŸ‡«πŸ‡·. Opinions are my own.

Discussion

pic
Editor guide