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:
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:
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
system
Closed
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.