This article presents an example scenario simulating a microgrid system with wind power, solar power, and energy storage assets. Metrics from this system are ingested over Sparkplug B into TDengine TSDB, and an asset model is built and panels and real-time analysis tasks are generated in TDengine IDMP.
Environment Setup
In this demonstration, TDengine TSDB and TDengine IDMP are deployed using Docker, with a Sparkplug B simulator serving as the data source for the demo environment. The data flow is described in the following figure:

Prerequisites
- Download the Sparkplug B simulator to your local machine.
- Install Docker Engine 20.10 or later on your local machine. For instructions, see Install Docker Engine in the Docker documentation.
- Install Docker Compose 1.29.2 or later on your local machine. For instructions, see Overview of installing Docker Compose in the Docker documentation.
- Install Git on your local machine. For more information, see the Git website.
Install the Demonstration Environment
-
Clone the tdengine-idmp-deployment repository:
git clone https://github.com/taosdata/tdengine-idmp-deployment.git
-
Start Docker Compose:
cd tdengine-idmp-deployment/docker docker compose up -d
This command will automatically pull the required images and start the TDengine IDMP and TDengine TSDB-Enterprise services in detached mode.
-
Add an MQTT broker container to enable the Sparkplug B simulator:
docker pull tdengine/ev-mqtt:20250806092152 docker run --name mqtt -d --network=docker_taos_net tdengine/ev-mqtt:20250806092152
You can access TDengine TSDB Explorer at http://localhost:6060
and TDengine IDMP at http://localhost:6042
.
Create a Data Ingestion Task and Simulate Data Writing
Create a Database
-
In your browser, access TDengine TSDB Explorer at
http://localhost:6060
. -
Log in with the default username
root
and passwordtaosdata
. -
Enter your name and email address as prompted to activate TDengine TSDB-Enterprise.
-
Create a database to store the sample data.
-
In the main menu on the left, click Explorer. Then click the + (Create Database) button next to Databases.
-
In the Name field, enter
db_microgrid
. Retain the default values for all other settings. -
Click Create.
-
Generate Simulated Data
The simulated data in this scenario is described in the following table.
Group ID | Edge Node ID | Device ID | Metrics | Unit |
---|---|---|---|---|
Industrial_Park | Micro_Grid | PV_Inverter_1 | solar_pv_output | kW |
PV_Inverter_2 | ||||
Wind_Turbine_1 | wind_power_output | kW | ||
Wind_Turbine_2 | ||||
Battery_1 | battery_state_of_charge | % | ||
battery_charging_rate | kW | |||
battery_discharging_rate | kW | |||
Env_Sensor_1 | solar_irradiance | W/m2 | ||
wind_speed | m/s | |||
temperature | °C | |||
humidity | % | |||
atmospheric_pressure | hPa | |||
Grid_Interface_1 | grid_load_demand | kW | ||
frequency | Hz | |||
voltage | V | |||
power_exchange | kW |
Generate the data as follows:
-
Copy the Sparkplug B simulator to the root directory of the TDengine TSDB container. Replace
<arch>
withx86_64
orarm64
depending on the simulator package that you downloaded.docker cp spb_pub-<arch>.tar.gz tdengine-tsdb:/root
-
Open a terminal inside the TDengine TSDB container and decompress the simulator package.
docker exec -it tdengine-tsdb /bin/bash tar -zxvf spb_pub-<arch>.tar.gz cd spb_pub
-
Download the simulator configuration file to the simulator directory:
curl https://content.tdengine.com/hubfs/microgrid.toml --output microgrid.toml
-
Start the simulator:
./spb_pub --schema microgrid.toml --host mqtt
Create a Data Ingestion Task
-
In the main menu on the left, open Data In and click Add Source.
-
Configure basic information as follows:
- Name: Enter a unique name for the data ingestion task.
- Type: Select SparkplugB.
- Agent: Leave this field blank.
- Target: Select the
db_microgrid
database.
-
Configure the connection information as follows:
- Brokers: Enter
mqtt:1883
. - MQTT Protocol Version: Retain the default value of 5.0.
- Client ID: Enter a unique client ID for the data ingestion task.
- Leave all other fields in this section blank.
Then click Check Connection to ensure that your connection to the MQTT broker is configured correctly.
- Brokers: Enter
-
Configure the subscription information as follows:
- Group ID: Enter
Industrial_Park
. - Node Device List: Enter the following:
Micro_Grid/PV_Inverter_1,Micro_Grid/PV_Inverter_2,Micro_Grid/Wind_Turbine_1,Micro_Grid/Wind_Turbine_2,Micro_Grid/Battery_1,Micro_Grid/Env_Sensor_1,Micro_Grid/Grid_Interface_1
- Message Type: Enter
DBIRTH,DDATA
. - Enable Rebirth CMD.
- Group ID: Enter
-
Under Payload Transformation, click Retrieve from Server. The transformation configuration will appear in the text box on the left. Then under Mapping, click Create STable.
-
Configure the supertable as follows:
- Name: Enter
stb_microgrid
. - Remove all columns. Then add one column with data type
DOUBLE
and namevalue
. - Remove all tags. Then add three tags with data type
VARCHAR(128)
and namesgroup_id
,edge_node_id
, anddevice_id
.
When you have finished configuring the supertable, click Create.
- Name: Enter
-
At the bottom of the page, click Submit to create the data ingestion task.
-
On the Explorer page, you can now see that the microgrid simulation data is being generated.
Get Started with TDengine IDMP
Create Element Templates
-
In a web browser, access
http://localhost:6042
and activate TDengine IDMP. -
From the main menu, open Libraries. Then select Element Template and click the New Element Template (+) button.
-
Configure the element template as follows:
- Template Name: Enter
PV Inverter
. - Element Naming Pattern: Click the Add Attribute Expression (+) button and select Template Name. Click the button again and select KEYWORD +. In the dialog box displayed, enter
Device ID
.
Then click Save.
- Template Name: Enter
-
Repeat this process to create templates for all elements in the sample dataset.
Create Attribute Templates
-
From the main menu, open Libraries. Click an element template and select Attribute Template from the drop-down list in the path bar.
-
Click New Attribute Template and configure the attribute template as follows:
- Name: Enter
Solar PV Output
. - Value Type: Select Double.
- Display Digits: Enter
2
. - UOM Class: Select Power.
- Default UOM: Select kilowatt.
- Display UOM: Select kilowatt.
- Data Reference Type: Select TDengine Metric.
- Name: Enter
-
Click inside the Data Reference Expression field. Configure the data reference expression as follows:
- Connection: Select TDengine.
- Database: Select db_microgrid.
- Table Name Pattern: Enter
t_PV_Inverter_${KEYWORD1}_solar_pv_output
. - Column: Enter
value
.
Then click Confirm.
-
Click Save. Repeat this process to create attribute templates for all element templates in the sample dataset.
Create Asset Model
-
From the main menu, open Explorer. Under Elements > Child Elements, click New Child Element.
-
Retain the default settings and click Confirm. Name the element
Industrial Park
and click Save. -
Following the same steps, create a child element of
Industrial Park
namedMicrogrid
. -
Following the same steps, create a child element of
Microgrid
namedSolar Power
. -
Create a child element of Solar Power and configure it as follows:
- Reference Type: Retain the default value of Strong.
- Template: Select PV Inverter.
- KEYWORD1: Enter
1
.
Then click Confirm.
-
Continue creating elements within
Microgrid
until your asset model is complete.
Select an asset and view its attributes. You can see that metrics from TDengine have been imported via the data reference.

Try AI-Generated Dashboards
-
In the sidebar, select Industrial Park > Microgrid > Solar Power > PV Inverter1.
-
Open the Panels page on this element to see AI recommendations.
-
Click Generate on a panel that you want to try. Once the panel is generated, click View to open it.
-
On the details page, you can view the panel or click Edit to make changes. When you edit a panel, you can select Advanced to view the SQL statement used to create the panel.
-
When you have finished modifying the panel, click Save to add it to the element.
Try AI-Generated Analysis
-
In the sidebar, select Industrial Park > Microgrid > Solar Power > PV Inverter1.
-
Open the Analyses page on this element to see AI recommendations.
-
Click one of the suggested questions to generate a real-time analysis task.
-
On the details page, you can view the configuration for the real-time analysis task and make changes as needed. When you have finished, click Save.
Summary
This article walks through how to use TDengine TSDB and TDengine IDMP to quickly build a microgrid monitoring system that ingests data collected in Sparkplug B format. Systems that previously took days or even weeks of tedious configuration and debugging can be completed within 30 minutes using TDengine IDMP. In the future, if new devices need to be added to the monitoring system, simply create elements from your existing element templates. If monitoring points change or new ones are added, just update the corresponding attribute templates within the element template — no other changes are required.