Arduino Serial - Node-RED - ioBroker

This Node-RED flow is between the serial connected Adruino UNO via USB port and the ioBroker. For this example are 2 switches und 2 relays on Arduino digital GPIOs connected. The Arduino is also working stand alone. Node-RED is listing on the Arduino’s serial monitor and send the data to ioBroker. Also ioBroker is sending commands to Node-RED and Node-RED do an forward to the Arduino’s serial monitor. The Sketch for the Arduino you can copy from https://www.4hf.de/raspberry-pi/iobroker-node-red-raspberry-serial-arduino-heimautomation-209.htm

[
    {
        "id": "5dc14f5e.b39e48",
        "type": "tab",
        "label": "Relais01"
    },
    {
        "id": "87b2cdb9.c9cc38",
        "type": "serial in",
        "z": "5dc14f5e.b39e48",
        "name": "Arduino USB",
        "serial": "413a9322.7df064",
        "x": 105,
        "y": 182,
        "wires": [
            [
                "61d2de74.9707c",
                "42e8d89e.b7faf8"
            ]
        ]
    },
    {
        "id": "5a5f5efe.415708",
        "type": "debug",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 632,
        "y": 455,
        "wires": []
    },
    {
        "id": "2f9387d6.cb62c",
        "type": "serial out",
        "z": "5dc14f5e.b39e48",
        "name": "Arduino USB",
        "serial": "413a9322.7df064",
        "x": 602,
        "y": 178,
        "wires": []
    },
    {
        "id": "553740d1.71b318",
        "type": "ui_switch",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "label": "Relais01 Schalter",
        "group": "9c90b407.f62ef",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": true,
        "topic": "",
        "style": "",
        "onvalue": "C",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "D",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 415,
        "y": 142,
        "wires": [
            [
                "2f9387d6.cb62c"
            ]
        ]
    },
    {
        "id": "11f1c6bf.cd6291",
        "type": "ioBroker out",
        "z": "5dc14f5e.b39e48",
        "name": "Staus Lampe",
        "topic": "Status Lampe",
        "ack": "true",
        "autoCreate": "true",
        "x": 582,
        "y": 620,
        "wires": []
    },
    {
        "id": "33cdc360.cd1dac",
        "type": "change",
        "z": "5dc14f5e.b39e48",
        "name": "Relais1",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "Relais3:0",
                "fromt": "str",
                "to": "0",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "Relais3:1",
                "fromt": "str",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 355,
        "y": 620,
        "wires": [
            [
                "11f1c6bf.cd6291",
                "5a5f5efe.415708"
            ]
        ]
    },
    {
        "id": "c1b0897b.6bf018",
        "type": "change",
        "z": "5dc14f5e.b39e48",
        "name": "Relais2",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "Relais4:0",
                "fromt": "str",
                "to": "0",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "Relais4:1",
                "fromt": "str",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 281,
        "y": 444,
        "wires": [
            [
                "60d1c07b.a0b2d",
                "5213599c.e25638",
                "5a5f5efe.415708"
            ]
        ]
    },
    {
        "id": "60d1c07b.a0b2d",
        "type": "ioBroker out",
        "z": "5dc14f5e.b39e48",
        "name": "Status Lampe02",
        "topic": "Status Lampe02",
        "ack": "true",
        "autoCreate": "true",
        "x": 492,
        "y": 385,
        "wires": []
    },
    {
        "id": "61d2de74.9707c",
        "type": "switch",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Relais3:0",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Relais3:1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 181,
        "y": 619,
        "wires": [
            [
                "33cdc360.cd1dac"
            ],
            [
                "33cdc360.cd1dac"
            ]
        ]
    },
    {
        "id": "42e8d89e.b7faf8",
        "type": "switch",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Relais4:0",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Relais4:1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 303,
        "y": 323,
        "wires": [
            [
                "c1b0897b.6bf018"
            ],
            [
                "c1b0897b.6bf018"
            ]
        ]
    },
    {
        "id": "2a0b5d9e.adbf0a",
        "type": "ui_colour_picker",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "label": "",
        "group": "9c90b407.f62ef",
        "format": "hex",
        "outformat": "string",
        "showSwatch": true,
        "showPicker": false,
        "showValue": false,
        "showAlpha": false,
        "showLightness": true,
        "order": 0,
        "width": "2",
        "height": "2",
        "passthru": true,
        "topic": "",
        "x": 662,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "5213599c.e25638",
        "type": "change",
        "z": "5dc14f5e.b39e48",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "0",
                "fromt": "num",
                "to": "red",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "str",
                "to": "green",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 403,
        "y": 538,
        "wires": [
            [
                "2a0b5d9e.adbf0a"
            ]
        ]
    },
    {
        "id": "c1a493a4.35a2a",
        "type": "ioBroker in",
        "z": "5dc14f5e.b39e48",
        "name": "Von ioBroker",
        "topic": "Von ioBroker",
        "payloadType": "value",
        "onlyack": false,
        "func": "all",
        "gap": "",
        "x": 426,
        "y": 228,
        "wires": [
            [
                "2f9387d6.cb62c"
            ]
        ]
    },
    {
        "id": "413a9322.7df064",
        "type": "serial-port",
        "z": "",
        "serialport": "/dev/ttyACM0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": false
    },
    {
        "id": "9c90b407.f62ef",
        "type": "ui_group",
        "z": "",
        "name": "Schalter01",
        "tab": "df8d25f2.4868c8",
        "disp": true,
        "width": "6"
    },
    {
        "id": "df8d25f2.4868c8",
        "type": "ui_tab",
        "z": "",
        "name": "Schalter",
        "icon": "dashboard"
    }
]
hermannf1

Flow Info

created 1 month, 1 week ago

Node Types

Core
  • change (x3)
  • debug (x1)
  • serial in (x1)
  • serial out (x1)
  • serial-port (x1)
  • switch (x2)
Other
  • ioBroker in (x1)
  • ioBroker out (x2)
  • tab (x1)
  • ui_colour_picker (x1)
  • ui_group (x1)
  • ui_switch (x1)
  • ui_tab (x1)

Tags

  • ioBroker
  • Arduino
  • Serial
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option