# Weird Y Axis generated by MQTT

**URL:** https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416
**Category:** Dashboard
**Created:** [31 May 2024 20:35 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416 "2024-05-31T20:35:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discourse.nodered.org/u/Greg)
#### Post date: [31 May 2024 20:35 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416/1 "2024-05-31T20:35:10Z")

</div>

I have an issue with my dashboard. Using almost identical code, I end up with nonsense for the left axis on pool room while the outdoor stuff seems fine.

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

The data is input using MQTT and the gauge and graph have the exact same payloads, so why is the Y axis so weird?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75ea824df7fdc5fe44eb380ae357d9a39267219c.png)

Here is the underlying code:

```auto
[
    {
        "id": "ebbaaf1fbb49d248",
        "type": "mqtt in",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "topic": "indoor_temp_topic",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "c6bf5d021264d8e1",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 170,
        "y": 180,
        "wires": [
            [
                "a6eb72edd2662bb8",
                "f495317ab40f3852",
                "654176514a578ae5"
            ]
        ]
    },
    {
        "id": "82604fbed3287434",
        "type": "mqtt in",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "topic": "indoor_humidity_topic",
        "qos": "0",
        "datatype": "auto-detect",
        "broker": "c6bf5d021264d8e1",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 180,
        "y": 300,
        "wires": [
            [
                "0eec4248f657dcab",
                "3a58ae216556eea4",
                "fc0b23b51621a17c"
            ]
        ]
    },
    {
        "id": "654176514a578ae5",
        "type": "ui_gauge",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "group": "570d12a99fb5ce3d",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Pool Room Temperature",
        "label": "°F",
        "format": "{{value}} °F",
        "min": 0,
        "max": "110",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 510,
        "y": 200,
        "wires": []
    },
    {
        "id": "0eec4248f657dcab",
        "type": "ui_gauge",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "group": "570d12a99fb5ce3d",
        "order": 5,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Pool Room Humidity ",
        "label": "% RH",
        "format": "{{value}}% RH",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "45",
        "seg2": "59",
        "diff": false,
        "className": "",
        "x": 500,
        "y": 300,
        "wires": []
    },
    {
        "id": "3a58ae216556eea4",
        "type": "ui_chart",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "group": "570d12a99fb5ce3d",
        "order": 7,
        "width": 0,
        "height": 0,
        "label": "Pool Room Humidity",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": "1",
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 500,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "f495317ab40f3852",
        "type": "ui_chart",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "group": "570d12a99fb5ce3d",
        "order": 6,
        "width": "0",
        "height": "0",
        "label": "Pool Room Temperature",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 510,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "a6eb72edd2662bb8",
        "type": "function",
        "z": "1e6d0cc92960bc78",
        "name": "inTemp",
        "func": "flow.get(\"GV_Indoor_Temp\");\nglobal.set(\"GV_Indoor_Temp\", msg.payload);\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 120,
        "wires": [
            [
                "f40ea75a5aa47093"
            ]
        ]
    },
    {
        "id": "8937281cdaa1872f",
        "type": "comment",
        "z": "1e6d0cc92960bc78",
        "name": "",
        "info": "Used functions named GV to store in a \nGlobal Variable, indoor and outdoor \nTemp and humidity\nThis should make them available to \nuse in If Then statements to control\nthe Fans and Louver\nThe Variables are\n GV_IndoorTemp\n GV_IndoorHumidity\n GV_OutdoorTemp\n GV_OutdoorHumidity\n",
        "x": 120,
        "y": 120,
        "wires": []
    },
    {
        "id": "fc0b23b51621a17c",
        "type": "function",
        "z": "1e6d0cc92960bc78",
        "name": "InHumidy",
        "func": "flow.get(\"GV_Indoor_Humidity\");\nglobal.set(\"GV_Indoor_Humidity\", msg.payload);\nreturn msg;",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 360,
        "y": 260,
        "wires": [
            [
                "b41f051f986e2444"
            ]
        ]
    },
    {
        "id": "b41f051f986e2444",
        "type": "link out",
        "z": "1e6d0cc92960bc78",
        "name": "Indoor Humidity",
        "mode": "link",
        "links": [
            "be08956c157be950"
        ],
        "x": 625,
        "y": 260,
        "wires": []
    },
    {
        "id": "f40ea75a5aa47093",
        "type": "link out",
        "z": "1e6d0cc92960bc78",
        "name": "Indoor Temp",
        "mode": "link",
        "links": [
            "590d94db0ef1ab01",
            "f211bb67c0fddbd4"
        ],
        "x": 625,
        "y": 120,
        "wires": []
    },
    {
        "id": "c6bf5d021264d8e1",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.50.168",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "1",
        "birthRetain": "true",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "570d12a99fb5ce3d",
        "type": "ui_group",
        "name": "",
        "tab": "08c882008efdc3a0",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "08c882008efdc3a0",
        "type": "ui_tab",
        "name": "Pool Room Humidity Control",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<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: [31 May 2024 20:57 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416/2 "2024-05-31T20:57:23Z")

</div>

Add debug nodes to your flow and work out which node is not doing what you expect.

---

<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: [31 May 2024 21:25 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416/3 "2024-05-31T21:25:36Z")

</div>

> [@Greg](#):
>
> and the gauge and graph have the exact same payload

The gauge shows NOW, the graph shows historical. Those high values must have occurred at some point.

Add a switch node to filter out "unlikely" values.

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

While that doesnt fix the problem, the debug will help you understand what is going on.

PS: double check your topic is not being written to by other publishers.

PS2: to help improve maintainability and readability, I would suggest you give your topics better names. e.g. `room/pool/temperature` is way better than `indoor_humidity_topic` (using `xxx/yyy/zzz` topics lets you subscribe to many topics using various wildcards e.g. `room/+/temperature` or `room/pool/#`)

---

<div class="post-metadata">

### Author: ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discourse.nodered.org/u/Greg)
#### Post date: [1 June 2024 00:53 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416/4 "2024-06-01T00:53:28Z")

</div>

Thanks. We are on the same page. I had re-written the flow like your suggestion right after I posted. No joy - until I rebooted the Raspberry Pi. Then it worked.

I think the problem is that the initial payload for a very short period of time is the date, even though the MQTT payload is just temp or humidity. That long list of numbers then gets used to set the automatic Y axis. I also tried to fix the Y axis scales to typical temperature and humidity ranges. No joy, even if I rebooted the Pi. Not too sure what that doesn't work.

I will revise my topics. Your suggestion is great.

Thanks. This solved my problem (using a switch node to only permit reasonable numbers for temperature and humidity to pass)

---

<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: [1 July 2024 00:53 UTC](https://discourse.nodered.org/t/weird-y-axis-generated-by-mqtt/88416/5 "2024-07-01T00:53:45Z")

</div>

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