Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Node-RED
  4. How to add a serial device to use in node-red

How to add a serial device to use in node-red

Scheduled Pinned Locked Moved Node-RED
23 Posts 9 Posters 27.7k Views 9 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tbowmoT Offline
    tbowmoT Offline
    tbowmo
    Admin
    wrote on last edited by
    #21

    @sburlot

    is /dev/ttyUSB20 your gateway device?

    What I have done, is the following:

    /dev/tty<gateway> <- nodered is connected to this one directly

    then I have socat create a dummy set of serial ports
    /dev/ttyS81 -> /dev/ttyUSB21

    Nodered connects to /dev/ttyS81 and domoticz connects to /dev/ttyUSB21

    Now nodered is in the middle, between the gateway and your domoticz instance. You then need to create a flow in nodered, that moves data from your gateway, to domoticz, and vice versa. Start with a simple flow, that just connects input serial node, to an output serial node, and then build up on that.

    Haven't got access to my nodered installation at the moment, so can't make any screenshots..

    1 Reply Last reply
    0
    • sburlotS Offline
      sburlotS Offline
      sburlot
      wrote on last edited by
      #22

      I tried (/dev/ttyUSB20 being the port used and created by the MySensors Gateway):

      sudo socat PTY,link=/dev/ttyUSB21,mode=666,group=dialout,raw PTY,link=/dev/ttyUSB20,mode=666,group=dialout,raw
      

      (I found that Domoticz needs the port to be ttyUSB*).

      I connected Domoticz to a MySensors Gateway USB on port /dev/ttyUSB21
      And Node-RED to /dev/ttyUSB20

      But nothing worked: Domoticz did not see new data arrive and Node-RED didnt receive anything. I tried rebooting (and redo the socat dance), nothing happened.

      I suppose my non-understanding of socat is the main cause of this failure.

      So, I took the plunge and moved to a MySensors MQTT gateway. I had to reflash my sensors with a fixed unit_id (not sure if it's still a requirement), and voila.

      Now I can play with Node-RED and try other controllers in parallel of Domoticz.

      Thanks for the help.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gn0st1c
        wrote on last edited by
        #23

        here is my solution;

        add a new udev rules file for permissions:

        sudoedit /etc/udev/rules.d/50-usb-permissions.rules
        

        paste the following in our new rules file:
        (it gives all permission to any USB* and ACM* devices)

        KERNEL=="ttyUSB[0-9]*",MODE="0666"
        KERNEL=="ttyACM[0-9]*",MODE="0666"
        

        that's it. this will give you all the permissions to all usb devices on every boot. also you can reload udev instead of rebooting.

        udevadm control --reload-rules
        

        *** please note that this gives permissions to all USB* and ACM* devices.

        if you're concerned about security you can add the following so that only the mentioned device will be accessable:

        ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="YYYY"
        

        for example, in my case (output from dmesg):

        [ 2654.037338] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523
        [ 2654.037344] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
        [ 2654.037347] usb 1-1: Product: USB2.0-Serial
        [ 2654.038531] usb 1-1: ch341-uart converter now attached to ttyUSB0
        

        so, for me it's:

        ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523"
        
        1 Reply Last reply
        1
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        18

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular