# Problems to "read out" mqtt Payload from DHT11

**URL:** <https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807>\
**Category:** General\
**Created:** [7 April 2021 10:04 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807 "2021-04-07T10:04:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bolle01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bolle01/32/56844_2.png) [@Bolle01](https://discourse.nodered.org/u/Bolle01)\
**Post date:** [7 April 2021 10:04 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/1 "2021-04-07T10:04:21Z")

</div>

Hi, i am new here and i can´t find my fault in a Function node. I want to read out the Temperature and Huminity from a Tasmota DHT11 Client. So i use the Function node to extract the Temperature and Huminity, but it will not work !  
 ![DHT11_Function](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/79948e32b05e3f28ad0bbb736091395472991b82.jpeg)  
I Used also the msg.payload = msg.payload.Temperature; but it returns The Payload is undefined.

 ![DHT11_Test](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf2e7571bb9b2a577394f39740d0a515504fcf23.jpeg)  
I Used a Testflow. The Injectnode sends a Teststring like the MQTT Client.  
Is anythin wrong with my Function nodes. Thank you for Support a Newbee.

```auto
[
    {
        "id": "9968598e.b88798",
        "type": "tab",
        "label": "Flow 3",
        "disabled": false,
        "info": ""
    },
    {
        "id": "9b8a73f.056939",
        "type": "inject",
        "z": "9968598e.b88798",
        "name": "Simulation DHT11",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"Time\":\"2021-04-06T18:20:04\",\"DHT11\":{\"Temperature\":38.0,\"Humidity\":25.0,\"DewPoint\":14.5},\"TempUnit\":\"C\"}",
        "payloadType": "str",
        "x": 270,
        "y": 80,
        "wires": [
            [
                "bb0529ee.da3168",
                "9c81b8e8.db70d8",
                "8f7ea74e.328278"
            ]
        ]
    },
    {
        "id": "bb0529ee.da3168",
        "type": "function",
        "z": "9968598e.b88798",
        "name": "Temperature Data",
        "func": "msg.payload = msg.Temperature;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 830,
        "y": 80,
        "wires": [
            [
                "aa4b43c9.b105a"
            ]
        ]
    },
    {
        "id": "8f7ea74e.328278",
        "type": "function",
        "z": "9968598e.b88798",
        "name": "Huminity Data",
        "func": "msg.payload = msg.Huminity;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 820,
        "y": 160,
        "wires": [
            [
                "42f17627.df3c88"
            ]
        ]
    },
    {
        "id": "fc6989c3.1f0b78",
        "type": "mqtt in",
        "z": "9968598e.b88798",
        "name": "Temp/Humin DHT11",
        "topic": "Gewaechshaus/DHT11_01/SENSOR",
        "qos": "0",
        "datatype": "auto",
        "broker": "798105ff.8a59ac",
        "x": 270,
        "y": 160,
        "wires": [
            [
                "8f7ea74e.328278",
                "9c81b8e8.db70d8",
                "bb0529ee.da3168"
            ]
        ]
    },
    {
        "id": "aa4b43c9.b105a",
        "type": "debug",
        "z": "9968598e.b88798",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 80,
        "wires": []
    },
    {
        "id": "42f17627.df3c88",
        "type": "debug",
        "z": "9968598e.b88798",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 160,
        "wires": []
    },
    {
        "id": "9c81b8e8.db70d8",
        "type": "debug",
        "z": "9968598e.b88798",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 270,
        "y": 120,
        "wires": []
    },
    {
        "id": "798105ff.8a59ac",
        "type": "mqtt-broker",
        "name": "MQTT Broker",
        "broker": "192.168.120.220",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 April 2021 10:18 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/2 "2021-04-07T10:18:42Z")

</div>

The data you show in the debug node is a string. If you change the config of the MQTT node to output a Parsed JSON Object then it will parse the JSON string and output a javascript object, which is what you want.

---

<div class="post-metadata">

**Author:** ![Bolle01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bolle01/32/56844_2.png) [@Bolle01](https://discourse.nodered.org/u/Bolle01)\
**Post date:** [7 April 2021 11:21 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/3 "2021-04-07T11:21:22Z")

</div>

Hi Colin, thank you for Support and your Patience  
But when i change the Output to Parsed JSON Object my Payload shows :  
{"Time":"2021-04-06T18:20:04","DHT11":{"Temperature":38,"Humidity":25,"DewPoint":14.5},"TempUnit":"C"}  
The Function Node with "msg.payload = msg.Temperature;" or "msg.payload = msg.payload.Temperature;"  
repeat´s  
Gewaechshaus/DHT11\_01/SENSOR : msg.payload : undefined

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 April 2021 12:05 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/4 "2021-04-07T12:05:34Z")

</div>

Try using msg.payload.DHT11.temperature and  
msg.payload.DHT11.humidity

---

<div class="post-metadata">

**Author:** ![Bolle01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bolle01/32/56844_2.png) [@Bolle01](https://discourse.nodered.org/u/Bolle01)\
**Post date:** [7 April 2021 12:33 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/5 "2021-04-07T12:33:56Z")

</div>

Thank You so much Paul, You make an old man happy.  
I´ll pray for you this evening. Google is also happy less search Traffic  
Juergen

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [7 April 2021 14:28 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/6 "2021-04-07T14:28:37Z")

</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:** [21 April 2021 14:28 UTC](https://discourse.nodered.org/t/problems-to-read-out-mqtt-payload-from-dht11/43807/7 "2021-04-21T14:28:57Z")

</div>

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