Device Sharing Server - USB to Serial Devices e.g Ser2net


I’ve been using a Raspberry Pi for years to access serial devices over IP (such as my DSC Alarm) . Doing this allows me the freedom to place items anywhere in the house and remove the need for everything to be connected directly into Vera.

To do this I use Ser2net but I have a 1 to 1 Pi to device ratio, and the Ser2net connections will only allow one connection at a time. So if I want to other controllers like Node Red or Home Assistant to access them, I can only choose one at a time…

To get around this, does anyone know of a tool/system (setup) that would allow me (a) to share a single usb/serial device with multiple HA controllers and (b) for those devices that can sit anywhere, ideally I’d like to connect them into one PI (which can act as a central server for anyone to then access ?)

I appreciate I’m treading old ground on this, based on a thread I was running a number of years back but never concluded - Building A ser2net (Serial to IP) Server

Can’t you just add mqtt to the equation? This way, you can take the serial output and send it via mqtt and replicate if necessary.

Didn’t know vera supported ser2net or have I read this wrong?
That aside, I use multiple Pi’s connected using ser2net albeit with HS4 as the controlling hub, so it would be a limitation on Vera’s side.
To answer your question (and I’ll probably be sent to the sin bin for this), if you use HS as your primary controller then you can use as many ser2nets as you like, each one connecting with whatever you want to add.
I’ve got N-R running on a RasPi-3 which is running HS, this is connected to Vera via Node-Red. Both co-exist with 2 Zed-Nets. Being able add RasPi’s as required is a novel and inexpensive way of being able to add devices that otherwise couldn’t be part of the ecosystem.

1 Like


Thanks @therealdb - I would be interested in exploring MQTT in this server set up, but have not had much exposure to it, other than some of the basics, what did you have in mind? What would be used to convert the messages received via Ser2net into mqtt messages ?

Thanks @zedrally - my issue is not necessarily the amount of Pi’s, it’s more the ability to share usb/serial devices connected to them - and by the looks of it I have found a fix, and it was with the Ser2net version on the Pi’s all along.

I had previously been running the version that would be installed by default (which was 2.9.1)- but when I went to the Soureforge project page for Ser2net ( ) - I found that version 3.5 (and after) allows you to share connections, simply by updating your associated Ser2net.conf config line with “max-connections=N” e.g.

3333:telnet:0:/dev/ttyUSB-P1:115200 8DATABITS NONE 1STOPBIT max-connections=3

So using a variation of the above, I now have my DSC Alarm System shared with a couple of my HA controllers, and the next thing on my list is to bring my CurrentCost energy monitor and RFXCOM 433mhz transceiver onto a single Pi…

Coincidentally looking on my VeraPlus; the Ser2net version running on there is v2.9.1 too

It makes me wonder what else I could connect and share…

Looking at an old post on another thread by the legendary @guessed who said the following …

"When you plug a USB-Serial device into Vera, it detects it and automatically assigns it to be managed by ser2net . Vera then maintains a certain amount of metadata about that Serial port within it’s own config, and you can see this in the UI (under Apps/Develop Apps/Serial Port configuration)

IF you don’t attach this to a Plugin, then it’s accessible via a standard TCP Connection, via the port outlined in the UI, since ser2net listens widely. If you attach a plugin to it, then it’s effectively “used” and no-one else can connect.

There’s no automatic HTTP <-> TCP mapping going on, but the TCP port is there if you want to do something with it from a local and/or remote entity."

Using my Vera3 (UI5) as a test case, I have two USB devices directly connected to that…

Now, it was my hope that I would find corresponding entries for the above in the Ser2net.conf file, but none are specifically called out and nothing seems to match up just on the settings alone ? See Ser2net.conf extract below.

#2002:raw:600:/dev/ttyS1:9600 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS 
2007:raw:5:/dev/ttyS6:9600 tw=tw1 tr=tr1 
3001:telnet:0:/dev/ttyS0:19200 remctl banner1 
3011:telnet:3:/dev/ttyS0:19200 banner2 #
3003:telnet:0:/dev/ttyS2:9600 banner3 

It makes me wonder how I can find and share them - if there is no obvious mapping ? Yet, I can see those two ports listed in the iptables.

> netstat -l -n
> Active Internet connections (only servers)
> Proto Recv-Q Send-Q Local Address           Foreign Address         State       
> tcp        0      0  *               LISTEN      
> tcp        0      0 *               LISTEN      
> tcp        0      0    *               LISTEN      
> tcp        0      0    *               LISTEN      
> tcp        0      0    *               LISTEN      
> tcp        0      0  *               LISTEN      
> tcp        0      0  *               LISTEN      
> tcp        0      0  *               LISTEN      
> tcp        0      0 *               LISTEN      
> netstat: /proc/net/tcp6: No such file or directory
> udp        0      0    *                           
> udp        0      0    *                           
> udp        0      0  *                           
> udp        0      0 *                           
> udp        0      0*                           
> netstat: /proc/net/udp6: No such file or directory
> netstat: /proc/net/raw6: No such file or directory
> Active UNIX domain sockets (only servers)
> Proto RefCnt Flags       Type       State         I-Node Path

Do you think I can simply add a new line/config Into the Ser2net.conf for these devices and then change the plug-ins associated to use a local IP with the registered port e.g. ?

It’s pretty easy. Mqtt are simple text messages, and thus can be easily routed. You’ll need a broker to receive them and push to other brokers, if necessary. from a quick search, it seems a ser2net to mqtt has already been created. This will push all the messages from the local serial port to the remote broker. Here you can analyze the messages, send to other brokers and whatever you could think of.

Check the process list. I no longer have Vera running anywhere in my env, but IIRC it fires up discrete ser2net processes with CLI parameters (or maybe 1, with a CLI of a non-default config… it’s been a while)

On newer Linux’s you can also use netstat -nap To see the PID of the process that’s attached to the LISTEN sockets.

Hey @guessed ! Hope all is well with you…

How are things, I’m guessing you are not missing the Vera experience;) So is it OpenHab you moved over to or was it some other HA controller ?

BTW, thanks for the tip, running ps aux, I found them…

10015 root      1676 S    /bin/sh -c ser2net -n  -C "3481:raw:0:/dev/ttyUSB0:38400 1STOPBIT NONE" -C "3482:raw:0:/dev/ttyUSB1:57600 1STOPBIT NONE"
10016 root       804 S    ser2net -n -C 3481 raw 0 /dev/ttyUSB0 38400 1STOPBIT NONE -C 3482 raw 0 /dev/ttyUSB1 57600 1STOPBIT NONE

I guess it’s OK for those lines to continue to occur there, assuming I can somehow work out how to append ‘max-connections=N’ to the end of those generated commands … any ideas ? Alternative is to hard-code them in the Ser2net.conf ?

1 Like

The challenge with the .conf file will be upgrades, and whether any changes made there will rollover to the next release. You could be chasing yourself senseless with that one. :dizzy_face:

assuming I can somehow work out how to append ‘max-connections=N’ to the end of those generated commands … any ideas ?

No really, it’s been ages since I’ve used ser2net. I tend to use HW serial-Ethernet devices for this stuff (still using WizNet’s) for the overall reliability, and keep a small set of RPi’s for data-collectors (Electricity), log aggregation (rsyslod and friends) and DNS (pi-hole et-al)

That, and my HA Controller has MQTT built in, and some great apps that expose it nicely… so not much need to do the deep dives on this stuff.

So is it OpenHab you moved over to or was it some other HA controller ?

I ended up looking for a more commercial ZWave Hub, and that. The one I use is actively maintained (releases 2-3x / mo), works offline, has both scripting (for User Apps and Drivers) and a healthy set of Rule engines built-in for declarative stuff.

It also has an extremely vibrant user community for the hub, which reminds me a lot of the early days.

My goal has always to feel comfortable selling the house, and leaving the HA Controller installed for the new owner(s).

There’s enough clues in that sentence as to what I use, without getting banned for mentioning/linking it specifically :wink:

Node-Red opens up a completely new world, if you haven’t looked into it then it’s worth while.
Not sure if it’s available for UI5 but is there for UI7.
Looks like @guessed is keeping us guessing?

1 Like

Looks like @guessed is keeping us guessing?

There’s a reason I originally chose my userid (2009?)… had the added advantage of being extremely hard to search for, and apparently still does :slight_smile:

If it helps, my userid is the same in their Community hub*.com site, and they use the same forum software… but doesn’t everyone? :laughing:

As always thanks @guessed I’m going to make an assumption that the controller you use today is one of the items in here :ok_hand: -

While I have you.

I still have a wiznet years ago (likely bought trying to emulate something you did years ago) but having bought a rj45 one, I could never find a place or a case for it to keep it safe - what do you use ?

Hi @zedrally - Thanks, although my thinking was more on hardware/device to share, not necessarily on the controller aspect - however I’m a big fan of Node-Red - I even created one of the early threads on it, on this forum myself - Node-Red & Vera (MIOS)

The main one is in a structured wiring closet and plugged directly into my Alarm panel’s interface board, using its RS-232 port. That interface board is mounted on a plate (specific to my SWC’s enclosure) so it’s all rigid, and I haven’t needed a case for the wiznet itself.

btw, more like this

You’ve just chucked even more “hubs’ into the mix now with that link … :thinking:
But one recently released a 2.2.3 update (Aug 13th) :fist_right:

1 Like

Well, to round off this thread - I’ve now got just the one RPi, running ser2net v3.5.1 configured to share my current cost energy monitor and my Rfxtrx433 - transceiver.

4002:raw:0:/dev/ttyUSB0:57600 8DATABITS NONE 1STOPBIT max-connections=4
4003:raw:0:/dev/ttyUSB1:38400 8DATABITS NONE 1STOPBIT max-connections=4
1 Like

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules