MQTT on Serial Gateway?

  • I've been using MQTT with a GPIO-wired Raspberry Pi gateway successfully for a number of months. I don't like the jumper-wire interconnect to the radio, so I'm moving off the Pi and onto a small Linux server (Intel NUC). As part of this I'm considering a serial gateway...but I notice there is no MQTT client option in the gateway code GatewaySerial.ino.

    Am I missing something or is this a technical limitation? I'm aware of the options with ethernet or Wifi gateways, but like the simplicity of a USB connection if it is a viable option. I'm committed to continuing to use MQTT. I also like the idea of a direct wired connection from the gateway to the controller without hopping over the LAN in between.

    Any info or opinions welcome and appreciated.



  • Mod

    @Grubstake I'm using NodeRed in combination with the MySensors Nodes by @tbowmo.
    You could run a similar setup on your NUC with serial gateway connected. Use these nodes to de/encode the serial gateway format and connect them to MQTT nodes.

    In the past I developed a serial-to-mqtt converter (see here) but I've moved away from separate solutions, concentrating on NodeRed.

  • @Yveaux Thanks, Yveaux. Mode Red looks pretty interesting and I think it may be very useful down the road. At this moment I'm trying to keep things as simple as possible (despite my MQTT constraint). I'm already comfortable with MQTT and if serial is a problem I'll probably go to ESP8266 Wifi, as I'm already familiar with the ESP modules.

    I'm just trying to select the best gateway, with the transport from radio to WAN being as fast/low latency and trouble-free as possible...but not looking for extra work! Wondering if the MQTT protocol already integrated into MySGW on the Rpi, ESP/Wifi, and Ethernet gateways might be a possiblity for Serial.


  • Mod

    @Grubstake Yes they are. If you drop the serial gateway requirement there are a lot more possibilities 👍
    My other gateway runs on a Uno+W5100 Ethernet shield with MQTT. Rock solid!

  • @Yveaux Interesting. What controller does your gateway talk to? I'm trying to get up and running with OpenHAB 2.0 which has its own MySensors binding issues to deal with an its unclear if it will work with MQTT.


  • Mod

    @Grubstake I'm not using a controller. NodeRed controls the logic and stores data in InfluxDB.

  • @Grubstake if you build a MQTT MySensors gateway, there's no OpenHab binding needed. Disadvantage is that you need to configure your nodes in OpenHab manually.

  • @Yveaux No controller...Interesting. Thank you for sharing that, it moves NodeRed up on the list I think, even though I do want to get OpenHAB running to see how useful it is. Thanks!

  • @ericvdb Eric, I did not know that the MySensors binding wasn't needed for MQTT on OpenHAB. My short term goal is to get ANY sensor configured and running on OpenHAB 2.0, and since I already have a MySensors MQTT gateway running on my rPi, that is an interesting option. Very helpful, thanks.

  • Hi @Grubstake

    In my case, I just use a nodeJS script which reads from serial and publishes to mqtt. It also subscribes from mqtt and sends it to serial.

    Pretty straight forward. For more details, look here.


  • @barduino Thanks for that. So many great suggestions in this thread.

    For the "learning this stuff as I go along folks", like me 😬 could you share briefly what's involved in using your code, beyond basic install of node.js?

    Trying to choose my battles, and moving from Domoticz to OpenHAB, new setup of InfluxDB, Grafana, Node-red are already on the top of a long list... So much software, so little time...

    Not to mention hardware...

    But, hey, an ESP-Easy MQTT node popped up in my OpenHAB Paper UI last night, after a few minutes of tweaking the node, which is a first, so that's a baby step. MySensors next...


  • Hi @Grubstake,

    Not much else...

    You can have node running (as a service or daemon) on any device that has a USB port (PC, mac, RPI) and it is agnostic of what controller you have.

    Are you interested in the code details? Check the MySensors post I included in the link.

    The MySensors typical messages is something like this 30;5;1;0;37;70

    Which gets translated to /whateverpathyouwant/out/30/5/1/0/37 Payload: 70

    And vice versa.

    The reason I did this was because I had no WiFi or Network enabled gateway.


Log in to reply

Suggested Topics

  • 4
  • 2
  • 5
  • 20
  • 9
  • 14