Main Content

Energy Profiling of Bluetooth Mesh Nodes in Wireless Sensor Networks

This example shows you how to perform energy profiling of nodes in a Bluetooth mesh network by using Bluetooth® Toolbox. Using this example, you can:

  • Create and configure a Bluetooth mesh network.

  • Compute energy consumption of mesh nodes in transmission, listen, sleep, and idle states by varying the number of Relay nodes, source-destination node pairs, Friend node-Low Power node (LPN) pair, and the application traffic.

  • Estimate the lifetime of mesh node based on the configured hardware-specific energy parameters.

  • Explore the impact of poll timeout and receive window size on the LPN lifetime.

The results confirm the expectation that LPN always consume less energy by spending more time in sleep, resulting in energy conservation and increased lifetime.

Bluetooth Mesh Energy Profiling

The Bluetooth Core Specification [ 2 ] includes a Low Energy (LE) version for wireless personal area networks, referred to as Bluetooth LE or Bluetooth Smart. The Bluetooth mesh profile [ 3 ] defines the fundamental requirements to implement a mesh networking solution for Bluetooth LE. Bluetooth mesh networking enables large-scale device networks in the applications such as smart lighting, industrial automation, sensor networking, and asset tracking. For information about Bluetooth LE protocol stack, see Bluetooth Protocol Stack.

Each Bluetooth mesh node possess some optional features enabling them to acquire additional capabilities. These features include the Relay, Proxy, Friend, and the LowPower features. The Bluetooth mesh nodes possessing these features are known as Relay nodes, Proxy nodes, Friend nodes, and LPNs, respectively. To reduce the duty cycles of the LPN and conserve energy, the LPN must establish a Friendship with a Friend node (mesh nodes supporting the Friend feature). This Friendship between the LPN and the Friend node enables the Friend node to store and forward messages addressed to the LPN. Forwarding by the Friend node occurs only when the LPN wakes up and polls the Friend node for messages awaiting delivery. This mechanism enables all of the LPNs to conserve energy and operate for longer durations. For more information about devices, nodes, and the Friendship in Bluetooth mesh network, see Bluetooth Mesh Networking.

In this example, the source nodes initiates mesh communication to a destination node and an LPN. During the simulation, the Friend node and LPN exchange Friendship messages. Each node computes the time spent in various states (transmission, listen, idle and sleep) and calculates its lifetime.

Configure Simulation Parameters

Specify the number of nodes (numNodes) along with their positions and simulation time. Set the seed for the random number generator to 1. The seed value controls the pattern of random number generation. For high fidelity simulation results, change the seed value for each run and average the results over multiple simulations.

% Set random number generator as "twister"

% Specify the simulation time in seconds
simulationTime = 5;

% Total number of nodes in the mesh network
numNodes = 21;

Get node positions from the MAT file. Specify the positions of Bluetooth mesh nodes as a numNodes-by-2 array, where numNodes is the number of nodes in the network. Each row specifies the Cartesian coordinates of a node, starting from the first node.


Set some of the nodes as relay nodes, source-destination node pairs, friend node and LPN.

relayNodes = [3 6 7 8 9 12 13 14 17];
sourceDestinationPairs = [1 20; 21 16];
friend = 15;
lpn = 16;

Create Bluetooth Mesh Nodes

Use bluetoothMeshProfileConfig to create mesh profile configuration object. To create a Bluetooth mesh node, use the bluetoothLENode object. Specify the role as "broadcaster-observer" and assign the mesh profile to MeshConfig.

% Initialize array to store Bluetooth mesh nodes
meshNodes = cell(1,numNodes);
clear wirelessNode; % Clear context of wirelessNode

% Create Bluetooth mesh network
for nodeIndex = 1:numNodes
    % Create and configure Bluetooth mesh profile by specifying the element
    % address (unique to each node in the network). Set relay and network
    % message repetitions.
    meshCfg = bluetoothMeshProfileConfig(ElementAddress=dec2hex(nodeIndex,4),...

    % For the configured relayNodes, enable Relay feature
    if any(nodeIndex==relayNodes)
        meshCfg.Relay = true;
    % For the configured Friend node, enable Friend feature
    if nodeIndex==friend
        meshCfg.Friend = true;
    % For the configured LPN, enable LowPower feature
    elseif nodeIndex==lpn
        meshCfg.LowPower = true;

    % Create and configure Bluetooth mesh node by assigning the mesh profile.
    % Set receiver range, advertising interval (seconds) and scan interval (seconds).
    meshNode = bluetoothLENode("broadcaster-observer",MeshConfig=meshCfg, ...
        Position=[bleMeshNetworkNodePositions(nodeIndex,:) 0],Name="Node"+num2str(nodeIndex),...

    % Store mesh nodes
    meshNodes{nodeIndex} = meshNode;

Configure Friendship Between Friend Node and LPN

Set friendship timing parameters (in seconds) such as poll timeout, receive window, and receive delay by using the bluetoothMeshFriendshipConfig object.

friendshipConfig = bluetoothMeshFriendshipConfig(PollTimeout=2,ReceiveWindow=180e-3,...

Configure the friendship between the friend node and LPN using configureFriendship method of bluetoothMeshFriendshipConfig.

friendNode = meshNodes{friend};
lowPowerNode = meshNodes{lpn};

Add Application Traffic to Source Nodes

Create a networkTrafficOnOff object to generate an On-Off application traffic pattern. Configure the On-Off application traffic pattern by specifying the application data rate, packet size, on, and off state duration. Simulate mesh communication between the specified source-destination node pairs in the mesh network.

for srcIdx = 1:numel(sourceDestinationPairs)/2
    % Create network traffic object using networkTrafficOnOff. Set data
    % rate and packet size. Set on and off times based on the simulation time.
    traffic = networkTrafficOnOff(DataRate=1,PacketSize=15,GeneratePacket=true,...

    % You can control the maximum number of hops that the source node uses
    % to relay message by setting the time-to-live (TTL) value.
    ttl = 10;

    % Attach application traffic to source
    addTrafficSource(meshNodes{sourceDestinationPairs(srcIdx,1)},traffic,...                         % Traffic object
        SourceAddress=meshNodes{sourceDestinationPairs(srcIdx,1)}.MeshConfig.ElementAddress,...      % Source element address
        DestinationAddress=meshNodes{sourceDestinationPairs(srcIdx,2)}.MeshConfig.ElementAddress,... % Destination element address

Visualize Mesh Network

Visualize the mesh network scenario by using the helperBLEMeshVisualizeNetwork helper object. Assign the helper object to the NetworkPlot parameter in the helperBLEMeshEventCallback helper object. For information on how to visualize the message flow in the mesh network, see Bluetooth Mesh Flooding in Wireless Sensor Networks.

% Object to visualize mesh network
plotScenario = helperBLEMeshVisualizeNetwork(NumberOfNodes=numNodes,...
    SourceDestinationPairs=sourceDestinationPairs,FriendPairs=[friend lpn],...
    Title="Energy Profiling in Bluetooth Mesh Network");

% Object to handle visualization callbacks
visualizeScenario = helperBLEMeshEventCallback(...

Figure Energy Profiling in Bluetooth Mesh Network contains an axes object. The axes object with title Energy Profiling in Bluetooth Mesh Network contains 7 objects of type graphplot, line. These objects represent Energy Profiling in Bluetooth Mesh Network, \color[rgb]{0 0.5 1} Node, \color[rgb]{1 0.4980 0.4980} Relay node, \color[rgb]{1 0.498 1} Friend node, \color[rgb]{0.75 0.75 0} Low Power node, \color[rgb]{0 0.5 0} Source-Destination pair (1, 20), \color[rgb]{0 0.75 0.75} Source-Destination pair (21, 16).

Run the simulation

Initialize the wireless network.

networkSimulator = helperWirelessNetwork(meshNodes);

Run all the nodes in the network for the specified simulation time.


Update simulation progress at the end of the simulation and clear context of wirelessNode.


Simulation Results

At each mesh node, the simulation captures these statistics.

  • Application end-to-end packet latency in seconds

  • Link layer (LL) throughput in Kbps

  • Time spent in listen state, transmit state, idle state and sleep state in seconds

  • Packet statistics at the application layer, network layer, transport layer, LL and physical layer

The workspace variable statisticsAtEachNode contains the cumulative value of the preceding statistics for all the nodes in the network. For a given simulation run, you can view the statistics for first five nodes. The network statistics for the first five nodes in the network are:

statisticsAtEachNode = helperBLEMeshStatistics(meshNodes);
statisticsForFirstFiveNodes = statisticsAtEachNode(1:min(numNodes,5),:)
statisticsForFirstFiveNodes=5×22 table
             End-to-end packet Latency (seconds)    Throughput (Kbps)    PHY Tx Packets    PHY Rx Packets    PHY Packet Collisions    Link Layer Tx Packets    Link Layer Rx Packets    Link Layer Dropped Packets    Sleep Time (seconds)    Idle Time (seconds)    Listen Time (seconds)    Transmission Time (seconds)    Network Layer Tx Packets    Network Layer Rx Packets    Network Layer Relayed Packets    Network Layer Dropped Packets    Transport Layer Tx Data Packets    Transport Layer Tx Control Packets    Transport Layer Rx Data Packets    Transport Layer Rx Control Packets    App Tx Packets    App Rx Packets
             ___________________________________    _________________    ______________    ______________    _____________________    _____________________    _____________________    __________________________    ____________________    ___________________    _____________________    ___________________________    ________________________    ________________________    _____________________________    _____________________________    _______________________________    __________________________________    _______________________________    __________________________________    ______________    ______________

    Node1                     0                          5.0554               117                22                    0                       117                       20                         0                          0                    0.86975                  4.089                     0.040248                         39                          20                             0                                20                               13                                   0                                    0                                   0                           13                0       
    Node2                     0                               0                 0               163                    6                         0                      154                         0                          0                          0                  4.999                            0                          0                         151                             0                               151                                0                                   0                                    0                                   0                            0                0       
    Node3                     0                           6.222               144                31                    0                       144                       31                         0                          0                     1.1395                   3.81                     0.049536                          0                          31                            48                                15                                0                                   0                                    0                                   0                            0                0       
    Node4                     0                               0                 0               129                    2                         0                      127                         0                          0                          0                  4.999                            0                          0                         127                             0                               127                                0                                   0                                    0                                   0                            0                0       
    Node5                     0                               0                 0                78                    0                         0                       76                         0                          0                          0                  4.999                            0                          0                          76                             0                                76                                0                                   0                                    0                                   0                            0                0       

This plot shows the average time spent by different type of mesh nodes in different states. The results conclude that the LPN spend most of the time in sleep state, resulting in energy conservation and increased lifetime.

fprintf("Average time statistics of different Bluetooth mesh nodes are:\n");
Average time statistics of different Bluetooth mesh nodes are:
meshNodesAvgStats = helperBLEMeshNodeAverageTime(meshNodes);

Figure Average Time Statistics of Different Bluetooth Mesh Nodes contains an axes object. The axes object with title Average Time Statistics of Different Bluetooth Mesh Nodes contains 4 objects of type bar. These objects represent Transmission, Listen, Idle, Sleep.

Configure the traffic between the mesh nodes by using the addTrafficSource method of bluetoothLENode. The transmission time at the mesh node depends on the application traffic. The transmission time at the LPN depends on the poll timeout value.

Further Exploration

Calculate Lifetime of LPN:

Use helperBLEMeshNodeLifetime helper function to calculate the lifetime of a node in the Bluetooth mesh network at the end of simulation. To compute node lifetime, the simulation time and the mesh node is given as an input to the helperBLEMeshNodeLifetime helper function. The node lifetime is calculated by using the energy parameters that are hardware dependent. To update these hardware parameters, use the helperBLEMeshNodeLifetime helper function.

lifeTime = helperBLEMeshNodeLifetime(lowPowerNode,simulationTime);
Configured hardware parameters for a 1200 mAh battery are:
       Hardware parameters        Configured values (mA)
    __________________________    ______________________

    Self-discharge                      0.0013699       
    Transmission on channel 37               7.57       
    Transmission on channel 38               7.77       
    Transmission on channel 39                7.7       
    Listening                                10.3       
    Sleep                                     0.2       
    Idle                                     1.19       

Timing metrics at Node16 are:
     Time variables      Time (seconds)
    _________________    ______________

    Transmission time       0.016704   
    Listen time                  1.2   
    Sleep time                3.1724   
    Idle time                0.60993   
fprintf("Lifetime of %s is %.4f days.\n",lowPowerNode.Name,lifeTime);
Lifetime of Node16 is 18.0435 days.

Lifetime of LPN by Varying Poll Timeout

The lifetime of an LPN depends on the time for which the node is in the listen state. In a given poll timeout, an LPN is in listen or sleep state for most of the time. The receive window for each poll request of an LPN determines the time spent in listen state. The time spent in transmission state is negligible.

Visualize the impact of the poll timeout and receive window on the lifetime of LPN by using the helperBLEMeshLPNLifetimeVSPolltimeout helper function.

The preceding plot concludes that the lifetime of LPN is directly proportional to the poll timeout. The poll timeout specifies the maximum time between two consecutive requests from an LPN to Friend node. As the poll timeout increases, the LPN spends more time in sleep state that results in increasing the lifetime of the LPN.

This example shows how to create and configure a multinode Bluetooth mesh network and analyze the message exchange in the network. This example also enables you to analyze the behavior and the advantages of the Friendship between Friend node and LPN. To calculate the time spent by each node in different states, the Bluetooth mesh network is simulated with source-destination node pairs, and a Friend node-LPN pair. The plot of the average time spent by each node in different states shows that the LPN always consumes less energy by spending more time in sleep state. You can further explore the energy profiling of LPN by varying the poll timeout and receive window values.


The example uses these helpers:

Selected Bibliography

  1. Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 25, 2021.

  2. Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification". Version 5.3.

  3. Bluetooth Special Interest Group (SIG). "Bluetooth Mesh Profile". Version 1.0.1.

See Also



Related Topics