Weekly EP06 - MQTT Sparkplug in Action: A Step-by-Step Tutorial
Latest news and trends in Industry 4.0, IoT, and the underlying technology. Weekly update.
Hi, we're planning our future events and initiatives and want to meet your needs and expectations. Your thoughts and opinions matter to us, and we genuinely appreciate your time and effort in providing feedback. Please click the link below to access the survey and let your voice be heard: https://forms.office.com/r/djjc373Bvm
🔥 EMQ Featured Blog
MQTT Sparkplug in Action: Step-by-Step Tutorial for Practical Implementation
Introduction
Sparkplug is an Industrial IoT protocol that provides a standardized way to communicate with industrial devices and applications. An efficient, comprehensive Sparkplug solution can facilitate communication between devices and applications and empower the decision-making of IIoT adopters through insights from data.
This blog will give a practical example of implementing an MQTT Sparkplug solution using EMQX and Neuron.
Essential Components: EMQX and Neuron
EMQX is a popular MQTT broker that supports the Sparkplug protocol, while Neuron is an industrial IoT platform that can be used to collect data from industrial devices and generate Sparkplug messages for applications.
Neuron can collect the data from the devices and publish Sparkplug messages to the EMQX broker based on the data by reporting changes. EMQX will forward the messages to the application that subscribes to the relevant Sparkplug topic. However, EMQX is able to decode the Sparkplug messages through the rules engine. The messages are then used for data platforms, persistent storage for historical, and so on.
Read our post to learn more about the architecture of Sparkplug solution: MQTT Sparkplug Solution for Industrial IoT Using EMQX & Neuron
Install EMQX
Download and install the EMQX MQTT broker on your server or machine. EMQX provides a community edition that can be downloaded for free from their website. Visit the website and follow the documentation.
Configure EMQX
Once EMQX is installed, you need to configure it to support the Sparkplug protocol.
Create Schema Registry in EMQX
Click the Create button in Schema Registry.
Select the protobuf for Parse Type and fill in the schema with Sparkplug schema.
Create Rules in EMQX
The SQL statement used for decoding.
SELECT
schema_decode('neuron', payload, 'Payload') as SparkPlugB
FROM
"spBv1.0/group1/DDATA/node1/modbus"
The key point here is schema_decode('neuron', payload, 'Payload') :
schema_decode()
decodes the content of the payload field according to the Schema 'protobuf_person'.as SparkPlugB
stores the decoded value in the variable "SparkPlugB".The last parameter
Payload
indicates that the message type in the payload is the 'Payload' type defined in the protobuf schema.
Then add the action with the following parameters:
Action Type: Message Repost
Purpose topic: SparkPlugB/test
This action sends the decoded "Payload" to the SparkPlugB/test topic in JSON format.
Install Neuron
Neuron is an industrial IoT platform that can be used to collect, store, and analyze data from industrial devices. You can download and install Neuron from their website. Visit the website and follow the documentation.
Configure Devices in Neuron
Sparkplug devices are configured with a set of data points that define their capabilities and properties. You can configure Sparkplug devices using the Neuron platform by defining the data points and assigning them to specific devices.
Select the driver plugin module for devices.
Set up the driver parameters for device communication.
Create Group and set up polling interval.
Add Tags to the Group and set up an address for each Tag.
Connect Neuron to EMQX
Once Neuron is installed, you need to connect it to the EMQX broker. You can do this by configuring the MQTT connection settings in Neuron to point to the EMQX broker.
Select the Northbound communication driver (SparkplugB).
Set up the driver parameters for EMQX connection.
Subscribe to the Group you interested in.
Check up on the Result in MQTTX
With EMQX and Neuron configured and connected, you can now publish and subscribe to Sparkplug data. You can use the Neuron platform to publish data to Sparkplug devices and subscribe to data from those devices.
MQTTX tool is used to subscribe to the data decoded by the codec function of the EMQX rule engine, as shown in the following:
Conclusion
By following these steps, you can get started with MQTT Sparkplug using EMQX and Neuron. Keep in mind that this is just a basic overview, and there are many more advanced features and configurations that you can explore to customize your setup. We highly recommend you explore the powerful features of EMQX and Neuron to accelerate your IIoT development.
🕐 Upcoming Events
IoT Unleashed: Connect, Innovate, and Cheers at GDG Phoenix!
We are bringing everyone together to discuss technology and enjoy some spirits! EMQ Developer Advocate Moheeb Zara will demonstrate how to build IoT applications with EMQX, and how to use Node-Red, a Raspberry Pi, and an ESP32 with EMQX. → Register Now!
Time’s Up! How to Migrate from Google IoT Core to EMQX
Google IoT Core shuts down in two weeks, but that doesn’t mean your business has to! Join EMQ for a practical guide to migrating your valuable IoT data to EMQX Cloud, a fully managed MQTT service built on the world’s leading open source MQTT platform for IoT, IIoT, and connected cars. → Register Now!
🛠 EMQ Tech Blog
MQTTX is an open-source MQTT Client Toolbox developed by EMQ. In this blog, we will guide you on how to use MQTTX for testing Serverless MQTT connections, including publishing, subscribing, and messaging. → Read more.
Fleet management is crucial in logistics, as it ensures the smooth and efficient operation of vehicle fleets involved in transportation, delivery, and supply chain management. This blog will introduce how EMQX's IoT-based solutions can help fleet management overcome challenges. → Read more.
The benchmark test shows that a single node EMQX is able to support 100,000 connections and write 100,000 QoS 1 messages with a payload of 200B to HStreamDB per second, and all messages are written to the database in real time. → Read more.
Developed in 1979, Modbus provides a messaging structure designed to establish master-slave communication between intelligent devices. This blog will introduce how to seamlessly integrate Modbus with modern #IoT devices for automation, control, and data analysis. → Read more.
⚙ EMQ Products Update
Google Cloud IoT Core will be retired in August, but developers can migrate to EMQX, an open-source distributed MQTT broker. EMQX Enterprise 4.4.19 simplifies the migration process by providing a compatibility layer that supports importing device configurations and authentication data from Google Cloud IoT Core. → Read more.
EMQX Cloud is expanding to three new regions, providing seamless MQTT connectivity across the globe. This allows users to confidently expand their IoT initiatives, penetrate new markets, and deliver exceptional customer experiences. → Read more.
Neuron is an industrial IoT server that can connect with diverse devices simultaneously using multiple protocols. It aims to address the challenge of accessing data from automated equipment and provide infrastructure support for smart manufacturing.
Previously, all available modules of Neuron only offered a 15-day free trial. Now you can enjoy a permanent free license with no more than 30 data tags! —>Get started now!
EMQX Cloud is an MQTT middleware for the IoT from EMQ. As the world's first fully managed MQTT 5.0 cloud messaging service, EMQX Cloud provides a one-stop O&M colocation and a unique isolated environment for MQTT services. —>Get started free!