OptiCloud MQTT JSON schema

This is a guide to our JSON schematics for when sending data to Opticloud.
Basic message structure
{
"time":"timestamp ISO8601 yy-mm-ddThh-mm-ssz",
"inputType":"string[30]",
"functions":
[{
"deviceId":"string[30]",
"name":"string[30]",
"value":"string[128]",
"time":"timestamp ISO8601 yy-mm-ddThh-mm-ssz"
}]
}
“time”
The “time” field is the timespan of when the event or state occurred.
The first time field is the timestamp for when the message was sent. The timestamp in functions is for the message itself, so when a part was counted or when the machine went into run mode.
All timestamps should be in the UTC time zone.
“inputType”
The input type is typically also referred to as tags in PLCs and typically has its own topic in our IoT broker. The inputType is a string and can either be MachineState, PartCounter, AddPartInformation, or Telemetry.
“functions”
functions are basically the payload of the message. One message can contain multiple functions/payloads, essentially blocks of data. When talking real-time data, it’ll typically only contain one, because the message is being sent when the MachineState arrives i.e.
“deviceId”
The device ID is a unique ID given by the IoT Hub. The device ID is the link between the device and the machine in Opticloud. Typically looks something like: “OL01010”, “OM01010”, “MA01010” or “SC01010”.
If needed Optipeople can provide customized device IDs.
“name”
Name is being used as another parameter to identify what type of data is being sent and where it belongs. Machine states only use the “name”:”state”, whereas “PartCounter” can use multiple at once because you can have multiple part counters per machine. For example: “PartCounter”:”Parts”, “PartCounter”:”Parts2″, “PartCounter”:”m2″, “PartCounter”:”Kilos”, etc.
“value”
For machine states, the value is either Runtime, Downtime, or any stop reason. It’s a string and takes any type of text. The Runtime is being used to indicate that the machine is running or stopped and vice versa, and if you input any other thing it’ll be like downtime but with a specific cause.
Message example: Machine state
{
"time":"2022-04-25T07:50:18.039Z",
"inputType":"MachineState",
"functions":
[{
"deviceId":"OL01010",
"name":"state",
"value":"Runtime",
"time":"2022-04-25T07:50:18.039Z"
}]
}
Remember: The field with “Runtime” is where you indicate if the machine is running or stopped. If stopped, it’s “Downtime” instead. You can input “Some stop reason” to indicate why the machine is stopped.
Message example: Partcounters
{
"time":"2022-04-25T07:50:18.039Z",
"inputType":"PartCounter",
"functions":
[{
"deviceId":"OL01010",
"name":"Parts",
"value":"420",
"time":"2022-04-25T07:50:18.039Z"
},
{
"deviceId":"OL01010",
"name":"m2",
"value":"420",
"time":"2022-04-25T07:50:18.039Z"
}]
}
In the above example, I’ve included two different part counters but in the same message. One for ordinary parts and one for square meters. You can add as many as you want.
Message example: Add part information (Batch/order/item numbers)
{
"time":"2022-04-25T07:50:18.039Z",
"inputType":"AddPartInformation",
"functions":
[{
"deviceId":"OL01010",
"name":"OrderX;ItemY;PartZ",
"value":"null",
"expectedSpeed":"100",
"time":"2022-04-25T07:50:18.039Z"
}]
}
The order and/or item number you are producing should go into the name field. You can also include both or anything else, as long as you separate them by a semicolon or something else that is not included in the number or name.
Expected speed is how many parts/units the machine can produce per hour.
Message example: Telemetry
{
"time":"2022-04-25T07:50:18.039Z",
"inputType":"Telemetry",
"functions":
[{
"deviceId":"OL01010",
"name":"Temperature",
"value":"41",
"type":"1",
"time":"2022-04-25T07:50:18.039Z"
}]
}
The inputType Telemetry can be used to send any kind of data to Opticloud. Most used are temperature, humidity, vibration, and QR/Bar codes. The field “name” is typically the sensor name or tag from PLC. If you only have tag IDs in the PLC, no worries, in the cloud you can give it a more friendly name. So if you can only send some unique ID for the tag/sensor, you can attach this ID to another name in the cloud.
The field “type” can either be 1, 2, or 3.
1 is for integers.
2 is for decimals.
3 is for text.
So by using the correct number in “type” you can send whatever data you need to be displayed in OptiCloud.
Message example: Rejection of parts for quality
{
"time":"2022-04-25T07:50:18.039Z",
"inputType":"PartRejection",
"functions":
[{
"deviceId":"OL01010",
"name":"Parts",
"value":"-1",
"time":"2022-04-25T07:50:18.039Z"
}]
}
The rejection of parts works essentially the same as the part counter. It’s just called PartRejection instead of PartCounter. The value you type in the field “value” will be subtracted from the counted parts in OptiCloud. It doesn’t matter if you write -1 or 1.
Book a demo
Enter your name, company and telephone number below, and we will call and arrange a meeting as soon as possible.
Book a demo
Enter your name and company mail, and we will arrange a demo as soon as possible.