-
Notifications
You must be signed in to change notification settings - Fork 224
Visualize data from the diyBMS
The controller can send data to either MQTT, influxDB or both. Not all data are pushed to influxDB for example you cannot see relay status. The controller is also quite overloaded so it's best to just enable either or.
Here is a description how to use MQTT then used NodeRED to push data into InfluxDB 2.0 database then visualise the data using Grafana.
Prerequisites :
- MQTT server - Mosquitto
- InfluxDB 2.0 server
- NodeRED server
- Grafana server
I assume you have done following :
- Created an user in Mosquitto
- Configure diyBMS to use the Mosquitto server and you are receiving data -> use MQTTBox to test and subscribe to diyBMS/# and see if data is indeed coming from diyBMS, if not check your diyBMS and Mosquitto settings
- Setup NodeRED server and make a connection to Mosquitto server. You can test that you get data by drawing a connection between the MQTT node and a debug node.
Do following
- Head over to Flux UI interface and login (it runs on port 8086 so url would be http://your-influx-host-ip:8086)
- Create a organization and a bucket (check the Influx documentation how to do that from the UI)
- When you have created the organization look at the url : http://your-influx-host-ip:8086/orgs/c6278d4a10130f7b notice the
c6278d4a10130f7b
, that is your organization ID which is needed in NodeRED together with the bucket name you created in Flux. - Add following flows in NodeRED (change the bucketname and organization on the Flux node to match yours)
[
{
"id": "d737058.bd3b5f8",
"type": "comment",
"z": "efe93325.55893",
"name": "Push cell data from MQTT to InfluxDB",
"info": "",
"x": 300,
"y": 270,
"wires": []
},
{
"id": "4146fd37.aa7214",
"type": "comment",
"z": "efe93325.55893",
"name": "Push diyBMS status from MQTT to InfluxDB",
"info": "",
"x": 320,
"y": 375,
"wires": []
},
{
"id": "bb75249b.baa748",
"type": "comment",
"z": "efe93325.55893",
"name": "Push diyBMS relay status from MQTT to InfluxDB",
"info": "",
"x": 330,
"y": 495,
"wires": []
},
{
"id": "d2e3da5e.46cb48",
"type": "influxdb out",
"z": "efe93325.55893",
"influxdb": "a6fdab90.b072d8",
"name": "",
"measurement": "",
"precision": "",
"retentionPolicy": "",
"database": "database",
"precisionV18FluxV20": "ms",
"retentionPolicyV18Flux": "",
"org": "home",
"bucket": "diybms",
"x": 910,
"y": 675,
"wires": []
},
{
"id": "5f31136b.6f802c",
"type": "comment",
"z": "efe93325.55893",
"name": "Push diyBMS rules status from MQTT to InfluxDB",
"info": "",
"x": 330,
"y": 765,
"wires": []
},
{
"id": "60dc208.35703e",
"type": "change",
"z": "efe93325.55893",
"name": "relay2",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "relays",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"1\"\t },\t {\t \"relay\":\"2\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 585,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "a5494dd2.bb4c1",
"type": "change",
"z": "efe93325.55893",
"name": "relay3",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "relays",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"2\"\t },\t {\t \"relay\":\"3\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 630,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "c0aa04b9.bd0858",
"type": "change",
"z": "efe93325.55893",
"name": "relay4",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "relays",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"3\"\t },\t {\t \"relay\":\"4\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 675,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "11d99b54.441385",
"type": "mqtt in",
"z": "efe93325.55893",
"name": "",
"topic": "diybms/output",
"qos": "2",
"datatype": "json",
"broker": "d77c97be.ca8e08",
"x": 230,
"y": 600,
"wires": [
[
"4b948575.b5c37c",
"60dc208.35703e",
"a5494dd2.bb4c1",
"c0aa04b9.bd0858"
]
]
},
{
"id": "4b948575.b5c37c",
"type": "change",
"z": "efe93325.55893",
"name": "relay1",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "relays",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"relay\":\"1\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 540,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "d860bb6e.6de468",
"type": "change",
"z": "efe93325.55893",
"name": "",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "cells",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t payload,\t {\t \"cell\":$substringAfter($.topic, 'diybms\\/0\\/')\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 410,
"y": 315,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "2d6c5e93.760ba2",
"type": "change",
"z": "efe93325.55893",
"name": "",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "status",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\t \"uptime\": payload.uptime,\t \"bankVoltage\": payload.bankVoltage[0],\t \"comserr\": payload.monitor.commserr,\t \"sent\": payload.monitor.sent,\t \"received\" : payload.monitor.received,\t \"badcrc\" : payload.monitor.badcrc,\t \"ignored\" : payload.monitor.ignored,\t \"oss\" : payload.monitor.oss,\t \"roundtrip\" : payload.monitor.roundtrip\t}",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 425,
"y": 420,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "ca71e196.4e9b7",
"type": "change",
"z": "efe93325.55893",
"name": "rule1",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"1\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 825,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "172d8ecc.c116a1",
"type": "mqtt in",
"z": "efe93325.55893",
"name": "",
"topic": "diybms/0/#",
"qos": "2",
"datatype": "json",
"broker": "d77c97be.ca8e08",
"x": 220,
"y": 315,
"wires": [
[
"d860bb6e.6de468"
]
]
},
{
"id": "830f3ce9.9c478",
"type": "mqtt in",
"z": "efe93325.55893",
"name": "",
"topic": "diybms/status",
"qos": "2",
"datatype": "json",
"broker": "d77c97be.ca8e08",
"x": 220,
"y": 420,
"wires": [
[
"2d6c5e93.760ba2"
]
]
},
{
"id": "f55b4ea.29e3cb",
"type": "mqtt in",
"z": "efe93325.55893",
"name": "",
"topic": "diybms/rule",
"qos": "2",
"datatype": "json",
"broker": "d77c97be.ca8e08",
"x": 220,
"y": 1020,
"wires": [
[
"ca71e196.4e9b7",
"213a9d0f.eed592",
"7f6f74a1.b55a2c",
"749c1cc2.344c24",
"1eac9398.9a358c",
"c6f226e4.30ae78",
"f721fa6a.7c75a8",
"2637ac1d.928b54",
"299e0e34.9876b2",
"2a7fca0e.25e1c6",
"25f975c8.dce94a"
]
]
},
{
"id": "213a9d0f.eed592",
"type": "change",
"z": "efe93325.55893",
"name": "rule2",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"2\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 870,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "7f6f74a1.b55a2c",
"type": "change",
"z": "efe93325.55893",
"name": "rule3",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"3\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 915,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "749c1cc2.344c24",
"type": "change",
"z": "efe93325.55893",
"name": "rule4",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"4\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 960,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "1eac9398.9a358c",
"type": "change",
"z": "efe93325.55893",
"name": "rule5",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"5\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1005,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "c6f226e4.30ae78",
"type": "change",
"z": "efe93325.55893",
"name": "rule6",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"6\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1050,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "f721fa6a.7c75a8",
"type": "change",
"z": "efe93325.55893",
"name": "rule7",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"7\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1095,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "2637ac1d.928b54",
"type": "change",
"z": "efe93325.55893",
"name": "rule8",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"8\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1140,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "299e0e34.9876b2",
"type": "change",
"z": "efe93325.55893",
"name": "rule9",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"9\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1185,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "2a7fca0e.25e1c6",
"type": "change",
"z": "efe93325.55893",
"name": "rule10",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"10\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1230,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "25f975c8.dce94a",
"type": "change",
"z": "efe93325.55893",
"name": "rule11",
"rules": [
{
"t": "set",
"p": "measurement",
"pt": "msg",
"to": "rules",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "[\t {\t \"state\":payload.\"0\"\t },\t {\t \"rule\":\"11\"\t }\t]",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 500,
"y": 1275,
"wires": [
[
"d2e3da5e.46cb48"
]
]
},
{
"id": "a6fdab90.b072d8",
"type": "influxdb",
"hostname": "127.0.0.1",
"port": "8086",
"protocol": "http",
"database": "database",
"name": "Influx",
"usetls": false,
"tls": "",
"influxdbVersion": "2.0",
"url": "http://influxdb:8086",
"rejectUnauthorized": true
},
{
"id": "d77c97be.ca8e08",
"type": "mqtt-broker",
"name": "Mosquitto",
"broker": "10.10.0.9",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
The flows looks like this :
- Deploy your NodeRED change
- Head over to Flux UI interface again and go to Data Explorer and select the bucket you created. As soon as you select it you should see tags like this :
If you don't see them then go back and check diyBMS -> mosquitto -> NodeRed -> InfluxDB settings.
- Head over to your Grafana server and add a Influx connection, make sure you choose Flux language and use same organization id and bucket as before.
- Import the dashboard i made from here (use Import in Grafana and either paste the JSON below or paste the JSON in a file and save it with extension .json then import the file :
Here is how the Grafana dashboard looks if everything works as it should:
Note: You should be all setup now but you probably have to fix the queries if your bucket is not named diybms
and if your Influx connection in Grafana is not named InfluxDB2
. Also the above covers only one pack, if you have multiple packs you would have to change some things.