Accelerating Azure IoT Device Simulation

At the recent Build, Microsoft announced that the Azure IoT Suites were renamed to Microsoft Azure IoT Solution Accelerators.

“A solution accelerator helps you speed up the development and deployment of your IoT solution. It’s open source so you can customize it to fit your business. Use it as a reference for your own solution, or as a demo to see how a finished solution can work for you.”

There are four different accelerators:

  1. Remote Monitoring
  2. Connected Factory
  3. Predictive Maintenance
  4. Device Simulation

In this blog, we dive into the Device simulation:

“Streamline your IoT solution development by using simulated IoT devices to both build and test your solution throughout the software development lifecycle.”

This is an interesting tool to generate the output of many devices as if there are actually (thousands of) devices connected to an IoT Hub.

What can we do with it? How useful is it?

Microsoft provides a guide, let’s check this out.

Resources deployed

If we look at the documentation, this service will generate the following resources on your Azure subscription:

  • 1 Azure Active Directory application
  • 1 Virtual Machine (Standard D4 v3 with 4 cores and 16 GB memory)
  • 1 Cosmos DB Account (Standard)
  • 1 Storage account (Standard-LRS)
  • 1 Web Application
  • 1 IoT Hub (S2 – Standard)

The costs are not clear. According to Microsoft, you will have to use the Azure calculator to find out. Experience says it will be quite cheap if you do some testing for a few hours or days and then tear down the resources. If you can not wait for twenty minutes to get everything created or you have custom messages which are very hard to re-create, you can choose to set resources on pause (like the VM).

If you are a heavy user, you have to monitor the resources to find out if these have to be scaled up.

It seems the IoT Hub can be removed during or after the creation if you have your own IoT Hub at some point in time.

Open source

You can look into the code of this accelerator or even start your own version of it using the open-source code.

Installing

Installation is pretty simple:

If you leave out the IoT Hub, it will not be created.

Creation will take 15 minutes or so.

You will need the correct permissions to get this created.

Afterwards you will see the resources created:

And a simple website is available:

You can see we can enter the connection string on an alternative IoT Hub.

Generating Data Messages

Using this website you can generated message of A maximum of 20.000 devices. We can specify the interval in hours (maximum of 99), minutes and seconds (default ten). And we can specify the duration, also in hours (maximum of 99), minutes and seconds (default indefinitely). Finally, we can choose the model. There are three pre-defined modules. These are the messages we receive:

Truck

Device: [Simulated.truck-01.0],

Data:[{

“latitude”:47.4467466983126,

“longitude”:-122.294169321976,”speed”: 29.5806421991813,

“speed_unit”:”mph”,

“cargotemperature”:37.7480468349941,

“cargotemperature_unit”:”F”

}]

Properties:
‘iothub-message-schema’: ‘truck-sensors;v1’
‘iothub-creation-time-utc’: ‘2018-05-14T20:44:23.1292541Z’
‘$$CreationTimeUtc’: ‘2018-05-14T20:44:23+00:00’
‘$$MessageSchema’: ‘truck-sensors;v1’
‘$$ContentType’: ‘JSON’

Chiller

Device: [Simulated.chiller-01.0],

Data:[{

“temperature”:77.7398422996001,

“temperature_unit”:”F”,

“humidity”:67.3500445512357,

“humidity_unit”:”%”,

“pressure”:158.938824070589,

“pressure_unit”:”psig”

}]

Properties:
‘iothub-message-schema’: ‘chiller-sensors;v1’
‘iothub-creation-time-utc’: ‘2018-05-14T20:48:29.8028660Z’
‘$$CreationTimeUtc’: ‘2018-05-14T20:48:29+00:00’
‘$$MessageSchema’: ‘chiller-sensors;v1’
‘$$ContentType’: ‘JSON’

Elevator

Device: [Simulated.elevator-01.0],

Data:[{

“floor”:1,

“vibration”:0,

“vibration_unit”:”mm”,

“temperature”:74.2529671434327,

“temperature_unit”:”F”

}]

Properties:
‘iothub-message-schema’: ‘elevator-sensors;v1’
‘iothub-creation-time-utc’: ‘2018-05-14T20:46:46.9557261Z’
‘$$CreationTimeUtc’: ‘2018-05-14T20:46:46+00:00’
‘$$MessageSchema’: ‘elevator-sensors;v1’
‘$$ContentType’: ‘JSON’

While the generation of messages is executed, you get some feedback (eg. the amount of messages generated):

You also get a summary at the end:

There is no Back button. If you want to switch back to a new generation run, just press the OK button. Or just remove “simulation” in the path “https://%5Byour solution].azurewebsites.net/simulation”. Here you can plan your next run, the previous selections are still available.

Generating Custom Messages

You can also choose to create a custom message. This message is just one dimension deep (so no arrays) and each field consists of the following properties:

  • Sensor name
  • Behavior. This is either Random, Increment or Decrement
  • Minimum value
  • Maximum value
  • Unit (just a string)

Entering the data is simple:

This will generate something like:

Device: [Simulated.custom.0],

Data:[{

“temperature”:14.2477341435141,

“temperature_unit”:”degrees”,

“humidity”:1,

“humidity_unit”:”percentage”,

“speed”:19,

“speed_unit”:”mps”

}]

Properties:
‘iothub-message-schema’: ‘custom-sensors;v1’
‘iothub-creation-time-utc’: ‘2018-05-14T21:06:31.6812805Z’
‘$$CreationTimeUtc’: ‘2018-05-14T21:06:31+00:00’
‘$$MessageSchema’: ‘custom-sensors;v1’
‘$$ContentType’: ‘JSON’

Note: And there is no unique Name check.

Units

you will have to add the unit. I have not seen cases where the unit was omitted. This was done because the company used standard units for certain fields or to limit the size of the message.

Having to add them, makes the messages ‘dirty’. A bit more information is sent. Chunks could be filled more quickly, a bit more load on the server side is needed, etc.

It would be nice to have the opportunity to leave out the unit.

Conclusion

If you want to send fairly exotic messages, from only a few devices, building your own message generator is a simpler and probably a cheaper solution.

But if you want to have a flexible solution to create A LOT of simple messages, this accelerator is just for you.

If you want to add arrays you will have to dive into the code in Github and change and create your own solution.

This accelerator has potential so I look forward to what the community or Microsoft will bring us in the next version.

Advertenties