Configuring Grafana Dashboard with MQTT Data
Configuring Grafana Dashboard
In this Note, the Grafana Dashboard will be configured. Open Grafana via http://localhost:3000
.
First, we will add the MQTT and InfluxDB data sources to our Grafana Dashboard.
Adding MQTT Data Source
To add an MQTT data source to Grafana, follow these steps:
In the left-hand menu, navigate to Connections -> Add new connection.
Search for MQTT in the search field.
Click the Select button for MQTT.
In the top right corner, click Install.
After it is installed, the Install button will turn into Add new data source, click it.
A new window will appear where you can configure the connection. For our case, since we did not choose authentication for our MQTT and no TLS, we just have to type in our host address of the MQTT Broker
mqtt://192.168.4.187:1883
that we set up earlier. Also, give it a name to identify the broker, e.g., "Lathe Docker". Click Save & Test. If the connection is successful, a green box will appear saying "MQTT Connected".
Next, you can start visualizing data by clicking on building a dashboard.
Building a Dashboard
In this example, we will build a simple dashboard to show some of the data sent to the MQTT Broker from Node-RED, including Axes, Spindle, and Feed Data.
Step 1: Create a New Dashboard
In the menu, select Dashboards, and click New in the top right-hand corner to start your new dashboard by adding a visualization.
Select Data Source MQTT as shown below, since we want to stream the data from there.
Step 2: Add MQTT Topics
In the next window, add one of the topics that we decided to publish under for our MQTT Out Node in Node-RED. For example, if you want to subscribe to the Axes Data, choose Purdue/IE/Lambertus/BuildatScale/CNC/Acra/ATL-618EVS/Telemetry/Axes
as a topic, as shown below. You also have the option to add another topic to your panel by adding another topic.

Step 3: Configure Panel Visualization
The data will now be streamed onto your panel. Since the default panel is a time series one, and we want to show the momentary Axes Data in digits, go to the top right corner and select another panel option from the drop-down menu. A suitable visualization would be the Stat one, as shown below.

Step 4: Format Panel
Once selected, you have the option to choose different formatting options. We chose the following formatting options. For example, under the Panel options, name it "Axes data" and set Text size for title to 40 and Value to 40, etc., see picture below:
With these options, the dashboard will look like the following. You can see Time, timestamp, clientID, z, and x axis values. This is because we are creating those values in Node-RED and publishing them on this topic in MQTT.
Step 5: Transform Data
Since we don't want to show Time, timestamp, and clientID, select Transform data and click + Add transformation.
In the transformation window, look for the Organize fields by name option and click it.
Disable the fields that you don't want to see and optionally rename them.
Step 6: Add Units to Data
Use the Overrides option to add the units of the data shown. Click on + Add field override, select Fields with name, and choose "x". Add the override property > Standard options > Unit. Search for "inch (in)" and select it. Do the same for the "z" axis. The override options will look like this:
Click Save and then Apply. Your panel will now look like this:
You can drag the panel to different positions or change its size.
Step 7: Add Another Panel (e.g., Spindle Speed)
Click Add > Visualization and add the MQTT Topic
Purdue/IE/Lambertus/BuildatScale/CNC/Acra/ATL-618EVS/Telemetry/Spindle
.Select Gauge in the visualization options.
Transform Data > Organize fields by name. Disable all except for "spindle_speed_RPM", and rename it to "Spindle Speed".
Add necessary formatting options, e.g., Standard options > No value > 0, Standard options > Max > 800.
Open the override options, Fields with name > "spindle_speed_RPM"; + Add override property > Standard options > Unit > Revolutions per minute (rpm).
Add Value mappings for color changes based on ranges. Example:
Save and Apply, then you will see your Gauge in the dashboard with color changes based on thresholds.