Checking The Operation Of Publish (Sending Of Mqtt Data) - Mitsubishi Electric MELSEC iQ-F Series Quick Start Manual

Hide thumbs Also See for MELSEC iQ-F Series:
Table of Contents

Advertisement

5.3
Checking the Operation of Publish (Sending of
MQTT Data)
Create a JSON string with M+StrProcessing_JSONSerialize_F, and use M+FX5ENET_MQTT_PublishSend (Sending of
MQTT data) to send messages to the server (MQTT broker).
(1)
M+StrProcessing_JSONSerialize_F
(1) FX5U CPU module
(2) FX5-ENET
FB library registration
Register the FB library. For the operating procedures, refer to the following.
Page 53 FB Library
Program
■Send data creation
• Settings for data to be sent
M50 (Execution command) turns on for setting the data to be sent.
M50
1
M_StrProcessing_JSONSerialize_F_00A_1.pb_st30Member[0].uType := K3; //Set the Value type to K3 (character string).
2
M_StrProcessing_JSONSerialize_F_00A_1.pb_st30Member[0].s32Key := 'Sample'; //Set the Key name to "Sample".
3
M_StrProcessing_JSONSerialize_F_00A_1.pb_st30Member[0].s64Value := 'MQTT_TEST'; //Set Value to "MQTT_TEST".
4
M_StrProcessing_JSONSerialize_F_00A_1.pb_st30Member[0].uDepth := K1; //Set the depth of layer to K1.
5
M_StrProcessing_JSONSerialize_F_00A_1.pb_st30Member[1].uType := K0; //Set the Value type to K0 (end of the member structure array).
• JSON string creation
When M50 (Execution command) turns on, the function block creates a JSON string in accordance with the information of
uType (Value type), s32Key (Key name), s64Value (value of Value), and uDepth (depth of layer) in the set member list
(pb_st30Member) and it outputs the string to the file register at the address specified with the start address of the JSON string
storage destination.
M50
JSON start address: K1000
5 CHECKING OPERATIONS
45

5.3 Checking the Operation of Publish (Sending of MQTT Data)

FB
FB
M+FX5ENET_MQTT_PublishSend
M_StrProcessing_JSONSerialize_F_00A_1
(M+StrProcessing_JSONSerialize_F_00A)
B: i_bEN
UD: i_udJSONAddr
D41
(2)
Publish
StrProcessing_JSONSerialize_FB
o_uJSONLength :UW
pb_st30Member
AWS
Set JSON start address to K1000.
DMOV
K1000
o_bENO :B
o_bOK :B
o_bErr :B
o_uErrId :UW
D42
D43
D41
M51
M52
M53

Advertisement

Table of Contents
loading

This manual is also suitable for:

Melsec iq-fx5-enet mqtt

Table of Contents