Hi,
I'm new in this forum. I use Node-Red v 1.3.4 and I'm trying to extract data from a MPU-6050 sensor. I don't know exactly how a I2C bus works, so I downloaded the package node-red-contrib-i2c but it seems doesn't work. This is the flow that I'm using.
[
{
"id": "e17abc1d.5dd908",
"type": "tab",
"label": "LB_MPU-6050_v01",
"disabled": false,
"info": ""
},
{
"id": "c3fac518.cac9f8",
"type": "inject",
"z": "e17abc1d.5dd908",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 320,
"y": 220,
"wires": [
[
"450151ff.9292b"
]
]
},
{
"id": "2b9c0dca.903ba2",
"type": "debug",
"z": "e17abc1d.5dd908",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 220,
"wires": []
},
{
"id": "450151ff.9292b",
"type": "i2c in",
"z": "e17abc1d.5dd908",
"name": "",
"busno": "1",
"address": "104",
"command": "59",
"count": "14",
"x": 470,
"y": 220,
"wires": [
[
"4b112863.d064d8"
]
]
},
{
"id": "4b112863.d064d8",
"type": "function",
"z": "e17abc1d.5dd908",
"name": "process i2c",
"func": "var data = msg.payload;\nvar int16 = function(high, low) {\n var result = (high << 8) | low;\n // if highest bit is on, it is negative\n return result >> 15 ? ((result ^ 0xFFFF) + 1) * -1 : result;\n};\n\n\nmsg.payload = {\n accelerometer : {\n x: int16(data[0], data[1]),\n y: int16(data[2], data[3]),\n z: int16(data[4], data[5])\n },\n temperature : int16(data[6], data[7]),\n gyro : {\n x: int16(data[8], data[9]),\n y: int16(data[10], data[11]),\n z: int16(data[12], data[13])\n }\n};\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 630,
"y": 220,
"wires": [
[
"2b9c0dca.903ba2"
]
]
}
]
Thanks for your support