Summary:
This article explains how to integrate a camera with Genetec Industrial IoT plugin using MQTT.
This document covers how to build a system using mosquitto-2.0.21, TNO-C3020TRA, and the Genetec Industrial IoT Plugin together.
The document is divided into three parts:
● Part 1 explains the Mosquitto MQTT broker.
● Part 2 covers how to configure MQTT settings on a Hanwha Vision camera.
● Part 3 describes how to set up MQTT in the Genetec Industrial IoT Plugin.
Step By Step Guide:
Part 1. Setting Up the Mosquitto MQTT Broker
This section explains how to configure the Mosquitto message broker for MQTT communication.
1. Download and install “mosquitto”,a free MQTT tool.
Note : The Mosquitto broker uses port 1883 by default, and since port 1883 is commonly used Open the Command Prompt (CMD) and execute the command netstat -ano | findstr "1883" to check if port 1883 is currently being used. If nothing is returned when the command is executed, it means the port is not currently in use. If port 1883 is being used by another application, please change the configuration to use a different port. |
2. Create user password (optional)
① Open the Command Prompt (CMD).
② Go to the folder where Mosquitto has been installed. (e.g., C:\Program Files\mosquitto).
③ Use the following mosquitto_passwd command to create a password file. When you run the command, you will be prompted to enter a password. The file containing the encrypted password is stored in the Mosquitto installation directory.
[Command Syntax] |
● option -c: Create a new file (this will overwrite the existing file if it already exists).
● passwordfile: File where the password information will be stored.
● username: Enter your desired username.
3. Edit the mosquitto.conf file to specify the desired port and enable password authentication. Make sure to add the contents shown in the red box to the configuration file. The mosquitto.conf file is located in the Mosquitto installation directory.
|
● listener: Enter the port that Mosquitto will use. If port 1883 is already in use, choose a different port.
● allow_anonymous: This setting specifies whether anonymous users are allowed to connect. If set to false, only authenticated users will be able to connect.
● password_file: Enter the path where the password_file is located.
4. Run the message broker manually or restart the service.
① Restart the Mosuitto Broker service.
② Or, you can run the Mosquitto broker manually after stopping the Mosquitto broker service.
[Command Syntax] |
● -v: Enable verbose mode to allow the Mosquitto broker to output detailed logs.
● -c mosquitto.conf: Run the Mosquitto broker using the mosquitto.conf configuration file.
Part 2. Setting Up the camera
This section explains how to configure the camera to publish an MQTT message when a temperature change detection event occurs.
1. MQTT Client Setup
① Enable MQTT
② Enter the IP address and port number of the message broker.
③ Enter the username and password for the message broker.
2. Add MQTT publication.
① Go to Event – MQTT – Client setup – Publication/subscription.
② Enter the Topic and Payload you want to publish to. For example, use 'temperature' as the topic and input 'The current temperature is above 30 degrees' as the payload.
3. Enable the Temperature detection event.
① Go to Analytics – Temperature detection.
② Check the [Enable temperature detection].
③ Select the detection condition as [Above] and set the detection threshold to 30 degrees.
4. Create an event rule and configure it to publish an MQTT message when a temperature change is detected.
① Add an event trigger and select the "Temperature Detection" event type.
② In the event action settings, select the pre-configured MQTT publication under the MQTT section.
Part 3. Setting Up the Genetec Industrial IoT Plugin
This section explains how to configure the Genetec Industrial IoT Plugin. To use the plugin, a separate Genetec license that includes the GSC-IIoT Part is required.
1. Open Config Tool and Select the Plugins Task.
2. Add an entity and select the plugin type as Industrial IoT plugin.
3. Select Industrial IoT plugin in the tree list and go to Protocols tab.
4. Follow the steps below to activate the MQTT protocol and configure the MQTT broker connection.
① Turn on the MQTT client protocols.
② Add MQTT broker.
③ In the Connection Info section, enter the IP address and port information of the MQTT broker set in Part 1.
④ In the Security section, select "None" for Encryption, enable authentication, and enter the username and password.
5. Add MQTT device
① Select Devices tab.
② Click Add a device button.
③ Select a protocol as MQTT client.
④ Select the MQTT broker that will communicate with the MQTT client.
6. Add a data point on the MQTT device that subscribes to the topic published by the camera.
① Click the “Add a data point” button.
② Enter the MQTT topic you want to subscribe to. For example, if the camera is publishing to the topic "temperature", you can subscribe to "temperature".
③ Select Raw as the Data Format type. You can choose between Raw and JSON, and the Raw option is used when you want to output the topic payload exactly as it is.
7. If you want to use JSON data published via ONVIF Profile M, please follow the steps below to configure the settings.
① Click the “Add a data point” button.
② Select data format as JSON.
③ Depending on your needs, enter the MQTT topic and JSON path — whether to subscribe to all topics from ONVIF Profile M or to a specific topic and extract a specific value from its JSON payload.
i. To subscribe to all topics published by ONVIF Profile M, as shown in example item (a), enter # as the topic and $ as the JSON path.
ii. If you want to subscribe only to the topic shown in item (b) among the various topics published by ONVIF Profile M, and display only the @MaxTemperature value from the JSON payload as shown in item (c), enter the values as follows.
● MQTT topic:
wisenet/onvifej/VideoAnalytics/Radiometry/BoxTemperatureReading/&//TemparetureDetectionModule-01
● JSON path:
$.Data.Reading.BoxTemperatureReading.@MaxTemperature
8. In the Genetec Security Desk Monitoring tab, assign the added MQTT device to a tile to monitor the received data values.
① Open Security Desk and select Monitoring Task.
② Double-click the MQTT client device from the tree.
i. When the data format type is set to Raw, you can see that the text contained in the payload of the topic published by the camera is displayed as-is, as shown in item (a).
ii. When the data format type is set to JSON, the topic is set to #, and the JSON path is set to $, you can see all topics published using the ONVIF Profile M appearing sequentially, as shown in item (b).
iii. When the data format type is set to JSON, and the desired target is specified in both the Topic and JSON path, you can display only specific values—such as MaxTemperature—as shown in item (c).
Comments
0 comments
Please sign in to leave a comment.