# Raspberry Pi PLC Analog Read Problem

**URL:** <https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677>\
**Category:** General\
**Created:** [19 August 2022 16:00 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677 "2022-08-19T16:00:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![locutus](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@locutus](https://discourse.nodered.org/u/locutus)\
**Post date:** [19 August 2022 16:00 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677/1 "2022-08-19T16:00:39Z")

</div>

Hey all, completely new to node-red. I'm trying to use the analog read node to read off of an analog pressure sensor on a RPI PLC shield. Right now I'm just connecting 5 V to I0.5 pin (which is the analog/digital input pin on the module) to see if it's reading anything but on the debug message I'm only getting 0 for the payload. On the node-red console I'm getting a message stating: i2c\_write: device or resource busy.

 ![Screenshot_20220819_115620](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/6/d659ba09e6ebfb6140328a9a50c255d11426b760.jpeg)  
 ![Screenshot_20220819_115534](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c7a22cab88ef2286d8daa6e2c0574dd21ce1f13.png)

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [19 August 2022 17:21 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677/2 "2022-08-19T17:21:07Z")

</div>

Hi @locutus and welcome!! I'm not sure but I think you need to configure some I2C Address in your read node! or the frequency that you are reading the analog input, could you show your node configuration?

---

<div class="post-metadata">

**Author:** ![locutus](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@locutus](https://discourse.nodered.org/u/locutus)\
**Post date:** [19 August 2022 17:54 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677/3 "2022-08-19T17:54:32Z")

</div>

Hey hey thanks for replying! Here's the configuration for the analog read node.

 ![Screenshot_20220819_134654](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d7e9c47e07899a4032a90476615f8736c903765.png)

And here's the flow:

```auto
[
    {
        "id": "d3df6b967180bd06",
        "type": "tab",
        "label": "Pressure Sensor Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "fa41a2b693778a4f",
        "type": "ui_button",
        "z": "d3df6b967180bd06",
        "name": "",
        "group": "2834acbfcd022381",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "START",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 160,
        "y": 120,
        "wires": [
            [
                "639b667e73f96d87"
            ]
        ],
        "info": "int count = 0"
    },
    {
        "id": "3ea0761ff8e23a52",
        "type": "ui_button",
        "z": "d3df6b967180bd06",
        "name": "",
        "group": "2834acbfcd022381",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "STOP",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "0",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 110,
        "y": 620,
        "wires": [
            [
                "a45defed725f8a72"
            ]
        ]
    },
    {
        "id": "639b667e73f96d87",
        "type": "function",
        "z": "d3df6b967180bd06",
        "name": "start flow.count and send python cmd",
        "func": "var count = flow.get('count')||0;\nflow.set('count', count);\nvar newMsg = {payload: \"python -u /home/locutus/hx711py/example.py\"};\nreturn newMsg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 120,
        "wires": [
            [
                "ff1d1803d08327d0"
            ]
        ]
    },
    {
        "id": "ff1d1803d08327d0",
        "type": "exec",
        "z": "d3df6b967180bd06",
        "command": "",
        "addpay": "payload",
        "append": "",
        "useSpawn": "true",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 710,
        "y": 120,
        "wires": [
            [
                "fbfac848b893fa78",
                "294cf4c2c2a94c89"
            ],
            [],
            []
        ]
    },
    {
        "id": "368e32f675ae7b70",
        "type": "status",
        "z": "d3df6b967180bd06",
        "name": "",
        "scope": [
            "ff1d1803d08327d0"
        ],
        "x": 160,
        "y": 40,
        "wires": [
            [
                "6908cb897339c750"
            ]
        ]
    },
    {
        "id": "6908cb897339c750",
        "type": "change",
        "z": "d3df6b967180bd06",
        "name": "set flow.pid",
        "rules": [
            {
                "t": "set",
                "p": "pid",
                "pt": "flow",
                "to": "$number($split(status.text, ':'[1])",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 450,
        "y": 40,
        "wires": [
            []
        ]
    },
    {
        "id": "a45defed725f8a72",
        "type": "change",
        "z": "d3df6b967180bd06",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "pid",
                "tot": "flow"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 760,
        "wires": [
            [
                "4e8cd9829c35c1d0"
            ]
        ]
    },
    {
        "id": "4e8cd9829c35c1d0",
        "type": "exec",
        "z": "d3df6b967180bd06",
        "command": "sudo kill -9",
        "addpay": "payload",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 590,
        "y": 760,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "fbfac848b893fa78",
        "type": "ui_chart",
        "z": "d3df6b967180bd06",
        "name": "",
        "group": "2834acbfcd022381",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "chart",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "1",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 930,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "294cf4c2c2a94c89",
        "type": "ui_gauge",
        "z": "d3df6b967180bd06",
        "name": "",
        "group": "2834acbfcd022381",
        "order": 2,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Bar",
        "label": "Bar",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 950,
        "y": 380,
        "wires": []
    },
    {
        "id": "8be32f244aa2ebdb",
        "type": "rpiplc-analog-read",
        "z": "d3df6b967180bd06",
        "rpiplc": "1a79a48be02df255",
        "pin": "I0.2",
        "name": "",
        "x": 320,
        "y": 380,
        "wires": [
            [
                "294cf4c2c2a94c89",
                "b8f403621d7f353b"
            ]
        ]
    },
    {
        "id": "dd140b02b40c503f",
        "type": "inject",
        "z": "d3df6b967180bd06",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 380,
        "wires": [
            [
                "8be32f244aa2ebdb"
            ]
        ]
    },
    {
        "id": "b8f403621d7f353b",
        "type": "debug",
        "z": "d3df6b967180bd06",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 260,
        "wires": []
    },
    {
        "id": "2834acbfcd022381",
        "type": "ui_group",
        "name": "Group",
        "tab": "95ad7dbb2df7acac",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "1a79a48be02df255",
        "type": "rpiplc-config",
        "model": "RPIPLC_19R",
        "name": ""
    },
    {
        "id": "95ad7dbb2df7acac",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![MecatronicaMADE](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@MecatronicaMADE](https://discourse.nodered.org/u/MecatronicaMADE)\
**Post date:** [19 August 2022 22:22 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677/4 "2022-08-19T22:22:41Z")

</div>

I tried execute flow but I don not have an Industrial Shield Rpi based, the nodes don not run in my PC. All the configuration look good, I also check the [Industrial Shields Analog tutorial](https://www.industrialshields.com/es_ES/blog/raspberry-pi-para-la-industria-26/post/tutorial-de-node-red-como-leer-las-entradas-analogicas-del-plc-raspberry-331) and is the same configuration that you have, you could check if digital inputs/outputs works well, and check if the PLC model is correct... sorry it is all I have....

PD. I only have been working with Industrial Shields M-Duino(Mega based) and Ardbox Relay PLC (Leonardo based), and are great!! I hope use an RPI based.

---

<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:** [18 October 2022 22:23 UTC](https://discourse.nodered.org/t/raspberry-pi-plc-analog-read-problem/66677/5 "2022-10-18T22:23:26Z")

</div>

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