TDengine IDMP in Action: Microgrid with Sparkplug B

Joel Brass

August 13, 2025 /

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

Install the Demonstration Environment

  1. Clone the tdengine-idmp-deployment repository:

    git clone https://github.com/taosdata/tdengine-idmp-deployment.git
  2. 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.

  3. 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

  1. In your browser, access TDengine TSDB Explorer at http://localhost:6060.

  2. Log in with the default username root and password taosdata.

  3. Enter your name and email address as prompted to activate TDengine TSDB-Enterprise.

  4. Create a database to store the sample data.

    1. In the main menu on the left, click Explorer. Then click the + (Create Database) button next to Databases.

    2. In the Name field, enter db_microgrid. Retain the default values for all other settings.

    3. Click Create.

Generate Simulated Data

The simulated data in this scenario is described in the following table.

Group IDEdge Node IDDevice IDMetricsUnit
Industrial_ParkMicro_GridPV_Inverter_1solar_pv_outputkW
PV_Inverter_2
Wind_Turbine_1wind_power_outputkW
Wind_Turbine_2
Battery_1battery_state_of_charge%
battery_charging_ratekW
battery_discharging_ratekW
Env_Sensor_1solar_irradianceW/m2
wind_speedm/s
temperature°C
humidity%
atmospheric_pressurehPa
Grid_Interface_1grid_load_demandkW
frequencyHz
voltageV
power_exchangekW

Generate the data as follows:

  1. Copy the Sparkplug B simulator to the root directory of the TDengine TSDB container. Replace <arch> with x86_64 or arm64 depending on the simulator package that you downloaded.

    docker cp spb_pub-<arch>.tar.gz tdengine-tsdb:/root
  2. 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
  3. Download the simulator configuration file to the simulator directory:

    curl https://content.tdengine.com/hubfs/microgrid.toml --output microgrid.toml
  4. Start the simulator:

    ./spb_pub --schema microgrid.toml --host mqtt

Create a Data Ingestion Task

  1. In the main menu on the left, open Data In and click Add Source.

  2. 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.
  3. 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.

  4. 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.
  5. 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.

  6. Configure the supertable as follows:

    • Name: Enter stb_microgrid.
    • Remove all columns. Then add one column with data type DOUBLE and name value.
    • Remove all tags. Then add three tags with data type VARCHAR(128) and names group_id, edge_node_id, and device_id.

    When you have finished configuring the supertable, click Create.

  7. At the bottom of the page, click Submit to create the data ingestion task.

  8. On the Explorer page, you can now see that the microgrid simulation data is being generated.

Get Started with TDengine IDMP

Create Element Templates

  1. In a web browser, access http://localhost:6042 and activate TDengine IDMP.

  2. From the main menu, open Libraries. Then select Element Template and click the New Element Template (+) button.

  3. 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.

  4. Repeat this process to create templates for all elements in the sample dataset.

Create Attribute Templates

  1. From the main menu, open Libraries. Click an element template and select Attribute Template from the drop-down list in the path bar.

  2. 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.
  3. 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.

  4. Click Save. Repeat this process to create attribute templates for all element templates in the sample dataset.

Create Asset Model

  1. From the main menu, open Explorer. Under Elements > Child Elements, click New Child Element.

  2. Retain the default settings and click Confirm. Name the element Industrial Park and click Save.

  3. Following the same steps, create a child element of Industrial Park named Microgrid.

  4. Following the same steps, create a child element of Microgrid named Solar Power.

  5. 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.

  6. 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

  1. In the sidebar, select Industrial Park > Microgrid > Solar Power > PV Inverter1.

  2. Open the Panels page on this element to see AI recommendations.

  3. Click Generate on a panel that you want to try. Once the panel is generated, click View to open it.

  4. 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.

  5. When you have finished modifying the panel, click Save to add it to the element.

Try AI-Generated Analysis

  1. In the sidebar, select Industrial Park > Microgrid > Solar Power > PV Inverter1.

  2. Open the Analyses page on this element to see AI recommendations.

  3. Click one of the suggested questions to generate a real-time analysis task.

  4. 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.

  • Joel Brass
    Joel Brass

    Joel Brass is a Solutions Architect at TDengine, bringing extensive experience in real-time data processing, time-series analytics, and full-stack development. With a 20 year background in software engineering and a deep focus on scalable applications and solutions, Joel has worked on a range of projects spanning joke databases, IoT, self-driving vehicles, and work management platforms. Prior to joining TDengine, Joel worked in Advisory Services for Enterprise customers of Atlassian and the Systems Engineering team at Waymo. He is currently based in the San Francisco Bay Area.