How to connect any serial device to the internet
Categories
Tags
Recent articles
Ubuntu 16.10 LXC host on ZFS Root, with EFI and Time Machine
How to connect any serial device to the internet
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 https://github.com/faceless2/serial-http-bridge.