File Exchange

image thumbnail

Shimmer MATLAB Instrument Driver

version (1.48 MB) by Shimmer Engineering Team
Object oriented solution for Shimmer sensor data capture directly into Matlab


Updated 22 Sep 2017

View License

Editor's Note: Popular File 2015

Object oriented solution for Shimmer data capture directly into MATLAB. Provides for full configuration functionality to set features such as sampling rate, accelerometer range and which sensors are enabled/disabled. Also provides solutions for low battery warning and 3D orientation estimation. Allows for simultaneous data capture of both raw data and calibrated data from multiple Shimmer units. Includes example .m scripts which demonstrate the use of the ShimmerHandle class including plotting of data and writing data to a file. Includes documentation and help info.

Comments and Ratings (11)


Two questions:
I am trying to add GSR and PPG to the plotandwriteexample function and can't get it to work.
Has anyone tried this before and succeeded? Banging my head against the wall as I seem to be missing something and can't figure it out.

Also: do I need to adjust anything in realterm or do I use the default settings?


i want to use the shimmer3 to track the object poisition. it look like the 3D orientation , but add the object poisition,
it can be done?

Ilie Galit

Previous problem was solved.
Support can be found here:

Ilie Galit

Ilie Galit

I was trying to use:
>> plotandwriteexample('5',20,'data.dat')
but this is what I get:
Error using actxserver (line 90)
Server creation failed. Invalid ProgID 'realterm.realtermintf'.

Error in ShimmerHandleClass/initialiserealterm (line 12004)
thisShimmer.Hrealterm = actxserver('realterm.realtermintf'); % Start Realterm as
a server

Error in ShimmerHandleClass/opencomport (line 12022)
initialiserealterm(thisShimmer); % Define and open
realterm server

Error in ShimmerHandleClass/connect (line 4741)
isOpen = opencomport(thisShimmer); %
Attempt to establish a connection by opening the comport

Error in plotandwriteexample (line 46)
if (shimmer.connect) % TRUE if the
shimmer connects

I thought that it might be because I indicated the wrong Com Port, but then I checked with shimmerCapture, and it was connecting to the 5th. Any solutions ?

I'm trying to run the example ppgheartrateexample.m and I get this error Undefined variable "com" or class "com.shimmerresearch.biophysicalprocessing.PPGtoHRAlgorithm".

Error in ppgtoheartrateexample (line 67)
com.shimmerresearch.biophysicalprocessing.PPGtoHRAlgorithm(fs,numberOfBeatsToAve,useLastEstimate); %
create PPG to Heart Rate object: Sampling Rate = 204.8Hz, Number of Beats to Average = 1 (minimum),
Repeat last valid estimate when invalid data is detected.

I'm using matlab R2016

I have a shimmer 3D accelerator and software that write x,y,z axis data in dat file.I want to detect, real time activities detection where 128 readings/window (2.56 sec data) and 50% overlap like the dataset for "Machine Learning Made Easy"

if ~exist('rawSensorData_train.mat','file') && ~exist('rawSensorData_test.mat','file')

%Load Train Data
load rawSensorData_train

%Display data summary
% 923(Train data) will be changed w.r to data number
plotRawSensorData(total_acc_x_train, total_acc_y_train, ...

%Create Table variable for train data
rawSensorDataTrain = table(...
total_acc_x_train, total_acc_y_train, total_acc_z_train);

%Extract features from Train raw sensor data
T_mean = varfun(@Wmean, rawSensorDataTrain);
T_stdv = varfun(@Wstd,rawSensorDataTrain);
T_pca = varfun(@Wpca1,rawSensorDataTrain);

humanActivityData = [T_mean, T_stdv, T_pca];
humanActivityData.activity = trainActivity;

%T_medn = varfun(@Wmedian,rawSensorDataTrain);
%humanActivityData = [T_mean, T_stdv, T_medn];

%classificationLearner calling,learning & export model

%Load Test Data (476 test data)
load rawSensorData_test

% Create Table variable for test data
rawSensorDataTest = table(...
total_acc_x_test, total_acc_y_test, total_acc_z_test);

% Extract features from Test raw sensor data
T_mean = varfun(@Wmean, rawSensorDataTest);
T_stdv = varfun(@Wstd,rawSensorDataTest);
T_pca = varfun(@Wpca1,rawSensorDataTest);

humanActivityData = [T_mean, T_stdv, T_pca];
humanActivityData.activity = testActivity;

%T_medn = varfun(@Wmedian,rawSensorDataTest);
%humanActivityData = [T_mean, T_stdv, T_medn];

%Using trained model(called trainedClassifier),
%Features and Test raw sensor data
%calling |*plotActivityResults| function & Show the result


Fan Yang

Server creation failed. Invalid ProgID how to solve it

Changes since v2.1:

- Bridge Amplifier support for Shimmer3 (Shimmer2/2r equivalent is known as Strain Gauge)
- Improved filter implementation (using FilterClass.m)
- Functions for setting wide-range accelerometer high resolution and low power modes for Shimmer3
- Compatibility change signal names accelerometers (see User Manual section 'Differences between Shimmer2r and Shimmer3')
- Use of macros for enabling sensors
- Function specific warnings
- Revised comments
- pppgtoheartrateexample (Heart Rate from Photo Plethysmograph)
- Improved existing examples
- Firmware compatibility codes

Current release is v2.2.

Please note that BtStream firmware v0.4.0 or later is required for Bridge Amplifier functionality. Please download from

Current release is v2.1.

Please note that BtStream firmware v0.3.0 or later is required for ExG functionality. Please download from


Changes since Rev 2.7

- Bugfix -> HardwareCompatibilityCode for Shimmer3 IMU (SR31).
- Minor other bugfixes.
- Examples now also write signal format/units to file.

- Added support for new IMU/BMP sensors. Based on 'HardwareCompatibilityCode', see determinehwcompcode().
- Added Pressure/temperature example - BMP180/BMP280.

v2.6 - for full compatibility use with FW: BtStream 0.8.0 / LogAndStream 0.6.0
- Improved ECGtoHR algorithm
- PC System Timestamps for sync.
- Three bytes timestamp support (BtStream 0.8.0/LogAndStream 0.6.0 and later).

- Updated readfirmwareversion() for compatibility with FW versions BtStream 0.6.0 / LogAndStream 0.4.0 and higher.
- minor fixes/changes.

v2.4 - for full compatibility use with FW: BtStream v0.5.0 / LogAndStream v0.3.0.
- Added resettodefaultconfiguration.
- Autoset data rates when Shimmer sampling rate is set.
- See Readme.txt for details.

v2.3 - for full compatibility use with FW: BtStream v0.5.0 / LogAndStream v0.3.0.

- ExG lead-off support
- Get Expansion Board ID support
- LogAndStream FW support
- Configurable Baudrate support
- ecgtoheartrateexample (Heart Rate from ECG)

Re-uploaded rev2.2

Please note that BtStream firmware v0.4.0 or later is required for Bridge Amplifier functionality. Please download from

- ExG support for Shimmer3 (including examples)
- Add battlimitwarning for Shimmer3
- Revised comments and warnings

Removed unused scripts and folders, users should note that, BTStream firmware is required on the Shimmer device when using the Instrument Driver. Latest Version of BTStream should always be used, and is readily available on our website.

Rev 1.9
- Added support for GSR+ Expansion Board

Rev 1.8
- Support for pressure sensor (Shimmer3)

- fix for BTStream (Shimmer3) and Boilerplate having the same version number
- updates to comments

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor