Configure and Connect an Azure IoT Device Simulator

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Who needs physical devices? In this lab, you will configure, modify, and test a software solution that simulates the hardware and firmware of an IoT device. Then, you will be able to practice building Azure IoT solutions — even if you don’t have a wind farm or a global network of climate-controlled warehouses at your disposal!

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create and Connect Simulated Device to Azure IoT Hub
  1. Log in to the Azure portal, and navigate to the only IoT Hub already deployed in the lab subscription.
  2. Create a new device, and copy the primary connection string.
  3. Using the link in the Resources section of the lab, open the device simulator in a new browser tab or window.
  4. In the code pane, find and modify the connection string using the primary connection string you copied from the new device registration.
  5. Run the code and observe changes in the telemetry messages. Don’t forget to take note of the light flashing on the device simulator in the assembly pane when each message is delivered — that’s half the fun!
  6. Stop to end the code run.
Make Minor Changes to Simulator Code
  1. In the code pane of the device simulator, find the code that makes up the body of the message.
  2. Modify the temperature telemetry to return the temperature in Fahrenheit instead of Celsius.
  3. Run the code and observe changes in the telemetry messages.
  4. Stop to end the code run.
  5. In the same section of the code, add a barometer reading using a reading called pressure_hPa.
  6. Run the code, and observe changes in the telemetry messages.
  7. Stop to end the code run.
Confirm Delivery of Messages in Azure IoT Hub
  1. Back in the Azure Portal subscription, return to the IoT Hub, and view the Device to cloud messages graph. Expand the graph to ensure you can see the full day. You should see at least a few messages generated from activities in the first 2 objectives.

  2. To view the actual messages, which have been routed to a storage container, navigate to the only storage account deployed into the lab subscription. Drill down in the blob container to find the delivered messages.

    Note: If you work especially fast, you may need to wait a few minutes for the messages to appear in the graph and in the blob container.

  3. Optionally, download a blob to open and view the telemetry.

Additional Resources

Imagine you are a software engineering team lead for the Green River Railway company. You've been tasked with prototyping a project to demonstrate how data from existing weather devices along the rail lines can be integrated into the company's logistics planning software. Your first step is to quickly spin up a demonstration of IoT devices sending telemetry data — without access to any physical devices.

You are not yet ready or expected to dive into architectural details and configuration decisions. The product manager tells you that the leadership team just wants to "see IoT in action!"

The code in the simulator is written in Node.js, but if you have experience in other programming languages, you should be able to make minor modifications to the code required to complete the lab. Try on your own using only the lab objectives, but if you get stuck, more detailed instructions are available in the lab guide and in the solution video that follows the diagram video.

Accessing the Device Simulator

Use the following link to access the device simulator.

WARNING: Be Prepared for UI Changes

Given the fluid nature of Microsoft cloud tools and open-source projects, you may experience user interface (UI) changes that were made following the development of this hands-on lab that do not match up with lab instructions. When any such changes are brought to our attention, we will attempt to update the content accordingly. However, if changes occur, students will have to adapt to the changes and work through them in the hands-on labs as needed.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?