# How to use GY-521 MPU-6050 with Node-RED?

**URL:** <https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741>\
**Category:** General\
**Created:** [21 February 2022 10:49 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741 "2022-02-21T10:49:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bongini](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Bongini](https://discourse.nodered.org/u/Bongini)\
**Post date:** [21 February 2022 10:49 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741/1 "2022-02-21T10:49:28Z")

</div>

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.

```auto
[
    {
        "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

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [21 February 2022 11:05 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741/2 "2022-02-21T11:05:04Z")

</div>

Welcome to the forum!

This may help:  
[https://flows.nodered.org/flow/f8c7a94454f79d3cfdc5](https://flows.nodered.org/flow/f8c7a94454f79d3cfdc5)

Be aware that this is an old posting.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [21 February 2022 11:17 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741/3 "2022-02-21T11:17:16Z")

</div>

What hardware are you running node-red on? Also, that is a very old version, you might have more success if you can update to the current version.

---

<div class="post-metadata">

**Author:** ![Bongini](https://avatars.discourse-cdn.com/v4/letter/b/87869e/32.png) [@Bongini](https://discourse.nodered.org/u/Bongini)\
**Post date:** [21 February 2022 17:58 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741/4 "2022-02-21T17:58:32Z")

</div>

Thanks, I'm using a Raspberry Pi Zero 2W. Now I'll try to update my Node Red.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 April 2022 17:59 UTC](https://discourse.nodered.org/t/how-to-use-gy-521-mpu-6050-with-node-red/58741/5 "2022-04-22T17:59:30Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
