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.

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.

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:

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 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. 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 'UPDATE FIRMWARE' in the Firmware Update section

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. 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 "fbg3iotdemo" 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. 

Select your new resource then go to -> IOT devices

On the top panel click "+New".

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 "a_new_device".

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 FATBOX G3 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 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.iot.com/ and sign in to your account to verify that it is streaming data.

 

5. Set Up Stream Analytics

5A. Create a new Stream Analytics Job

Log into Azure using your account settings.​

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

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

Next select the resource group which you created earlier.

5B. Designate the Job Scope (or Topology)

Go back to the AZURE dashboard, the resource -> Job topology->inputs -> Add stream input -> IOTHub.

Give the input a name and choose the IOTHub which you have selected earlier.

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 & authorize it, then create your own alias/dataset name/ table name.

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

 

Replace [Input] and [Output]with the name of the input and the name of the 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 G3 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.

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

Other articles that may interest you

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

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