How can I communicate with a BLE device in Simulink?

C
communicate · Sep 3, 2021 · 2.4K views
Question
I would like to communicate with a BLE (Bluetooth low energy) device in Simulink. However, I found no BLE blocks in the Simulink library. Is this supported?  
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Aug 24, 2026
There is currently no Simulink block that can directly read from a BLE device using the host PC interface. An enhancement request to add BLE Read/Write blocks to Simulink has been submitted to our development team.
 
As a workaround, you can add a MATLAB Function Block in your model that leverages the ble() function from MATLAB, which has been available since R2019b:
 
The code inside the MATLAB Function Block would be along the lines of:
 
 
function y = fcn()    
    persistent b;    %automatically initialized to []
    persistent hr;   %automatically initialized to []

      %%extrinsic declarations
      coder.extrinsic('ble');
      coder.extrinsic('characteristic');
      coder.extrinsic('read');
      if(isempty(b))
          b = ble("UA E39 MODULE");
          hr = characteristic(b, "heart rate", "heart rate measurement");
      end

      %%initialize output
      y = zeros(...)
      %%read data from BLE device
      data = read(hr);
      %%post-process the data
      y = ...
  end

Note that the 'ble'-related functions do not support code generation and therefore need to be declared as extrinsic.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!