# GPIO input to msg.reset

**URL:** https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761
**Category:** General
**Created:** [4 April 2022 10:40 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761 "2022-04-04T10:40:54Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)
#### Post date: [4 April 2022 10:40 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/1 "2022-04-04T10:40:54Z")

</div>

Hi  
i wan´t to toggle input from Raspi and convert this to msg.reset. with my toggle inject it works, what i am doing wrong?

[  
{  
"id": "5542a8a0.2ca958",  
"type": "tab",  
"label": "Flow 4",  
"disabled": false,  
"info": ""  
},  
{  
"id": "f72b7fba427a9063",  
"type": "debug",  
"z": "5542a8a0.2ca958",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "reset",  
"targetType": "msg",  
"statusVal": "",  
"statusType": "auto",  
"x": 980,  
"y": 180,  
"wires":   
},  
{  
"id": "da8ccfee81eca535",  
"type": "rpi-gpio in",  
"z": "5542a8a0.2ca958",  
"name": "",  
"pin": "27",  
"intype": "up",  
"debounce": "25",  
"read": false,  
"bcm": true,  
"x": 260,  
"y": 180,  
"wires": [  
[  
"a0ab2fb7ef09f749"  
]  
]  
},  
{  
"id": "a0ab2fb7ef09f749",  
"type": "toggle",  
"z": "5542a8a0.2ca958",  
"name": "",  
"onOffTopic": "",  
"onValue": "reset",  
"onType": "str",  
"offValue": "reset",  
"offType": "str",  
"toggleTopic": "",  
"toggleValue": "true",  
"toggleType": "bool",  
"passOnOff": "",  
"x": 470,  
"y": 180,  
"wires": [  
[  
"cb77bffed11082a8"  
]  
]  
},  
{  
"id": "cb77bffed11082a8",  
"type": "change",  
"z": "5542a8a0.2ca958",  
"name": "",  
"rules": [  
{  
"t": "set",  
"p": "payload",  
"pt": "msg",  
"to": "reset",  
"tot": "msg"  
}  
],  
"action": "",  
"property": "",  
"from": "",  
"to": "",  
"reg": false,  
"x": 710,  
"y": 180,  
"wires": [  
[  
"f72b7fba427a9063"  
]  
]  
},  
{  
"id": "fa5eabcfaf8d407c",  
"type": "inject",  
"z": "5542a8a0.2ca958",  
"name": "toggle",  
"props": [  
{  
"p": "reset",  
"v": "reset",  
"vt": "str"  
}  
],  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"topic": "",  
"x": 270,  
"y": 340,  
"wires": [  
[  
"f72b7fba427a9063"  
]  
]  
}  
]

 ![gpio-msg](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/e/ee564c66d32e3d858e4768070caee957fa1a2339.jpeg)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 April 2022 11:07 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/2 "2022-04-04T11:07:21Z")

</div>

Hi.

Your flow is unusable.

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)
#### Post date: [4 April 2022 11:32 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/3 "2022-04-04T11:32:09Z")

</div>

```auto
[
    {
        "id": "60ddb49f23d04d93",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "40e5321e4f897792",
        "type": "debug",
        "z": "60ddb49f23d04d93",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "reset",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1140,
        "y": 260,
        "wires": []
    },
    {
        "id": "6c967b019c09a4a1",
        "type": "rpi-gpio in",
        "z": "60ddb49f23d04d93",
        "name": "",
        "pin": "27",
        "intype": "up",
        "debounce": "25",
        "read": false,
        "bcm": true,
        "x": 420,
        "y": 260,
        "wires": [
            [
                "a992d6c9c2ed4a29"
            ]
        ]
    },
    {
        "id": "a992d6c9c2ed4a29",
        "type": "toggle",
        "z": "60ddb49f23d04d93",
        "name": "",
        "onOffTopic": "",
        "onValue": "reset",
        "onType": "str",
        "offValue": "reset",
        "offType": "str",
        "toggleTopic": "",
        "toggleValue": "true",
        "toggleType": "bool",
        "passOnOff": "",
        "x": 630,
        "y": 260,
        "wires": [
            [
                "c8efaaa7a598ca0c"
            ]
        ]
    },
    {
        "id": "c8efaaa7a598ca0c",
        "type": "change",
        "z": "60ddb49f23d04d93",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "reset",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 260,
        "wires": [
            [
                "40e5321e4f897792"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 April 2022 11:36 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/4 "2022-04-04T11:36:37Z")

</div>

> [@BWTH](#):
>
> i wan´t to toggle input from Raspi and convert this to msg.reset

What do you mean my toggle? Do you mean inverse? Or do you mean to flip between "on" and "off" or `true` and `false`? or do you mean when PIN 13 is HIGH to output a certain value?

Please explain exactly what you are hoping to get out of this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7d068138b9f57749fcca4eda4df70d11642c6ded.png)

do you expect `{ payload: "reset" }` or `{ reset: true }` or `{ reset: "reset" }` ?

---

<div class="post-metadata">

### Author: ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)
#### Post date: [4 April 2022 12:15 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/5 "2022-04-04T12:15:33Z")

</div>

> [@Steve-Mcl](#):
>
> when PIN 13 is HIGH

hi Steve  
when PIN 13 goes HIGH i wan´t to geht msg.reset, if pin 13 goas LOW do nothing

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 April 2022 12:19 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/6 "2022-04-04T12:19:45Z")

</div>

and what should `msg.reset` contain? a string? a boolean? a number?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 April 2022 12:23 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/7 "2022-04-04T12:23:57Z")

</div>

I think you simply want a switch node to filter out payload of `1` then a change node to set msg.whatever to "whatever" (no need for custom contrib nodes for something so simple)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6baedfdb70ee48043d1379dfaa5c9cdabcb9db1b.png)

```auto
[
    {
        "id": "40e5321e4f897792",
        "type": "debug",
        "z": "60ddb49f23d04d93",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "reset",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2290.000026702881,
        "y": 140.00000762939453,
        "wires": []
    },
    {
        "id": "6c967b019c09a4a1",
        "type": "rpi-gpio in",
        "z": "60ddb49f23d04d93",
        "name": "",
        "pin": "27",
        "intype": "up",
        "debounce": "25",
        "read": false,
        "bcm": true,
        "x": 1730.0000267028809,
        "y": 172.00000762939453,
        "wires": [
            [
                "9ae0c4c902857a66"
            ]
        ]
    },
    {
        "id": "c8efaaa7a598ca0c",
        "type": "change",
        "z": "60ddb49f23d04d93",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "reset",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2062.000026702881,
        "y": 172.00000762939453,
        "wires": [
            [
                "40e5321e4f897792",
                "203920077eb9627a"
            ]
        ]
    },
    {
        "id": "9ae0c4c902857a66",
        "type": "switch",
        "z": "60ddb49f23d04d93",
        "name": "== 1 ?",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1888.0000267028809,
        "y": 172.00000762939453,
        "wires": [
            [
                "c8efaaa7a598ca0c"
            ]
        ]
    },
    {
        "id": "203920077eb9627a",
        "type": "debug",
        "z": "60ddb49f23d04d93",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 2300.000026702881,
        "y": 204.00000762939453,
        "wires": []
    },
    {
        "id": "ef5d109123cb0925",
        "type": "inject",
        "z": "60ddb49f23d04d93",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 1740.0000267028809,
        "y": 252.00000762939453,
        "wires": [
            [
                "9ae0c4c902857a66"
            ]
        ]
    },
    {
        "id": "2fedda50742cbb8c",
        "type": "inject",
        "z": "60ddb49f23d04d93",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 1744.0000267028809,
        "y": 300.00000762939453,
        "wires": [
            [
                "9ae0c4c902857a66"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![BWTH](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@BWTH](https://discourse.nodered.org/u/BWTH)
#### Post date: [4 April 2022 12:30 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/8 "2022-04-04T12:30:20Z")

</div>

Thanks Steve, it works; i have to learn very much!!!

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [4 April 2022 12:31 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/9 "2022-04-04T12:31:05Z")

</div>

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<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: [3 June 2022 12:31 UTC](https://discourse.nodered.org/t/gpio-input-to-msg-reset/60761/10 "2022-06-03T12:31:55Z")

</div>

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