Connecting Modbus devices to Azure IoT Hub - FATBOX G3 Quick Start Guide:

This quick start guide is for engineers to quickly get from the wire up, to collecting data and visualising their remote field equipment on Azure IoT Hub & Power BI using the dual SIM FATBOX G3 IIoT gateway.

Download the PDF version for WINDOWS or MAC.

What You'll Need To Get Started
  • 1 FATBOX G3 Azure IOT Gateway Starter Kit ​​​

    • 1pc FATBOX G3 – Dual SIM Industrial 3G Gateway with Azure IoT client and Modbus RTU & TCP server

    • 1pc Digital input module – 4 x digital inputs (or switch contacts) Modbus RTU slave unit

    • 1pc Analog input – 2 x analog input Modbus RTU slave unit

    • Wires to connect the FATBOX G3 to the Modbus slave units (0.3m)

    • 2x 24VDC power supply 100-240VAC – 1 for FATBOX G3 and 1 for the 2 Modbus slave units

    • 1x cellular antenna (2m wire length)

    • 1x temperature sensor (0c - 400c) with 1m wire

Learn More: Click Here

You will also need the following

  • 1 x micro SIM card with 3G/4G data enabled – please also get its APN setting from provider.

  • A Microsoft Azure account

  • A Power BI account

  • optional: Test switches or load (max 230V 8A, e.g. a 12V indicator) if there is no field equipment ready.

Note: As per writing, you can get a one-month-free-or-USD200-credit for Microsoft Azure & Power BI to help with testing your concept. Click here to get your Free Azure Trail

The Temperature Sensor​

You can get more information on the temperature sensor here.

 

You can also access its data sheet here.

Collecting non-Modbus interface devices

 

For collecting data from non-Modbus interface devices, LUA or BASH scripts can be easily written to poll any data that is accessible over Ethernet or RS-485/232 interfaces. The data can then be put into a JSON format that can be processed by Stream Analytics query in Azure.

 

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

 

This section describes how to wire up the Modbus-485 I/O modules included in the starter kit to the FATBOX G3 and also to its 24VDC power supply. It will also show you how to wire up the temperature sensor to the analog Modbus module. The following are simplified wiring diagrams for the Novus Automation I/O modules but please refer to details in the instruction manual download links.

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 your Ubidots platform. 

Before you begin wiring, make sure to insert the an active SIM card into the FATBOX G3:

1. Dismantle the casing cover and slide out the PCB. Avoid touching the electronics, handle the board by the edges.

2. Insert your micro SIM card into the SIM card slot. Push the metal latch left/right to lock/unlock. Reassemble the metal casing.

Once the SIM card is in and the gateway is assembled you can proceed to wiring up the sensor and modules to it.

 

3. Setting Up The FATBOX G3

3A. Log into the FATBOX web console.

When you have connected up the FATBOX [ETH0 port], log into the web console [192.168.1.1].

By default the username is admin and password is fatbox12345

3B. Configure the cellular 3G 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

Got to <Port Settings>. Configure your serial port parameters as follows:

Remember to confirm the settings by clicking the UPDATE button.

3D. Enable SSH to be used for managing the FATBOX

Click on the <MANAGEMENT> tab and enable the SSH option. Remember to confirm the settings by clicking the UPDATE button.

MBM_START

 

TYPE,R #R=RTU and T=TCP

ADDR.3 #slave address on Modbus RTU network

MBFC,3 

REGS,8, 1, UINT16HL #data address, #of registers and function code 

Site,Azure IoT Starter Kit

Eqpt, DIGIRAIL.4C.CH1 #digital input 1 

Unit,NA

Key,Switch.CH1

TYPE,R
ADDR,2
MBFC,3
REGS,14,1,SINT16HL
Site,amplified.com.au
Eqpt,DIGIRAIL.2A.CH1
#analog input 1 Temperature Sensor
Unit,Celcius/100
Key,Temperature.CH1

 

TYPE,R #this is example to read VOLTAGE from a Modbus ABB Power Meter

ADDR,4

MBFC,3

REGS,4098,2,UINT16HLhl

Site,Azure IoT Starter Kit

Eqpt, ABB Power Meter

Unit,Volts

Key,Volts.ABB

MBM_STOP

3E. Ensure you have the iotasset.txt

The FATBOX G3 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:

#comments below are for explanation, please do not include in your text file.

Please refer to our Modbus User Guide for further details.

The iotasset.txt file comes pre-installed with your FATBOX G3. If for some reason it becomes overwritten, you have to do the following step to add the file to the FATBOX's /user directory.

For MAC users

Create a file called 'iotasset.txt' on TextEdit. Copy & paste the string above (without the #comments) in this file and save it.

Open a terminal session and run the following commands:

> cd <folder where you saved the iotasset.txt> i.e."cd documents"

> scp iotasset.txt root@192.168.1.1:/user
> enter in the password for your G3
[default is fatbox12345].

You can run the following commands to check that your iotasset.txt is loaded:

> ssh root@192.168.1.1
> enter the password.
> cd /user
> ls
 [check to see if there is a iotasset.txt file in the list]
> cat iotasset.txt [verify the contents of the iotasset.txt file]

Save your settings by going to the <MANAGEMENT> tab to reboot the G3.

For Windows Users

Create a file called 'iotasset.txt' on Notepad. Copy & paste the string above (without the #comments) in this file and save it.

Run Winscp and connect using the following File Protocol

 

> SCP Hostname: 192.168.1.1
> User/password: root/fatbox12345
>
Drag the iotasset.txt file over to the /user directory

You can run the following commands to check that your iotasset.txt is loaded:

> ssh root@192.168.1.1
> enter the password.
> cd /user
> ls
 [check to see if there is a iotasset.txt file in the list]
> cat iotasset.txt [verify the contents of the iotasset.txt file]

Save your settings by going to the <MANAGEMENT> tab to reboot the G3.

3F. Set up the FATBOX G3 Azure Hub IoT Client

Click the <AZURE IOT> tab in your web configuration menu and create a DeviceID for this FATBOX.

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 G3.

Technical :: 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.1For 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.

When you are prompted for the password:

> Enter the password as: fatbox12345

> Enter the command 'cd /tmp' to the console

> Enter the command 'cat dataq.txt' to the console.

(Note: For firmware 2.4.17 or later, you should use the following commands instead)

> Enter the password as: fatbox12345

> 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 FATBOX G3 to your Azure IOT Hub

We worked hard and closely to integrate AZURE IoT Hub client. You can securely collect data from remote industrial devices like MODBUS RTU and TCP power meters, PLCs or sensors. The FATBOX G3 with serial RS-485/232, Ethernet and CAN Bus is a flexible and robust LTE and 3G I(IoT) field gateway for your Azure remote monitoring and analytics solution.

4A. Log into Azure IOT Hub

Log into your Azure Portal (https://portal.azure.com) using your account settings.

4B. Create a new IoT Hub

 

In the dashboard select -> Create a Resource -> Internet of Things -> IoT Hub.

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 TestHub617 in this example). Click the 'Review + Create' tab to create.

4C. Obtain your Primary Key Connection String

To register the FATBOX G3 as a new device in AZURE we first need a Shared Access Key known as the Primary Key Connection String. 

Go to the AZURE Dashboard and select the IOT Hub you just created.

Scroll down the IoT Hub navigation pane till you get -> Explorers -> IOT Devices

On the right panel click "+Add".

Create a name for your device (Device ID) and click "Save"

In your IoT Hub, select the Device ID you just created. In this example, we called our device "IOTTempSensor".

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.

4D. Download the new settings to the G3

For MAC

Create a file called 'connstr.txt' on TextEdit. Paste the copied connection string in this file and save it.

Open a terminal session and run the following commands:

> cd <folder where you saved the connstr.txt> i.e." cd documents"

> scp connstr.txt root@192.168.1.1:/user
> enter in the password for your G3 [default is fatbox12345].

For Windows

Create a file called 'connstr.txt' on Notepad. Paste the copied connection string in this file and save it.

There are 2 ways to get the FATBOX G3 running these new settings:

 

Method 1: Using Winscp to copy the files over

 

- Run Winscp and connect using the following File Protocol:

> SCP 192.168.1.1
> User/Password: root/fatbox12345
> Drag the file over to the /user directory

Method 2: Using a flashdrive to copy the files

- Rename your flashdrive to 'FATBOX'
- Create a 'user' directory and paste the copied string to the FATBOX/user directory

- Remove it and connect to the G3 using the microUSB connector provided
- Log into the G3 at 192.168.1.1 with your web browser
- Go to the <Management> tab:
- Select <User Configuration and Scripts Management>
- Click "Download to FATBOX".

You can run the following commands to check that you connstr.txt is loaded:

> ssh root@192.168.1.1
> enter the password.
> cd /user
> ls [check to see if there is a connstr.txt file in the list]
> cat connstr.txt [verify the contents of the connstr.txt file]

Save your settings by going to the <MANAGEMENT> tab to reboot the G3.

 

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 go to the following site: https://shell.azure.com/

Key in the following command lines:

> az extension add --name azure-cli-iot-ext
az iot hub monitor-events --hub-name 'Your HUBNAME' --output table

 

(in our example we used "az iot hub monitor-events --hub-name AmplifiedHub --output table")

You should see an output similar to the following:

5. Set Up Stream Analytics

 

5A. Create a new Stream Analytics Job

Log into Azure using your account settings.​

In the dashboard, select -> Create a resource -> Internet of Things -> Stream Analytics Job

Create a distinct name for the Analytics Job. In this example we will call it "Stream617"

5B. Designate the Job Scope (or Topology)

Go back to the AZURE dashboard, select the Stream Analytics Job you just created. This will open up the Job Topology table you see below.

Click on the <INPUTS> field, then select -> Add Stream Input -> IOT Hub.

You can complete the rest of the inputs as follows:

We will designate the output for the job in the same manner.


Go back to your Stream Analytics Job and click on the <OUTPUTS> field. Then select > Add. Choose PowerBI from the scroll down list.

Next select <EDIT QUERY> at the top right of Query field in the Job Topology table.

Enter the following into the empty field given:

Under SELECT

 

deviceId,RecOn as TIMESTAMP,[Key], CAST (Val AS bigint) as VAL

CAST (Val AS bigint) as VAL

Under INTO

outputbi #The output alias you have set in step 4E.

Under FROM

inputbi #The input alias you have set in step 4D.

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 button.

At the prompt for "Job Output Start Time', select NOW and click on the START tab at the bottom right.

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 G3 and Novus IO modules are switched on.

Go to My workspace->reports->create-> report

Select the dataset which you have created earlier.


Then select all the values on the right of the dashboard by checking their boxes.

6B. Design & save your reports

PowerBI offers you many different options for displaying your data in their <VISUALISATIONS> tab. You can explore which option suits your application best.

VISUAL DESIGN

For our example, we will be creating a line chart for readings from our Modbus modules. We do this by selecting the corresponding 'line chart' icon from the options.

FILTERING

By default we have 6 different inputs connected to our NOVUS modules but I do not want to display them altogether. I can set filters so that each input reading is displayed individually to give me a report that makes more sense.

Scroll down & select -> Filters -> Visual Level Filters.

This displays a set of options to sort your data. (Options 2AIN1 & 2AIN2 refer to the analog inputs from the NOVUS 2A module; 4CIN1 to 4CIN4 refer to the digital inputs from the NOVUS 4C module).

SAVING YOUR REPORTS

To save a report, check the filter you like & click on the <SAVE> tab. We are going to save the report for our first input as '2AIN1'.

To create separate reports for each input, repeat the steps in 6A & 6B.

Remember to save each report with a distinct & relevant name.

6C. Churning the Visual Report

With the reports saved, we are now ready for our last step to churn the Visual Report for the data from our connected devices.

> Go to <My Workspace> in your Primary Navigation Pane

> Create a new Report with the <+ Create> tab.
> Give a name to your report. We will call ours 'IOTtestsite'

Next go to the reports that we created earlier -> My Workspace -> Reports. Select the report for which you wish to churn as a Visual Report.

> Hover the pointer over the top of the graph and click on 'Focus Mode'.

> Look at the top right hand of the graph and select the 'Pin Visual' icon.

> Select 'PIN' to attach your visual graph to the existing dashboard.

The following steps help you to enhance the professionalism of your reports.

RESIZING THE DATA

> Select the dashboard that you have created.

> To resize it hover the pointer to the bottom edge of each graph and drag the tiles to resize them

RENAME EACH TILE TO THE PROPER UNIT

> Go to each graph & open the menu at the top right hand

> Select the pencil icon to edit. Then change the title of the tile to the name of the report or the input.

> Click 'APPLY' to rename the tile

 

The steps in 6C can be replicated to display the rest of the reports you have created onto the same dashboard.

Congratulations! You have successfully set up the data reporting from your device, streamed it through AZURE IoT Hub and visualized it onto PowerBI.

Thank you and we look forward to working with your team!

Got a question for us?

Contacts:

Tech Support : support@amplified.com.au

Sales : sales@amplified.com.au

Amplified Engineering

BUY A GATEWAY ROUTER

E-commerce Shop

HARDWARE-AS-A-SERVICE

Leasing Plans

FAQ on leasing

PRODUCT CUSTOMISATIONS

Custom the G3

CONTACT US

Sales Enquiries

Technical Enquiries

Amplified Engineering Pty Ltd  

Suite 4 Enterprise Unit 3,

9 De Laeter Way,

Bentley WA 6102, Australia

ABN 44127163035