MQTT ---> S7 PLC (node-red-contrib-s7comm)

Project purpose: To receive MQTT payload and write each msg element to a S7 PLC tag.

data - STRING[22]
datetime - STRING[20]
devaddr - STRING[8]
fcnt - REAL
port - REAL
rssi - REAL

I have been able to inject json string and real values in to the S7 PLC (see debug messages 3 & 4). However, I am having trouble writing each of the objects from debug message 1 in to the S7 PLC. I used a json & function node to isolate the data string and that doesn't work either.


Any advice on the correct format which I should be sending this data through the flow so it will be accepted by the s7comm:write node would be greatly appreciated.



The issue was the format in which the MQTT message was split and sent to the PLC. S7 PLC requires the message as a javascript object within an array.

The important line was msg.payload = json.stringify(data);

Previously I wasn't changing the payload to a json string properly before it flowed through the json node to convert to javascript object.

Debug window showing correct format of message.

**image **