If in doubt about the operation or use, please contact your local Mitsubishi Electric representative. • Mitsubishi Electric will not accept responsibility for actual use of the product based on these illustrative examples. Please use it after confirming the function and safety of the equipment and system.
RELEVANT MANUALS The following relevant manuals can be downloaded from the Mitsubishi Electric FA site. www.mitsubishielectric.co.jp/fa/ref/ref.html?kisyu=plcf&manual=download_all [: Available, : Not available] Manual name Available form <manual number> e-Manual MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware) <SH-082452ENG> MELSEC iQ-F FX5 User's Manual (Application) <JY997D55401>...
TERMS Unless otherwise specified, this manual uses the following terms. Term Description Broker An MQTT server that mediates messages (MQTT broker) Engineering tool The product name of the software package for the MELSEC programmable controllers Message Data to be exchanged between the sender (publisher) and receiver (subscriber) Publish/Subscribe message exchange A protocol capable of one-to-many asynchronous communications.
KEY FEATURES Publish: Sending information collected in the FX5 CPU module to the MQTT broker with the MQTT communication function, Subscribe: Subscribing the information from the MQTT broker MQTT is an OASIS-standard communication protocol using a publish/subscribe message exchange model. Once the FX5- ENET executes publishing to the MQTT broker, information is distributed to all the information receive devices that have executed the subscribe request.
APPLICABLE MODELS The following models can be used for a series of operations described in this manual. FX5UJ CPU module FX5U CPU module FX5UC CPU module Ethernet module (FX5-ENET) 1 APPLICABLE MODELS...
PREPARATION This manual describes a configuration example in which an FX5-ENET is connected to an FX5U CPU module and is connected to AWS via a router. To use applicable CPU modules other than the FX5U CPU module, refer to the following manuals. MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware) MELSEC iQ-F FX5 Ethernet Module User's Manual, Appendix 7 Added and Changed Functions System Configuration...
Certificate Configuration Tool for FX5-ENET • Firmware version: 1.280 or later • Firmware version: 1.200 or later • Applicable software version: 1.00A or later *1 To obtain the latest version, please contact your local Mitsubishi Electric representative. Router Three Ethernet cables AWS account...
CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) This chapter describes the setting items for the clients (MQTT Publisher, MQTT Subscriber). Configuring Settings with GX Works3 This section describes how to configure the settings with GX Works3. Procedure for setting parameters Open the "Navigation" window [Module Configuration]. Drag and drop [FX5-ENET] to add it. Drag and drop Double-click [FX5-ENET] on [Module Configuration].
Page 14
Change [Use Module Label] to [Yes] and click the [OK] button. Click the [OK] button. Select [Basic Settings] [Own Node Settings] and configure [IP Address] as shown below. Item Setting IP Address 192.168.3.13 Subnet Mask 255.255.255.0 Default Gateway 192.168.3.1 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.1 Configuring Settings with GX Works3...
Page 15
Select [Basic Settings] [External Device Configuration] and double-click <Detailed Setting>. Drag and drop [MQTT Connection Module] to add it. Set the protocol and port number as shown below, and click [Close with Reflecting the Setting]. Item Setting Protocol Port No. 50000 Drag and drop Drag and drop...
Page 16
Select [Application Settings] and configure [DNS Settings] as shown below. Item Setting To Use or Not to Use DNS Server Settings DNS Server 1 Address 8.8.8.8 DNS Server 2 Address 8.8.4.4 DNS Server 3 Address 1.1.1.1 DNS Server 4 Address 1.0.0.1 Select [Application Settings] ...
Page 17
To avoid errors, temporarily enter arbitrary character strings for "MQTT Server Host Name" and "Client ID". Click the [Apply] button. Configure the proper settings at the following timing. Page 40 Configuring Settings with GX Works3 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.1 Configuring Settings with GX Works3...
Configuring communication settings with GX Works3 Directly connect the Ethernet ports as shown below. To execute the writing process, perform a communication test first. FX5U CPU module Ethernet Select [Online] [Current Connection Destination]. Select "Direct Coupled Setting". 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.1 Configuring Settings with GX Works3...
Page 19
Specify an Ethernet adapter of the personal computer which is used when the personal computer is directly connected to the CPU module. When [Not Specified] is set, select an adapter to be used from the drop-down list. After the adapter is selected, click the [Communication Test] button. For the connection via a hub, refer to the following.
Writing data to the programmable controller Write the program to the FX5U CPU module. The operation to determine the programs and the parameters is required before writing them to the programmable controller. Select [Convert] [Rebuild All]. Click the [OK] button. Select [Online] ...
Page 21
Configure the following settings and click the [Execute] button. For the setting details, refer to the following. GX Works3 Operating Manual Select [Online] [Write to PLC]. 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.1 Configuring Settings with GX Works3...
Page 22
Click [Parameter + Program], and click [Execute]. When the following window appears, click [Yes to all]. After the writing is complete, reset (or power off and on) the FX5U CPU module. 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.1 Configuring Settings with GX Works3...
Configuring Settings with Certificate Configuration Tool for FX5-ENET Start Certificate Configuration Tool for FX5-ENET, set the certificate, and perform the writing process. Certificate Configuration Tool for FX5-ENET FX5-ENET Ethernet Because the settings cannot be written to the FX5-ENET with the connection of a personal computer and an FX5U CPU module, connect a personal computer and the FX5-ENET with an Ethernet cable.
Page 24
Select [Connection Settings]. Enter the IP address of the FX5-ENET in [Host (IP Address)] and click the [Communication Test] button. • If a firewall is set up between the FX5-ENET and the personal computer, the communication test will fail. In this case, permission must be given to a port to be used, so check the firewall settings.
Page 25
Click the [Yes] button. When generation is completed, click the [Get a CSR] button, name the CSR file, and save it. The saved CSR file is used when issuing certificates in AWS. Page 32 Creating a certificate 3 CONFIGURING CLIENTS (MQTT PUBLISHER, MQTT SUBSCRIBER) 3.2 Configuring Settings with Certificate Configuration Tool for FX5-ENET...
CONFIGURING SERVER (MQTT BROKER) CONNECTION This chapter describes the setting items for the server (MQTT broker). Configuring Settings with AWS Configure the server (MQTT broker) for connecting to AWS. Configure the server (MQTT broker) while signed in to AWS Management Console. Prepare your account ID, user name, password, and IAM user in advance.
Configuring settings with AWS IoT services Configure the AWS IoT services to be used with AWS connection. The settings required for MQTT communication between the FX5-ENET and AWS IoT services are as follows. • Policies • Things • Certificates On the top left, select [Services] [Internet of Things] [IoT Core]. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 28
Creating a policy A policy manages which operations to be allowed for things. Configure detailed settings for MQTT communication by associating things and certificates. Select [Security] [Policies] from the left menu and click the [Create policy] button. Configure settings as shown below, and click the [Create] button. Item Setting Policy name...
Page 29
The policy is added to the list. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 30
Creating AWS IoT things A thing is an object that connects to the Internet. In this manual, this refers to the FX5-ENET. Select [Manage] [All devices] [Things] from the left menu, and click the [Create things] button. Select [Create single thing] and click the [Next] button. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 31
Configure settings as shown below, and click the [Next] button. Item Setting Thing name Any name Device Shadow No shadow Select [Skip creating a certificate at this time] and click the [Create thing] button. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 32
The thing is added to the list. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 33
Creating a certificate A certificate authenticates the connection between a device and a client. To enable a device or client to communicate with AWS IoT, a certificate must be registered and activated with AWS IoT. Select [Security] [Certificates] from the left menu and click the [Create certificate] button. Select [Create certificate with certificate signing request (CSR)].
Page 34
Download [Device certificate]. This certificate is required for writing to the FX5-ENET. (Page 37 Writing a certificate) When downloading is completed, click the [Continue] button. The certificate is added to the list. Click the certificate ID created now. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 35
Click the [Attach policies] button in [Policies]. Select the created policy name and click the [Attach policies] button. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Page 36
Click the [Attach to things] button in [Things]. Select the name of the created thing, and click the [Attach to thing] button. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.1 Configuring Settings with AWS...
Checking an endpoint An endpoint represents a URL required for connecting to AWS services. The endpoint will be needed for configuring the GX Works3 settings. Therefore, users are recommended to copy and keep it. (The URL must be copied with "********.amazonaws.com" included.) Select [Settings] in the left menu.
Configuring Settings with Certificate Configuration Tool for FX5-ENET Writing a certificate In Certificate Configuration Tool for FX5-ENET, click [Client Certificates] [Replace] button. Click the [Yes] button. Select the certificate (*.crt) downloaded in Page 32 Creating a certificate and import the certificate. If the certificate (*.crt) is not displayed, delete the end of the file name (.crt).
Page 39
Download the server certificate (sf-class2-root.crt) from AWS. The certificate can be downloaded from the following (as of the publication of this manual). https://aws.amazon.com/blogs/security/how-to-prepare-for-aws-move-to-its-own-certificate-authority/ ?nc1=h_ls Certificates have expiration dates. For the latest information, check the website of AWS. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.2 Configuring Settings with Certificate Configuration Tool for FX5-ENET...
Page 40
In Certificate Configuration Tool for FX5-ENET, select [Server Certificates] [Import] button to import the server certificate (sf-class2-root.crt). When the file has normally been imported, click the [Write] button to write it to the FX5-ENET. Click the [Yes] button. Click the [Yes] button. 4 CONFIGURING SERVER (MQTT BROKER) CONNECTION 4.2 Configuring Settings with Certificate Configuration Tool for FX5-ENET...
CHECKING OPERATIONS Based on the system configuration (Page 9 System Configuration), write the program to the FX5U CPU module and check the operation. GX Works3 Certificate Configuration Tool for FX5-ENET (1) FX5U CPU module (2) FX5-ENET (3) Router Checking the Operation of Connect (MQTT Connection Establishment) Use M+FX5ENET_MQTT_Connect (MQTT connection establishment) for controlling the connection with the server (MQTT broker).
Page 43
Program M12 turns on for setting the information used for M+ENET_MQTT_Connect (MQTT connection establishment). SM402 $MOV MQTT_TEST/Will/Topic/Name Set the Will topic name data for R0. $MOV MQTT_TEST Will message R300 Set the Will message data for R300. $MOV MQTT_TEST/topic/name R600 Set the Publish/Subscribe topic name data for R600.
Page 44
After M4 (Enable Will) turns on, M0 turns on. When FX5ENET_1.uSts_CertFuncReadyStatus_D (Certificate function ready-to- enable state) turns on, M14 (Execution command) turns on. M1 (CONNECT instruction) subsequently turns on to establish the connection. When the connection is successfully established, M9 (Establishment completion) turns on. FX5ENET_1.uSts_CertFuncReadyStatus_D TEST U1\G108899...
Checking the Operation of Subscribe (Sending of Subscribe Command) Use M+FX5ENET_MQTT_Subscribe (Sending of Subscribe command) for sending a SUBSCRIBE/UNSUBSCRIBE command to the server (MQTT broker). Subscribe M+FX5ENET_MQTT_Subscribe (1) FX5U CPU module (2) FX5-ENET Program M27 turns on for setting the information used for M+ENET_MQTT_Subscribe (Sending of Subscribe command). Set subscribe ID to K1.
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). Publish M+StrProcessing_JSONSerialize_F M+FX5ENET_MQTT_PublishSend (1) FX5U CPU module (2) FX5-ENET FB library registration Register the FB library.
Page 47
■Sending of message data M67 turns on for setting the information used for M+ENET_MQTT_PublishSend (Sending of MQTT data). Set QoS to K0. Set the binary/ASCII/Unicode strings to K0. K600 Set the Publish topic name data start address to K600. Set the Publish message size to K0. M69 (Execution command) turns on.
Checking the Operation of Subscribe (Receiving of MQTT Data) Use M+FX5ENET_MQTT_Receive (Receiving of MQTT data) for reading a message received from the server (MQTT broker). Publish M+StrProcessing_JSONDeserialize_F M+FX5ENET_MQTT_Receive (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 5 CHECKING OPERATIONS 5.4 Checking the Operation of Subscribe (Receiving of MQTT Data)
Page 49
Program ■Receiving of message data M34 turns on for setting the information used for M+ENET_MQTT_Receive (Receiving of MQTT data). K1100 Set the receive topic name data start address to K1100. K1300 Set the receive message data start address to K1300. M36 (Execution command) turns on for storing the receive data into the specified file register.
Page 50
Checking reception on GX Works3 Messages received from AWS can be checked from the "Device/Buffer Memory Batch Monitor" of GX Works3. [Online] [Monitor] [Device/Buffer Memory Batch Monitor] 5 CHECKING OPERATIONS 5.4 Checking the Operation of Subscribe (Receiving of MQTT Data)
TROUBLESHOOTING Checking Procedure 1. Checking the LED status Check the communication status with the display status of the LEDs. For the FX5U CPU module, refer to the following. MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware), Section 15.2 Checking with LEDs For the FX5-ENET, refer to the following. MELSEC iQ-F FX5 Ethernet Module User's Manual, Section 10.1 Checking with LEDs For the router, refer to the manual of the router used.
Page 52
3. Checking the AWS settings For the AWS settings, follow the instructions on the window or contact the support center. 6 TROUBLESHOOTING 6.1 Checking Procedure...
APPENDICES Appendix 1 List of FX5 Ethernet-equipped Module The FX5 Ethernet-equipped module FB library contains the following FBs. Programs are created by combining FBs according to each application. Name Description M+FX5ENET_MQTT_Connect Controls the connection with a server (MQTT broker) to establish a TCP or TLS session by the CONNECT instruction or to disconnect the session by the DISCONNECT instruction.
Appendix 2 FB Library Downloading the FB library In this manual, the character string operation FB library is used. To obtain the FB library, please contact your local Mitsubishi Electric representative. APPX Appendix 2 FB Library...
Importing the FB library This section describes how to register the obtained FB library to GX Works3. Decompress the FB library folder (zip file) before registering the FB library. Start GX Works3, and select [Project] on the toolbar [New]. In this manual, the following settings are used.
Page 56
Select the "StrProcessing_F.mslm" file in the decompressed FB library folder, and click [Open]. The selected file is added to [Library] in the "Element Selection" window. If the "Element Selection" window is not displayed, select [View] on the toolbar [Docking Window] [Element Selection] to open the window.
How to use the FB library Select an FB registered in the library from the "Element Selection" window, and drag and drop it to the program editor. Create an input ladder and an output ladder of the pasted FB to create a program. Arrange the FB input ladder to the left side, and output ladder to the right side of the window in the same manner as standard ladder programs.
Page 58
Insert a contact and input to B:i_bEN. Insert an FB word device input to the left side of the FB. Insert an FB word device output to the right side of the FB. Repeat these steps to create the ladder. APPX Appendix 2 FB Library...
Appendix 3 How to Use the Program Copy Function of e-Manual Program examples in e-Manual can be copied and pasted to GX Works3. Click "Copy Ladder Program (for GX Works3)" in e-Manual. Right-click the mouse on the ladder editor of GX Works3, and select [Paste]. The copied program is pasted in undefined state.
Page 60
Click the [OK] button on the "FB Instance Name" window. When the FB is properly defined, the FB instance name is highlighted in gray. Label items (label name, data type, and others) are copied in the order defined as an example in this manual. Therefore, define label items in the same order as shown on the label editor of the engineering tool.
Page 61
MEMO APPX Appendix 3 How to Use the Program Copy Function of e-Manual...
Page 62
Japanese manual number: L08896-A This manual confers no industrial property rights or any rights of any other kind, nor does it confer any patent licenses. Mitsubishi Electric Corporation cannot be held responsible for any problems involving industrial property rights which may occur as a result of using the contents noted in this manual.
Page 63
WARRANTY Please confirm the following product warranty details before using this product. MELSEC iQ-F FX5S/FX5UJ/FX5U/FX5UC User's Manual (Hardware), WARRANTY MELSEC iQ-F FX5 Ethernet Module User's Manual, WARRANTY TRADEMARKS Microsoft Edge and Windows are trademarks of the Microsoft group of companies. Amazon Web Services and AWS are trademarks of Amazon.com, Inc.
Page 64
Fax : +62-21-31923942 Fax : +91-20-2710-2100 Fax : +61-2-9684-7245 Mitsubishi Electric's e-F@ctory concept utilizes both FA and IT technologies, to reduce the total cost of development, production and maintenance, with the aim of achieving manufacturing that is a "step ahead of the times".