Azure IoT Hub cloud connection RUTOS

From Teltonika Networks Wiki
Main Page > General Information > Configuration Examples > Third party services > IoT platforms > Azure IoT Hub cloud connection RUTOS

The information on this page is updated in accordance with the 00.07.4 firmware version .


Azure IoT Hub is an open and flexible cloud platform that supports open-source SDKs and multiple protocols. This article contains instructions on how to configure a RUT router in order to connect to the Azure IoT Hub.


You will need:

  • A Teltonika Networks router
  • An Azure IoT Hub account

Azure account creation

Visit and create an account that will suit your needs, for testing purposes we will be using free Azure account.

Managing Azure services

  • First you will want to create a Resource group for easier management of resources that you will add later. In Microsoft Azure home page.
    • Select Resource groups
      If it is not in very first page, click More services and locate it there.
    Azure new.png
  • In new window, select Add
  • Azure02.png
  • And then finish creating yours Resource group
  • Select your subscription, we are using Free Trial for this test.
    1. Name your group
    2. Finally, choose server location for meta data. We will choose (South America) Brazil South and will use it during test where available.
    Azure03 RUTX.png
  • At this moment we will skip adding Tags since we will be able to do that later if needed, so simply press Review + create at the bottom of screen and then click Create to finish setup.
  • Azure04.png
    Azure05 RUTX.png
  • You will be redirected to Homepage, then click on Resource groups. You should see yours newly created group, select it, and press Add.
  • Azure06 RUTX.png
  • Select Internet of Things or simply search IoT Hub and press Create.
  • Azure07.png
  • We leave default subscription and resource group and choose:
    1. Region – (South America) Brazil South as before
    2. Create a name for IoT Hub
    3. Then go to Size and scale tab
  • Azure08 RUTX.png
  • For testing purposes, we are using F1: Free tier
  • At the bottom of the screen Review + create


    And finally, Click on >> Create

    Azure10 RUTX.png

    Note: Wait until resource deploys and press Go to Resources

  • Inside IoT Hub list:
    Scroll down to Explorers and select IoT devices

    Azure11 RUTX.png

  • Press New
  • Azure12 RUTX.png
  • In new device creation
    1. Enter Device ID
    2. Leave everything else on default and press Save
  • Azure13 RUTX.png
  • After you finish creation, you will be redirected back to IoT devices select yours newly created Device ID
  • Azure14 RUTX.png
  • In your device window you will find information needed to connect RUT devices to Azure IoT Hub.
  • For now, we will only need connection string. Copy Primary Connection string by pressing copy icon next to it.

    Azure16 RUTX.png

Configuring Azure IoT Hub in WebUI

  • First open router WebUI, go to System > Package Manager and install Azure IoT Hub package
  • Networking rutx configuration examples package manager v1.png
  • Now navigate to Services → Cloud solutions → Azure IoT Hub
  • 1. Select Enable Azure IoT Hub monitoring
    2. Paste previously copied Connection String (For this test we leave other values as default)
    3. Select what kind of information you want to send to Azure IoT Hub
    4. Press Save

    Networking rutx configuration examples azure iot hub v1.png

Checking if Data reaches Azure IoT Hub

  • From router side, connect to it with CLI or SSH client and write in command azure_iothub and press Enter
  • - You should get answer that looks something like that, depending on what information you chose to send.

    Azure19 RUTX.png

  • From Azure IoT Hub side you can check if it receives data. Go to IoT Hub that you created previously. Select Overview, there you can see:
  • 1. How many devices are connected to hub, and how many messages it sent during chosen period of time.
    2. Device to cloud messages, that your router is sending.

    It should look something like that if IoT Hub is receiving data.

    Azure20 RUTX.png

  • To capture logs you will need Device Explorer for IoT Hub Devices.

  • Scroll down to Assets, download and install SetupDeviceExplorer.msi


  • Now you will need connection string of yours Azure IoT Hub, Not device. Navigate to IoT hub in your browser, then:
  • 1. Click Shared access policies
    2. Next choose iothubowner
    3. And copy Connection string – primary key

    Azure22-1 RUTX.png

  • After that go back to Device Explorer:
  • 1. In Configuration tab paste in Connection string that you just copied
    2. Copy HostName part from connection string and paste it in Protocol Gateway HostName
    3. Click Update

    Azure23 RUTX.png

  • Open Management tab
  • 1. Click Update
    2. You should see your device in the list below and Connection state

    Azure24 RUTX.png

  • Go to Data tab
  • 1. Click monitor, and wait for Event Hub Data to update (Depends on yours chosen interval)
    2. Messages like this should start appearing.

    Azure25 RUTX.png

    Setting router to Forward MQTT messages/commands to Azure IoT Hub

    First you will need MQTT broker to subscribe to, for testing purposes we will set MQTT Broker in same router, and will use PC from LAN to sent MQTT messages.
  • Go to Services > MQTT > Broker
  • 1. Click Enable
    2. Use same port in MQTT Broker and Azure IoT Hub settings.
    3. Press Save

    Azure26-1 RUTX.png

  • Go to Services → Cloud solutions → Azure IoT Hub
  • 1. Enable monitoring
    2. Use same Connection string as before (GSM values configuration)
    3. Messages Type choose MQTT messages
    4. Enter MQTT Host address, we are using since our broker is set up on same router.
    5. Port Same as MQTT Broker
    6. And Topic under which router will subscribe to MQTT Broker
    7. Press Save, we will not need username or password.

    Azure27-2 RUTX.png

Testing the configuration


    Connect to router with SSH, in logread you should see Router establishing connection to Azure IoT Hub:


  • Open terminal and publish to MQTT Broker message with previously chosen topic.
    For our example we are using example: mosquito_pub -h -p 8883 -m ‘testing Azure MQTT messages’ -t test

  • If everything was configured correctly in Device Explorer Data tab you should receive message like:

    Azure28 RUTX.png

    This means our router Forwards MQTT messages to Azure IoT Hub.


  • Install a MQTT client software to do the test, for this example we used MQTT.fx
  • 1. Setup your Router IP Address
    2. Use the same broker port
    3. Paste your Connection string – primary key and click Apply

    Azure29-1 RUTX.png

    1. Connect to the server broker
    2. Use the created topic. For this example test
    3. Send a message

    Azure30 RUTX.png

  • If you did everything right this message will be shown in the device explorer

Setting router to Forward Modbus data to Azure IoT Hub

To send Modbus data to Azure IoT Hub, configure the device with your desired Modbus configuration, then go to Services → Data to server and configure as follows:

  1. Enable the instance
  2. Name - enter desired name
  3. Data source - Modbus data
  4. Protocol - Azure MQTT
  5. JSON format - data you would like to receive
  6. URL/Host/Connection string - Azure connection string

Data to server.png

Testing the configuration

If everything was configured correctly in Device Explorer, Data tab you should receive message: Explorer message.png