MATLAB Answers

Capturing heart rate from USB ANT+ dongle and chest strap

179 views (last 30 days)
Hello,
I'm trying to figure out the simplest way to acquire data live from my heart rate monitor (chest strap), which communicates wirelessly with the PC through an ANT+ USB dongle. I really don't know much about drivers but I think I have to use the Instrument Control Toolbox and make a Matlab driver for this? Unless the Data Acquisition Toolbox can get the USB data directly? Any tips would be appreciated!
Edit3: As explained in an answer below, some ANT dongles can work with virtual COM port drivers, and thus Matlab can interface with them as a serial port. Unfortunately, the chip in my device is Nordic nRF24AP2-USB which includes USB and does not provide a VCP driver. Thus to interface with it I need to use their API. The way I think I can do this is with MEX files, but I'm still wondering: does the Instrument Control Toolbox provide anything that would make this easier?
Thanks! Marc

  0 Comments

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 21 Jul 2014
You don’t necessarily have to use the Instrument Control Toolbox or the Data Acquisition Toolbox. You didn’t say what OS you have, but if you plug the USB dongle into your computer — and the Force is with you — Windows should find the driver for you and install it. (You may have to try different USB ports. All of mine function correctly, but for some reason, only the ones on the right side of my relatively new HP laptop will trigger the Windows search behaviour.)
Set the USB interface up as a serial port. See the Serial Port Devices documentation for details.
I didn’t do exactly what you are doing, but about five years ago I got a fingertip plethysmograph (measures pulse contour, oxygen saturation, heart rate, and a few other things) that had limited offline data storage and a direct connection with a USB cable, and after finding the details of the hardware and its communications protocol online (PDF documentation from an Internet search on the hardware Windows identified), was able to get all the information from the device and display it in real time. I had to do a lot of experimenting, but I got it to work.
I have a couple routines from that effort that may help get you started. I’m attaching them here for your reference. (Unfortunately, I don’t remember the details of the logic behind them. I believe I got some of the information in them from the hardware and driver documentation, so it’s best you use that information for your hardware and driver in your application.) They were written for a Windows 7 machine in R2009b, so there could be version differences as well.

  10 Comments

Show 7 older comments
Star Strider
Star Strider on 25 Jul 2014
I managed to find some information on ANT by searching for your nRF24AP2-USB chip (that also seems to have the drivers) and on the Nordic developer resources Software and Downloads site. The ANT Message Protocol and Usage and Interfacing with ANT General Purpose Chipsets and Modules (I can’t link to them directly) are likely to be the most informative, but that’s not saying much. They’re nowhere near as straightforward as my pulse-oximeter, and the documentation does not have any discernible references to simple USB interfacing, at least that I could find. There are several examples of C scripts, so if you’re going the MEX route, they could help.
The second document however gives an Alberta address for what is apparently their Canadian affiliate (228 River Avenue, Cochrane, Alberta, Canada T4C 2C1), so contacting them directly may be an option. ANT seems also to have its own proprietary interface software environment, probably to make it easier for developers. Getting access to it may be challenging, because Nordic wants you to establish an account with them to log in to get the information and software. I get the impression that the USB interface capability is possible, but due to the complexity of the ANT hardware, might be challenging to implement.
Marc Lalancette
Marc Lalancette on 25 Jul 2014
Yup that pretty much echoes what I saw yesterday, they don't seem to have a VCD driver. However, I have signed up as an "ANT adopter" so I have access to all the documentation of the ANT API, code examples etc. So I think for the mex option, I'll have all the information I need from ANT. Still, since that does seem like a lot more work, and there is one report of making the Nordic chip work with the FTDI drivers, I'll give that a shot first.
Star Strider
Star Strider on 25 Jul 2014
I didn’t sign up (no reason for me to) so I didn’t explore those options. The FTDI drivers seem to be much more straightforward — similar to my pulse-oximeter drivers from what I saw — so that is definitely the way to go if you can possibly get it to work. I get the impression that ANT isn’t eager to have others develop software for their devices, or maybe with all the RF networking stuff in ANT (they thought of everything, including encryption), it’s simply difficult to do it.

Sign in to comment.

More Answers (15)

Marc Lalancette
Marc Lalancette on 25 Jul 2014
I finally got some details on the ANT forum, which I will paraphrase here to my limited understanding level:
Some ANT USB dongles use a Nordic chip for ANT, but a separate chip for USB; that second chip either from SiLabs or FTDI, thus the possibility of using a VCP driver. Other dongles use a Nordic chip which has USB integrated, and that "requires writing code to interface with". This is the case for my dongle "ANT USB Stick 2", which uses the nRF24AP2-USB chip with USB integrated, that uses the driver libusb.
Thankfully, there are quite a few code examples for me to look at, in particular from the ANT developer site. If I get this to work, I'll probably post the code on the file exchange, but it could take a little while.

  1 Comment

Star Strider
Star Strider on 25 Jul 2014
That’s what I suspected from what I read. I would definitely encourage you to write a function for the File Exchange for your application.
The reason I didn’t formalise my pulse-oximeter functions and put them up is that there have never been any Questions that I’ve seen that asked for them. (Besides, they were relatively easy to figure out and code from the online documentation, so I suspect others had no problems with it either.)

Sign in to comment.


Peter Gamma
Peter Gamma on 23 Jan 2020
Edited: Peter Gamma on 23 Jan 2020
Data from ANT+ sensors can be streamed from GARMIN watches over the EventHubApp:
to an EventHub in the Microsoft Azure Platform
and from there to Microsoft Power Bi:
and from there to the MATLAB Production Server:
and from there to MATLAB
Matlab Production Server is an enterprise product that is be installed by the administrators of the server:

  0 Comments

Sign in to comment.


Peter Gamma
Peter Gamma on 23 Jan 2020
Edited: Peter Gamma on 23 Jan 2020
Is MATLAB Production Server included in a Standard MATLAB licence? A Standard MATLAB licence is $2,350 USD perpetual license or $940 USD annual license:
If the answer is yes, is this the most low-cost option for the above descibed path to live-stream sensor data from a GARMIN watch to MATLAB?

Peter Gamma
Peter Gamma on 23 Jan 2020
Edited: Peter Gamma on 23 Jan 2020
This is a pity. Unfortunately, there is no other Power BI integration with MatLab to this date, to my knowledge:
Is CSV data import into MATLAB as recommended in the Power BI community a contemporary solution for the year 2020?

  2 Comments

Peter Gamma
Peter Gamma on 16 Mar 2020
Is MATLAB Production Server really necessary to stream the GARMIN watch from Microsoft Power BI to MATLAB?
Is a Power Query M-script in Power B with a custom data connector for the GARMIN watch which connects to the RESTful API of MATLAB not sufficent to integrate the GARMIN watch into MATLAB?
Peter Gamma
Peter Gamma on 20 Mar 2020
Or even better: what is missing is a standard interface in Microsoft Power Bi for the GARMIN watch which can connect to MATLAB. There is already a demo software available for Microsoft Power Bi for the GARMIN watch. This demo software could be connected to the RESTful API of MATLAB, or Lab Streaming Layer LSL could be connected to this demo software. LSL would be well documented and supported standard interface for the GARMIN watch to MATLAB or Python.

Sign in to comment.


Peter Gamma
Peter Gamma on 26 Mar 2020
There is also a device from Moxy to get ANT+ sensor data into Matlab:
There's an example code for MATLAB in the manual.

  4 Comments

Show 1 older comment
Peter Gamma
Peter Gamma on 27 Mar 2020
The example code is written for MATLAB? Or is it a C+ code which was integrated into MATLAB? Whatever, it runs in MATLAB.
Peter Gamma
Peter Gamma on 27 Mar 2020
And it s to my knowledge the first and only commercially available ANT+ live stream which is available for MATLAB to this date (exept for MATLAB Production Server which is an expensive enterprise product).

Sign in to comment.


Peter Gamma
Peter Gamma on 1 Apr 2020
Edited: Peter Gamma on 2 Apr 2020
Scott W Harden, DMD, PhD, dentist and biological research scientist with a passion for collaborative public software and hardware development:
developed the sound card ecg:
and the ScottPlot:
There are now two options availble for a live-stream from a GARMIN watch:
  1. Moxymonitor ANT to Serial Converter which is commercially available (for MATLAB):
2. Garmin IoT Series is a Microsoft Azure Cloud solution from Dave Does Demos :
Is it possible to use Scott s software for the GARMIN watch to analyze real-time data from a GARMIN watch? ? Is there any software which is better than Scott s software to use it for a GARMIN watch? Can Scott s software be integrated into MATLAB?

  0 Comments

Sign in to comment.


Peter Gamma
Peter Gamma on 8 Apr 2020
Now, it is also possible to live-stream ANT+ sensor data to Microsoft Excel and to any application that can read and decode a serial string, personal communication from Moxy CEO Roger Schmitz:

  5 Comments

Show 2 older comments
Peter Gamma
Peter Gamma on 11 Apr 2020
4. Pairing of Bluetooth smart sensors like the Polar H7 heart rate sensor to Matlab might be easier than streaming ANT+ sensor data to Matlab::
Peter Gamma
Peter Gamma on 12 Apr 2020
Another streaming-service to Matlab which could be brought back to live is livetrack.io:
A programmer which can communicate with Nils Knielings is necessary for this.

Sign in to comment.


Peter Gamma
Peter Gamma on 11 Apr 2020
Edited: Peter Gamma on 11 Apr 2020
The group of Milind Y. Desai, MD. Department of Cardiovascular Medicine, Cleveland investigated the Accuracy of commercially available heart rate monitors in athletes:
Among those devices where Garmin Forerunner 235 compared to ECG devices. I sent an e-mail some time ago to Milind Y. Desai and asked him to include the POLAR OH1 as currently potentially the most accurate optical heart rate sensor in his next study.
There was no response from Milind Y. Desai. I might be worth contacting him.
I miss an investigation of the accuracy of POLAR OH1 compared to an ECG device.
The Polar OH1 supports ANT+ and bluetooth smart.It might be worth implementing this device in MATLAB.

  5 Comments

Show 2 older comments
Peter Gamma
Peter Gamma on 13 Apr 2020
Smartphone client is already incuded in this solution. What is missing are examples with integrated bluetooth smart sensors like the Polar OH1 heart rate sensor or the Stryd foot pod.
Peter Gamma
Peter Gamma on 13 Apr 2020
According to this review:
the Stryd foot pod (BLE & ANT+) is currently the most accurate foot pod, which can be paired to sports watches or Android applications via BLE or ANT+. This makes this device attractive for scientific and biomedical purposes.
Peter Gamma
Peter Gamma on 14 Apr 2020
Richard J. Davidson, Professor of Psychology and Psychiatry at the University of Wisconsin–Madison, Center Founder and Director of the Center for Healthy Minds in Wisconsin–Madison says: «I envision a day when mental exercise will be as much a part of our daily lives as physical exercise and personal hygiene.”https://centerhealthyminds.org/
Polar OH1 and STRYD foot pod shoud be supported by MATLAB, since they are suitable for mental exercise, and it should be possible to get these data in MATLAB for scientific and biomedial purposes.

Sign in to comment.


Peter Gamma
Peter Gamma on 14 Apr 2020
My personal conclusion:
Only nerds try to stream ANT+ sensors to Matlab. Smart people choose blueooth smart sensors, which can be connected directly to Matlab since Matlab release R2019b:
and try to connect them with the bluetooth smart example in Matlab, which exists since Matlab release R2020a:



Peter Gamma
Peter Gamma on 15 Apr 2020
You find the answer whether there is an example how to live-stream of ANT+ sensor data from an ANT+ stick to MATLAB through Darren HaguesVirtual Power here:

  0 Comments

Sign in to comment.




Peter Gamma
Peter Gamma on 6 Jun 2020
To get ANT+ sensor data for instance from a Garmin watch in real-time is difficult. Also to get post-processing ANT+ sensor data is difficult. Garmin stores sensor data in .fit files. But how is .fit file structure defined? .fit files can be conerted to .csv files. But when .fit files are converted by the THIS IS ANT .fit to csv tool, the data structure is not clear. There are sports sensors like for instance the Polar H7, the Polar OH1, or the Stryd foot pod which can also be used for scientific purposes. These are high-quality low-cost sensors. There are papers and studies available which confirm their accuracy. But to access sensor data from these sensors is difficult. I put together a list of links how to obtain live-stream sensor data from Garmin watches, and also links to some other options:

  0 Comments

Sign in to comment.