How to connect any serial device to the internet

14 Mar 2017


Boat (27) 
Not the Boat (12) 


Recent articles

25 Apr 2017

Ubuntu 16.10 LXC host on ZFS Root, with EFI and Time Machine

Still completely unrelated to boats, but I needed somewhere to put this. Here is a blow-by-blow guide to installing a minimal Ubuntu 16.10 to a ZFS root, booted from EFI, which as used as a LXC host to act as an Apple "Time Machine" destination.
mike 25 Apr 2017 at 17:20
14 Mar 2017

How to connect any serial device to the internet

A completely generic script that will proxy serial devices over HTTP, turning USB-things into internet-things.
mike 14 Mar 2017 at 23:00

As well as building the boat we're converting an old pub into a house. Naturally it's got a bit out of hand, and now I have a number of custom circuits talking to the DALI lighting bus to control all the lights in the house. More on that later. Briefly, I needed a simple way to patch these custom circuit boards into Openhab, and this project is the result.

The vast majority of first-generation Arduino-type devices communicate over serial, and the vast majority of those do so via some sort of ASCII protocol - commands are sent to the device in ASCII, and a reply comes back in ASCII.

If you have a device like this and want to control it remotely or integrate it into a larger system, chances are you'll need to put that device on the web. This would typically involve some coding to translate whatever ASCII protocol you've devised to talk over the serial connection into some sort of REST API.

I have a lot of different devices and didn't fancy reinventing this wheel each time, so have written a small, completely generic webserver which will proxy any serial device to HTTP. The device is written to by POSTing the commands to /write, one per line. And any data received from the device is sent as Server-Sent Events. This means the server can relay any input/output between a serial device and the web without knowing the protocol.

This one is a NodeJS module (my first, so it may be a bit crufty). You can see more detail at