Introduction
Azure Digital Twins Service offers a way to build next generation IoT solutions. There are other approaches on the market to describe IoT devices and build digital twins. Without making a formal comparison I can say with the Azure Digital Twins is possible to build a powerful semantic layer on top of your connected devices using domain specific models.
To show you how this work let’s create a kind of “hello world” example. An end-to-end solution is out-of-scope of this post. Instead I will create some hands-on tutorial to demonstrate some of the functionalities.
Scenario description
Let’s consider the following simplified use case.
I like farming, even when I am really a rookie on this topic. Let’s suppose we have a parcel in a farm. The parcel has a soil. There are also different product types in every soil.
Soil quality is an extensive topic and it could be measured using a set of physical, chemical and biological properties. One of them is the soil PH. Suppose we have one or more devices able to measure the soil PH and send the measured values to a local gateway, which transmit them to our digital twin instance in Azure. For more information about soil quality please visit this document:
https://ag.tennessee.edu/biodegradablemulch/Documents/What_is_Soil_Quality_Aug5_2015.pdf

In the first video I only show you how to use the Azure Digital Twins Explorer. The use case is just a reference and I hope it makes a little bit of sense.
Prerequisites
Create a digital twin instance
https://docs.microsoft.com/en-us/azure/digital-twins/how-to-set-up-instance
Create an App registration in Azure Active Directory
https://docs.microsoft.com/en-us/azure/digital-twins/how-to-authenticate-client
From the register app we would need the Application (client) ID and Directory (tenant) ID. Since we are going to use an OAuth 2.0 authorization code flow. To learn more about authentication
flows please visit this article: https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-flows-app-scenarios

The next step is to grant the register app the permissions to interact with the digital twins service instance. There are two roles for that in the current preview version, “Azure Digital Twins Owner” and “Azure Digital Twins Reader”. We will use the owner role in this example.

DTDL models
In order to model the data I will used the FIWARE Agrifood smart data models as a starting point: https://github.com/smart-data-models/dataModel.Agrifood
I also created a super class called “Thing” in order to demonstrate inheritance in DTDL.
The created models are available in my github:
https://github.com/pauldj54/adt-agrifood
Model diagram:

ADT Explorer
The Azure Digital Twins (ADT) Explorer is an open source tool that allows model management, instance creation, relationship creation, graph visualization and run queries again our ADT instance. It can be download here: https://github.com/Azure-Samples/digital-twins-explorer/tree/master/
In the video I will show how to:
- Upload models
- Create Instances
- Create Relationships
- Executing some queries
Pingback: Understanding Digital Twins in IoT Hub – Curated SQL
Pingback: Azure Digital Twins Management with Postman | Paul Hernandez playing with Data
Pingback: Azure Digital Twins Management with Python | Paul Hernandez playing with Data