Main Content

Create, Configure, and Visualize BLE Mesh Network

Communications Toolbox™ Library for the Bluetooth® Protocol features enable you to create, configure, and visualize a Bluetooth low energy (BLE) mesh network. For information about BLE mesh networking, see Bluetooth Mesh Networking.

Create, Configure, and Visualize BLE Mesh Network

Specify the total number of BLE mesh nodes.

totalNodes = 6;

Create a BLE mesh node by using the helperBLEMeshNode object. This helper function creates a BLE mesh node object and models the complete protocol stack in a mesh node.

meshNodes(1,totalNodes) = helperBLEMeshNode();                % Create a list of mesh nodes
for nodeIdx = 1:totalNodes
    meshNode = helperBLEMeshNode();                           % Object for a mesh node
    meshNode.Identifier = nodeIdx;                            % Unique identifier for a mesh node
    meshNodes(nodeIdx) = meshNode;                            % Assign node to the list

Configure the mesh nodes as source, destination, and relay. Node 6 is termed as the end node.

sourceDestinationPairs = [1 4; 2 5];
relayNodeIDs = 3;

Assign positions to the mesh nodes by using one of these options.

  • Specify an n-by-2 matrix, where n is the total number of mesh nodes. Each row in the matrix represents the x- and y-coordinate of the mesh node. To use this option, the NodePositionType property of the helperBLEMeshVisualizeNetwork object must be set to 'UserInput'.

  • Load a .mat file containing node positions into the workspace. To use this option, you must set the NodePositionType property of the helperBLEMeshVisualizeNetwork to 'UserInput'.

For this example, assign positions to the mesh nodes by specifying six (x, y) coordinates as a matrix.

bleMeshNodesPositions = [15 25; 15 5; 30 15; 45 5; 45 25; 60 25];

Visualize the BLE mesh network by using the helperBLEMeshVisualizeNetwork function. This helper function creates a BLE mesh network visualization object with configurable properties.

meshNetworkGraph = helperBLEMeshVisualizeNetwork();          % Object for BLE mesh network visualization                
meshNetworkGraph.NumberOfNodes = totalNodes;                 % Total number of mesh nodes
meshNetworkGraph.NodePositionType = 'UserInput';             % Option to assign node position             
meshNetworkGraph.Positions = bleMeshNodesPositions;          % List of all node positions
meshNetworkGraph.VicinityRange = 25;                         % Transmission and reception range of mesh node
meshNetworkGraph.Title = 'BLE Mesh Network';                 % Title of plot
meshNetworkGraph.SrcDstPairs = sourceDestinationPairs;       % Source-destination pair
meshNetworkGraph.NodeState = [1 1 2 1 1 1];                  % State of mesh node
meshNetworkGraph.DisplayProgressBar = false;                 % Display progress bar
meshNetworkGraph.createNetwork();                            % Display mesh network

Figure BLE Mesh Network contains an axes. The axes with title BLE Mesh Network contains 5 objects of type graphplot, line. These objects represent \color[rgb]{1 0.4980 0.4980} Relay node, \color[rgb]{0 0.5 1} End node, \color[rgb]{0 0.5 0} Source - Destination pair (1, 4), \color[rgb]{0 0.75 0.75} Source - Destination pair (2, 5).


[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed September 25, 2020.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.2.

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

[4] Bluetooth Special Interest Group (SIG). "Bluetooth Mesh Model Specification." Version 1.0.1.

Related Topics