Prerequisites:

 

Overview:

Sparkplug is an open source project developed by Cirrus Link Solutions which shows how devices or projects can be enabled to communicate with MQTT Engine and Ignition.  This example will show how data can be published via MQTT from an emulated device running on a development machine.  In addition, it will show how devices or projects can be controlled by writing to tags in Ignition.  It will also show the caveats associated with establishing/ending an MQTT session and ensuring that the tag values in Ignition are valid.

 

Example C Client:

This tutorial assumes:

With the standalone Sparkplug example downloaded onto your development machine, change into the directory and build the application.  In order for this to work you must have a C compiler installed for your development system.  Also, this example assumes the MQTT Server running is MQTT Distributor running with it's default configuration.  If you are using a different MQTT Server, edit the following file to reflect your MQTT Server configuration:

The most likely candidates for change are the host, username, and password.  For simplicity this example does not use or support TLS over MQTT without modifications.

 

Mosquitto is the only dependency of the sample application. It must be installed on your development machine before building the sample application.

 

With the above steps completed, run the following commands to get the sparkplug library and sample application:
cd ~/dev

git clone https://github.com/Cirrus-Link/Sparkplug.git
cd Sparkplug/client_libraries/c/
make
cd ~/dev/Sparkplug/sparkplug_b/stand_alone_examples/c/udt_example/


At this point the example.c file should be edited to properly reflect your MQTT server URL, port, credentials, etc.  Finally, build the application:
make

 

 

Now simply start the application with the following command: 
./example


At this point, the application will start, connect to the MQTT server, publish a Edge Node Birth Certificate, publish a Device Birth Certificate, and begin periodically reporting random data values to Ignition via MQTT Engine.  This can be verified via Ignition Designer.  Using a Web Browser, browse to the Ignition Gateway on your Ignition Gateway.  If it is running on your development machine, that is: http://localhost:8088.  You should see this: