Skip to content
This walks you through how to integrated an MX Chip with the OOB Dynamics 365 Connected Field Service Demo
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
IoTStream to AlertsQueue with Custom MX Chip Name.sql
IoTStream to PowerBISQL with Custom MX Chip Name.sql
README.md

README.md

MX-Chip-with-Dynamics-365-Connected-Field-Service

This walks you through how to integrate an MX Chip with the OOB Dynamics 365 Connected Field Service Demo.

Recently we released a firmware update for the MX Chip that exposes all the telemetry on the chip and integrates it with IoT Central. However, we can also use that firmware for the chip to interact with the traditional IoT Hub without IoT Central. This makes it very easy to get the chip integrated with the Dynamics 365 Connected Field Service demonstration. Thus, if you already have the Connected Field Service demonstration running within Azure IoT and Dynamics 365, you can use the following steps to integrate the MX Chip to interact with Dynamics 365 for both sending and receiving messages. For more information on the MX Chip, click here.

  1. Go into Dynamics 365 and add your custom device. To do so, within D365, go to Internet of Things >> Registered Devices and click +NEW to add a new device. Give it a distinct name and Device ID. NOTE: The Device ID is what gets registered to the IoT Hub, so we will need to remember this for future steps.

  2. After the record has saved, click the REGISTER button on the toolbar. Once the registration process has completed, your device should now show a Registration Status = Registered.

  3. Next, we need to capture our Device Connection string. To do so, go into the Azure portal and under your Connected Field Service resource group, select your IoT Hub and once loaded, click on the IoT Devices blade and select your newly registered Device ID.

  4. This will open the IoT Device blade for this device. Copy the Connection string – primary key to Notepad.
    NOTE: This is what defines your custom Device Id to the MX Chip

  5. Download the Dec 4, 2017 release of the firmware which is the AZ3166-IoT-Central-1.0.0.bin file from GitHub at https://github.com/Microsoft/microsoft-iot-central-firmware/releases.
    NOTE: Do not download the latest release as it has an issue with receiving the Method Name commands.

  6. Follow the instructions in the Prepare the DevKit device section at https://docs.microsoft.com/en-us/microsoft-iot-central/howto-connect-devkit. When you get to step 7 and you configure the device in the web page at http://192.168.0.1/start make sure to copy your Connection string – primary key from Notepad into the Device connection string field and select the Temperature checkbox at a minimum. You can select the other telemetry as well, but it is not needed for this specific scenario.
     

     
    Click the Configure Device button and click the reset button on the MX Chip.
     
    NOTE: If you do not get the Device connection string field in the window above, try doing a hard reset on the MX CHIP by holding down both the A & B buttons for a few seconds.

  7. Now you should see telemetry coming from your custom named MX chip. You can view this by downloading the Azure Device Explorer Twin and pasting the IoT Hub Connection Sting into the Configuration tab. Once you have done so, go to the Data tab and select your device and click Monitor…
     

     
    NOTE: The IoT Hub Connection string can be obtained by going into the Azure portal and under your Connected Field Service resource group, select your IoT Hub and click on the Shared access polices blade. Once it is loaded, click the iothubowner policy and copy the Connection string-primary key.
     

Since the MX Chip firmware for IoT Central device sends telemetry a little different than the web simulator or other devices, we will need to modify our queries for the Stream Analytics jobs. If you enabled the Power BI integration during the Connected Field Service setup, you will have 2 Stream Analytics jobs in your Connected Field Service resource group. The following steps show how to configure these jobs so that both the MX Chip and the web simulators can send data simultaneously via the IoT Hub and ultimately into Dynamics.

  1. First, we will modify the Stream Analytics job with the Output to the Alerts Queue. This can be identified by choosing our Connected Field Service Resource Group within the Azure portal and sort the listing by Type. Open the first Stream Analytics job in your listing and verify that the output states AlertsQueue. If it is not this job, close and open the other job.
     

  2. Next, we need to stop the Stream Analytics job in order to modify the query. From the overview blade of the Stream Analytics job, click the Stop button at the top. Typically, it takes about 30-90 seconds for the Stream Analytics job to stop.

  3. Once stopped, click on the Query blade to open the Query window. Highlight all text in the window and delete. Copy the contents from the IoTStream to AlertsQueue with Custom MX Chip Name SQL script in this repository into the Query Editor window and click Save.

  4. Once the query has saved, go back to the Overview blade and click Start.

  5. Put your finger on the temp sensor of the MX Chip to manipulate the temperature so it is hotter than the threshold. You should now start to see IoT Alerts showing up in Dynamics 365.

  6. If you activated the Power BI integration, we need to also manipulate the Stream Analytics job with the output to PowerBISQL. This can be identified by choosing our Connected Field Service Resource Group within the Azure portal and sort the listing by Type. Open the other Stream Analytics job in your listing and verify that the output states PowerBISQL
     

  7. Just as before, we need to stop the Stream Analytics job in order to modify the query. From the overview blade of the Stream Analytics job, click the Stop button at the top.

  8. Once stopped, click on the Query blade to open the Query window. Highlight all text in the window and delete. Copy the contents from the IoTStream to PowerBISQL with Custom MX Chip Name SQL script in this repository into the Query Editor window and click Save.

  9. Once the query has saved, go back to the Overview blade and click Start.

  10. You should now see the data in the Azure SQL database and the Power BI Report Template for Connected Field Service that uses that database as a source.

Now that we have configured data to flow from the device to Dynamics 365. Let’s look how we can send a signal back to the device from Dynamics 365. With the MX Chip IoT Central Firmware, there are two out-of-the-box methods that we can call on the device…

Have a Message Display on the device
NOTE: This only works with the Dec 4, 2017 release of the firmware which is the AZ3166-IoT-Central-1.0.0.bin file. Later firmware releases use different Method Names and are not compatible with these commands.

  1. Bring up your IoT Device record in Dynamics 365 by going to Internet of Things >> Registered Devices and open your IoT Device. In the toolbar, click the CREATE COMMAND button on the toolbar. In the New IoT Device Command window, fill in a name and then copy the following into the MESSAGE TO SEND FIELD…
     
    {"methodName": "message","payload": {"text": "Message Received from Operator"}}
     
    and click the SEND & CLOSE button on the toolbar. Your message should show on the screen of the MX Chip shortly. It can take upwards of a minute to take effect.

Show Rainbow Lights on the Device

  1. Bring up your IoT Device record in Dynamics 365 by going to Internet of Things >> Registered Devices and open your IoT Device. In the toolbar, click the CREATE COMMAND button on the toolbar. In the New IoT Device Command window, fill in a name and then copy the following into the MESSAGE TO SEND FIELD…
     
    {"methodName": "rainbow","payload": {"cycles": "5"}}
     
    and click the SEND & CLOSE button on the toolbar. The LED light on the left of the MX Chip should cycle through rainbow lights shortly. It can take upwards of a minute to take effect.
You can’t perform that action at this time.