MQTT Simulator: Azure IoT Hub integration

  1. Table of Contents
  2. Overview
  3. This package integrates MIMIC MQTT Simulator with Azure IoT Hub to add many simulated sensors into Azure. This allows testing Azure applications with thousands of simulated sensors generating precisely tailored telemetry.

    Once you install the optional MQTTAZUR package in the MQTT library section with Update Wizard , you will see a new IoT menu in the MIMICview GUI .

  4. Prerequisites
    1. We have tested this on a 64-bit CentOS 8 Linux and Windows 10 system and were able to add up to 10,000 sensors. For example, this graph shows connected device statistics reported by Azure

      and list of devices

    2. MIMIC MQTT Simulator needs to be installed as detailed on our GetStarted page.

    3. To run this tool, you need Python 3.6.8 or later installed on your system. Install it from the Python page . Select pip and add to system path option while installing it.

  5. Usage
    1. Make sure MIMIC MQTT Simulator is installed by verifying that MQTT is listed in MIMICview with the Help->About Mimic... menu item.

    2. Python 3.6.8 or later should be installed and verified as follows from a command prompt:

      % python3 --version
      Python 3.6.8
      

    3. Invoke Wizard->Update menu and install the Bosch sensor package from the MQTT section, and the Python API package from the MIMIC API Language Bindings section, if not done so already. See details on the Update Wizard page.

    4. Invoke shell terminal on Linux or Windows command prompt using Right-Click "Run as Administrator" menu and install the Azure iothub SDK.

      pip install azure-iot-hub
      

    5. Copy MimicAzureIoTHubDeviceConfig-sample.xml in the scripts/azure folder to scripts/iot/MimicAzureIoTHubDeviceConfig.xml.

    6. Sign up or Log in to Microsoft's Azure portal , create an IoT Hub as detailed in this Microsoft tutorial page ,

      and get the keys & connection string needed for the MimicAzureIoTHubDeviceConfig.xml file related to your IoT Hub from the Shared Access Policies Security settings page.

    7. Copy/paste the primary key, secondary key and connection string into that file in the azure section. Other fields can be customized, such as IP addresses, device identifier, etc.

    8. Invoke MIMICView IoT->Azure IoTHub->Add... to add sensors. Each of the added devices will have it's own authentication via SAS. NOTE: The SAS token has a limited validity, expiring after one day. If you want to change this, change the expiration time in scripts/azure/MimicAzureIoTHubDeviceConfig.py.

    9. Invoke MIMICView IoT->Azure IoTHub->Remove... to remove sensors.

    10. Invoke MIMICView IoT->Azure IoTHub->Status to get current status.

    11. Invoke MIMICView IoT->Start to start sending telemetry.

    You should be able to see events from the Azure bash shell with this command:

    az iot hub monitor-events --hub-name mimic-demo --output table
    

    Optionally:

    1. Install Node.js version 4.x or higher

    2. Run below command in command prompt with admin privileges

      npm install -g iothub-explorer
      

    3. Verify via iothub-explorer monitor-events command without quotes in command prompt.

      iothub-explorer monitor-events  --login 'connect string'
      

      (Note: You may refer to the MimicAzureIoTHubDeviceConfig.xml for deviceid and connect string).

    4. Also, you will see MIMIC sensors sending the MQTT packets in the Azure Portal's Overview or Monitoring->Metrics section.

    This shows MIMIC in action adding devices to Azure:

  6. Compatibility
  7. Python 3.6.8+

    CentOS 8

    MIMIC MQTT Lab on AWS EC2

    Windows 10