Hi there,
I'm trying to publish a Sparkplug B message from node-red, but I don't get how I'm supposed to do that. This is my flow:
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/9/c/9c3a9f7782507434f47138e733f0e10a5899039d.png)
msg.topic = "spBv1.0/namespace/group/device/edgeNode/sensor1";
msg.payload = {
"bn": "sensor1/",
"n": "value",
"t": 1,
"v": Math.random() * 100
};
return msg;
But, the output I get in the debug is this:
![image](https://global.discourse-cdn.com/business6/uploads/nodered/original/3X/a/6/a62a7631de715f2e7c1d206119a80673cac9272d.png)
I'm very new to sparkplug but this works for me
let seq = flow.get('seq') || 1
msg.topic = "spBv1.0/FactoryA/DDATA/ProductionLine03/dev04a"
msg.payload = {}
msg.payload.timestamp = new Date().getTime()
msg.payload.seq = seq
msg.payload.metrics = [
{
"name": "externalTemperature",
"value": 14.1,
"type": "Float"
},
{
"name": "humidity",
"value": 88,
"type": "UInt16"
},
{
"name": "pressure",
"value": 77,
"type": "UInt16"
},
{
"name": "temperature",
"value": 22.2,
"type": "Float"
}
]
seq++
flow.set('seq',seq)
return msg