This tutorial is for engineers using the nodeG5 IoT Gateway to get from wiring to sending Modbus sensor data to Azure IoT Hub & visualising it on a PowerBI dashboard.
(approx. time required: 2 1/2 hours)
What You'll Need To Get Started
The nodeG5 Azure IIOT Starter Kit
nodeG5 4G Industrial IoT Gateway
1x Digital input module – 4 x digital inputs (or switch contacts) Modbus RTU slave unit
1x Analog input – 2 x analog input Modbus RTU slave unit
Single core AWG20-AWG30 wires to connect the nodeG5 to the Modbus slave units (0.3m)
2x 24VDC power supply 100-240VAC
1x cellular antenna (2m wire length)
1x temperature sensor (0c - 400c) with 1m wire
1 x micro SIM card with 4G data enabled – please also get its APN setting from provider.
A Microsoft Azure account
optional: Test switches or load (max 230V 8A, e.g. a 12V indicator) if there is no field equipment ready.
Let's Get Started:
1. Design
It’s usually good practice to start by mapping out the devices you want to monitor, e.g. a switch or a sensor in a network diagram. Later, you can move on to your own field devices like power meters or PLCs.
2. Wire Up
Before you begin wiring, make sure to insert the an active SIM card into the nodeG5:
In your starter kit, a temperature sensor is pre-wired to to the Digirail-2A analog module to facilitate immediate testing of transmission of field data to Azure.
Refer to the wiring diagrams in the Novus Automation I/O instruction manual for the rest of the wiring connections to the nodeG5 gateway and power supply.
3. Setting up the nodeG5
3A. Log into the nodeG5 web console.
Connect up the nodeG5 using the ETH0 port & log into the web console [192.168.1.1].
By default the username is admin and password is node12345.
3B. Configure the cellular 4G settings
Enter in the APN details you got from your SIM card operator.
Then to confirm the settings, click the UPDATE button.
3C. Configure the Serial Port Settings
Go to the <Port Settings> page & configure your serial port parameters as follows:
Remember to confirm the settings by clicking the UPDATE button.
3E. Configure the polling of data using iotassest.txt or JSON
The nodeG5 integrates a ‘device server’ that will poll all attached Modbus RTU and TCP slaves at a configure period. This server reads a configuration file ‘iotasset.txt’ that is a simple text file with each polled Modbus device register specified as following:
MBM_START
TYPE,R
ADDR,1
MBFC,3
REGS,8,1,UINT16HL
Key,4C_IN1
TYPE,R
ADDR,2
MBFC,3
REGS,14,1,UINT16HL
Key,2A_IN1
MBM_STOP
Please refer to our FAQ for more detailed write up for the iotasset device register.
To configure the iotasset.txt file to your device, please refer to our Modbus User Guide.
The iotasset.txt file comes pre-installed with your nodeG5. If for some reason it becomes overwritten, you have to do the following step to add the file to the FATBOX's /user directory. Note that the gateway HTTPS connected webconsole must be accessible (If you do not have an Internet connection, you can follow the alternative steps here).
Log into your web console and go to the <IOT Hardware> tab, click on 'Upload iotasset.txt File' button.
In the new window, click on 'CHOOSE FILE' and select from your local folder the updated iotasset.txt file then click on 'UPLOAD FIRMWARE FILE'. After the upload is successful you will need to close the page and log in again for security purpose.
3F. Turn on & set up the Azure IoT client
Click the <IoT Client> tab in your web configuration menu and create a DeviceID for this nodeG5.
How you name this ID is up to you but make it distinct so you can identify it easily later.
Select the ENABLE option and confirm your settings by clicking the UPDATE button.
Save your settings by going to the <MANAGEMENT> tab to reboot the G5.
We suggest doing an ‘interim’ test at this point to ensure that your Modbus master, network and I/O modules are working before interacting with the Azure system.
For MAC users, open a session on Terminal and log into the box using the command: 'ssh root@192.168.1.1'
For Windows, use PUTTY or a similar software, open a session to host: 192.168.1.1, port: 22; and log into the box as: root.
> Enter the password as: node12345
> Enter the command 'cat /data/dataout' to the console.
If you see an output similar to the following, CONGRATULATIONS! Your site level devices are properly configured and now we can proceed to the Azure settings.
4. Add the nodeG5 to your Azure IOT Hub
Our integration of Azure IoT Hub client on the nodeG5 allows you to securely collect data from remote industrial Modbus RTU/TCP devices like meters, CAN Bus J1939/OBD2 vehicular ECU, OPC UA PLCs & wireless BLE/WIFI sensors.
4A. Log into Azure IOT Hub
Log into your Azure Portal (https://portal.azure.com) using your account settings & open up Device Explorer.
4B. Create a new Resource
In the dashboard select -> Create a Resource -> Internet of Things -> IoT Hub -> CREATE.
Create a distinct name for your Resource Group (i.e. you can call this the name of your project or application) and IoT Hub Name (i.e. you can call this the location of your device, we called ours "resourcegrp" in this example). Click the 'Review + Create' tab to create.
4C. Obtain your Primary Key Connection String
To register the nodeG5 as a new device in AZURE we first need a Shared Access Key known as the Primary Key Connection String.
Go to the IoTHub you just created.
Scroll down to -> IOT devices
On the top panel click "+New".
Create a name for your device (Device ID). In this example, we called our device "newsite".
Then click "Save"
In your IoT Hub, select the Device ID you just created.
You should see a section with the heading 'Connection String-Primary Key' under this menu. Click on the 'clipboard' icon to copy or select the entire string and copy it using the 'Ctrl-C' keyboard shortcut.
Save it into a text file and name it "connstr.txt."
Upload this into the nodeG5 using the following steps:
Go to your web configuration menu -> IOT Hardware -> upload connstr.txt
Save your settings by going to the <MANAGEMENT> tab to reboot the G5.
4E. Test that your Azure account is receiving data
At this point it is good to check if everything is connected well and ensure that your AZURE account has started to receive the data from your NOVUS modules.
To do this open Powershell by clicking this icon on Azure.
Run the following commands:
az extension add --name azure-iotaz iot hub monitor-events --output table --hub-name {YourIoTHubName}
Replace {YourIoTHubName} with the name of your iothub name which you have created earlier. If you were following the same names used in this demo, the command would be:
az iot hub monitor-events --output table --hub-name newsite
You should be able to see the same strings as above in the device explorer [image below is a sample].
5. Set Up Stream Analytics
5A. Create a new Stream Analytics Job
Log into Azure & in the search bar, search for "Stream Analytics Job"
Add a new job.
You can use the following settings to get you started.
NAME: newsite
SUBSCRIPTION: Free trial/Pay as you go
RESOURCEGRP: [select the name you created in step 4B from the drop down menu] in our example, the name was 'resourcegrp'
Create the new job.
5B. Create the Job Topology
We will designate the input and output for the job.
Click on the <Go To Resource> button.
Go to -> Inputs->add stream input -> IOT Hub
You can use the following settings
INPUT ALIAS: inputbi
IOT HUB: newsite [from the drop down menu]
SUBSCRIPTION: Pay as you go
Next on the <OUTPUTS> field, select > Add.
Choose PowerBI from the scroll down list & authorize it.
You can use the following settings to start off.
OUTPUT ALIAS: outputbi
DATASET NAME: newdataset
TABLE NAME: newtable
Click on SAVE.
Next select <EDIT QUERY> at the top right of Query field in the Job Topology table.
Replace [Input] and [Output] with the respective names of the input and output you created in the past few steps.
Then enter the following into the empty field given:
Under 'SELECT'
deviceId,RecOn as TIMESTAMP,[Key],
CAST (Val AS bigint) as VAL
Under 'INTO'
outputbi #The output alias you have created.
Under 'FROM'
inputbi #The input alias you have created.
Click <SAVE>. This should give you a set up similar to the following:
5C. Test your settings
Let's test is everything is going well so far and that the Stream Analytics has started receiving data for its job.
Go to your Stream Analytics Dashboard and click on the START THE JOB button.
If everything is set up well you should see a RUNNING status notification.
Congratulations! You are a successful device to cloud solution. Next is decide on how to ingest and make economic benefit from all that data.
If however, the above fails please check the following possibilities.
Ensure FATBOX G3 is connected to the internet – it’s obvious but you never know.
Make sure /user/iotasset.txt is correctly configure and data is being correctly polled from slave devices and sent to /tmp/dataq.txt buffer file
Make sure that IoT device connection string is correct in /user/connstr.txt
Please contact Amplified Engineering at support@amplified.com.au for further assistance.
6. Visualise on Power BI
6A. Create a report in PowerBI
Log into PowerBI using your account settings.
Please also ensure Stream Analytics is running and your nodeG5 and Novus IO modules are switched on.
Once logged in to your account, go to <MY WORKSPACE> and create a new dashboard using the <+ Create> tab & give your new dashboard a name.
Once the dashboard is created, go to <Datasets> and select the dataset which you have created earlier in step 5B.
Then check on the pencil icon to edit the Date & Time to your required time zone.
Go back to <My Workspace> and click the <+Create> again to create a new report. Choose the dataset that you have just created.
Play around with the different graph settings to create the report that you will like. You can reference our sample below for the checkbox settings we use to create our graphs. (We used an area graph to plot the value of 2A_CH1 against Time.)
Once done save your report with the <SAVE> tab and pin a live page on the dashboard you have created.
You can continue adding for various keys to your dashboard. To view your report go to <Workspaces> & select your Dashboard.
Congratulations! You have successfully set up the data reporting from your device, streamed it through AZURE IoT Hub and visualized it onto PowerBI.
7. Create Cloud-to-Device controls
The nodeG5 industrial IoT gateway can be configured to receive control messages from Azure IoT Hub (or other cloud back-ends) to control Modbus or CAN bus connected field devices like PLCs, motor inverters or EV chargers.
This demo application explains the sending of a control string from Azure CLI to simulate a cloud application or dash board widget.
The data is sent over 4G/Ethernet, securely received by the gateway and written to Modbus/CAN Bus registers of connected devices.
7A. Send Modbus or CAN Bus control message from Azure IoT Hub to the G3 Gateway
From your Azure console, start the CLI PowerShell.
Run the az extension add command to add the Microsoft Azure IoT Extension for Azure CLI to your CLI shell.
az extension add --name azure-iot
Then you can configure your cloud to devices send command string
az iot device c2d-message send -d simDevice --data "device_tag" --props "key0=value0;key1=value1" -n{YourIoTHubName}
At your nodeG5 gateway, if the C2D Azure function has been enabled the following process would be executed and in this case, Modbus register(s) in PLC.2 written.
Congratulations! You have successfully set up the data reporting from your device, streamed it through AZURE IoT Hub, visualized it onto PowerBI & created bi-directional message controls to your device from your cloud solution.
Thank you and we look forward to working with your team!