NodeRed i2c

394 views
Skip to first unread message

Petrescu Cristian

unread,
Mar 26, 2017, 11:04:45 AM3/26/17
to Node-RED
Hi guys!

I want to connect my Raspberry Pi with Arduino using i2c protocol.

If I sent 1 byte its working as expected. But if I want to send an array of bytes i get the following message :


3/26/2017, 5:55:01 PMnode: ee93fd72.2eee9msg : error
"TypeError: String.isString is not a function"
The array of bytes it's something like : [1,2,3].
Also if I set the message command manually it's working ok. But if i set the msg.command it will laways send 0.
Do you have any idea?
Thanks in advance!

Mark Setrem

unread,
Mar 26, 2017, 11:13:16 AM3/26/17
to Node-RED

What does your node-red flow look like?  What nodes are you using?

Petrescu Cristian

unread,
Mar 26, 2017, 11:39:51 AM3/26/17
to Node-RED
This is just for testing:

[
    {
        "id": "ee93fd72.2eee9",
        "type": "i2c out",
        "z": "6df5275a.e143f8",
        "name": "",
        "i2cdevice": "be40c2b9.13854",
        "address": "4",
        "command": "",
        "payload": "",
        "count": "3",
        "x": 480,
        "y": 240,
        "wires": []
    },
    {
        "id": "85b1ee2f.c212c",
        "type": "inject",
        "z": "6df5275a.e143f8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 120,
        "y": 240,
        "wires": [
            [
                "bd3261a9.7decd"
            ]
        ]
    },
    {
        "id": "bd3261a9.7decd",
        "type": "function",
        "z": "6df5275a.e143f8",
        "name": "",
        "func": "msg.payload=[56,69];\nmsg.command=100;\nmsg.test=200;\nreturn msg;",
        "outputs": "2",
        "noerr": 0,
        "x": 290,
        "y": 240,
        "wires": [
            [
                "ee93fd72.2eee9",
                "ab6a7236.1ac89"
            ],
            []
        ]
    },
    {
        "id": "ab6a7236.1ac89",
        "type": "debug",
        "z": "6df5275a.e143f8",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "true",
        "x": 460,
        "y": 300,
        "wires": []
    },
    {
        "id": "be40c2b9.13854",
        "type": "i2c-device",
        "z": "",
        "device": "/dev/i2c-1",
        "address": "8"
    }
]



The i2c node was installed  via palette. This is the link:


Marcus Törndahl

unread,
May 18, 2017, 10:39:17 AM5/18/17
to Node-RED
Hi,
As I have the same problem I wonder if you got this to work. I have also been thinking about trying a workaround by using the EXEC node in node-red and calling I2CSET.
BR,
Marcus
Reply all
Reply to author
Forward
0 new messages