Saturday, October 12, 2019

accessing CMS 50D+ using Python on Ubuntu linux



https://www.tranzoa.net/~alex/blog/images/Communication%20protocol.pdf

********************

https://github.com/paulvangentcom/heartrate_analysis_python
https://python-heart-rate-analysis-toolkit.readthedocs.io/en/latest/

********************

https://www.atbrask.dk/?p=244
https://github.com/atbrask/CMS50Dplus

git clone https://github.com/atbrask/CMS50Dplus.git
sudo python3 cms50dplus.py LIVE /dev/ttyUSB0 foo.csv

$ head foo.csv
"Time","PulseRate","SpO2","PulseWaveform","BarGraph","SignalStrength","Beep","FingerOut","Searching","DroppingSpO2","ProbeError"
"2019-10-13 00:48:55.022638",0,0,0,1,4,False,False,True,False,False
"2019-10-13 00:48:55.039349",0,0,14,1,4,False,False,False,False,False
"2019-10-13 00:48:55.056106",0,0,0,0,4,False,False,False,False,False

$ tail foo.csv 
"2019-10-13 00:49:15.130141",79,97,37,4,5,False,False,False,False,False
"2019-10-13 00:49:15.146497",79,97,35,4,5,False,False,False,False,False
"2019-10-13 00:49:15.163291",79,97,34,4,5,False,False,False,False,False
"2019-10-13 00:49:15.179896",79,97,33,4,5,False,False,False,False,False
"2019-10-13 00:49:15.196665",79,97,32,4,5,False,False,False,False,False
"2019-10-13 00:49:15.213300",79,97,32,4,5,False,False,False,False,False

********************
https://github.com/tobac/cms50ew

git clone https://github.com/tobac/cms50ew.git
sudo -H pip3 install matplotlib pygal
sudo apt-get install bluetooth libbluetooth-dev
sudo python3 -m pip install pybluez
sudo python3 cms50ew_cli.py  live /dev/ttyUSB0 --csv tobac.csv --mpl

$ cat tobac.csv 
Time [s],Finger out,Pulse rate [bpm],SpO2 [%]
5,N,0,0
6,N,0,0
7,N,0,0
8,N,0,96
9,N,0,96
10,N,96,0
11,N,0,0
12,N,96,96

********************
https://github.com/jimmynewland/paths-up-expeditions-in-computing-ret2018


git clone https://github.com/bhpayne/paths-up-expeditions-in-computing-ret2018.git
The Python version is 2 :(
I made a bunch of changes
sudo -H pip3 install pyserial

sudo python3 read_from_1cms.py

CMS 50D+ pulse oximeter

I purchased a CMS 50D+ pulse oximeter from Amazon for $38 in 2015.

How a pulse oximeter works: https://www.howequipmentworks.com/pulse_oximeter/

USB

The first time I plugged the device into my USB port, dmesg reported the following:

[  113.192067] usb 4-1: new full speed USB device number 2 using uhci_hcd
[  113.581236] usbcore: registered new interface driver usbserial
[  113.581253] USB Serial support registered for generic
[  113.581288] usbcore: registered new interface driver usbserial_generic
[  113.581290] usbserial: USB Serial Driver core
[  113.590473] USB Serial support registered for cp210x
[  113.590511] cp210x 4-1:1.0: cp210x converter detected
[  113.700056] usb 4-1: reset full speed USB device number 2 using uhci_hcd
[  113.843245] usb 4-1: cp210x converter now attached to ttyUSB0
[  113.843265] usbcore: registered new interface driver cp210x
[  113.843267] cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver


I'm not sure how to poll the saved data, or get live data from the USB device

See this analysis
https://www.tranzoa.net/~alex/blog/?p=371
and
http://www.jimmynewland.com/wp/about-jimmy/presentations/comparing-ppg-signals-open-vs-closed/
with source code
https://github.com/jimmynewland/paths-up-expeditions-in-computing-ret2018
specifically
https://github.com/jimmynewland/paths-up-expeditions-in-computing-ret2018/blob/master/cms50dplus.py

Ubuntu 

In Ubuntu, I installed SleepyHead
http://sleepyhead.sourceforge.net/wiki/index.php?title=Main_Page
http://jedimark64.blogspot.com/p/sleepyhead.html
http://sourceforge.net/projects/sleepyhead/
http://sourceforge.net/projects/sleepyhead/files/Releases/Linux/

sudo dpkg -i sleepyhead_0.9.2-1_i386.deb
SleepyHead
I can view live data and save data to file.

cd ~/Documents/SleepyHeadData/Profiles/
go into the most recent directory, ie
cd CMS50_560ee6c6

Although I am able to see the save files, they are binary and I cannot read them.
SleepyHead hits a segfault

Windows XP

The pulse oximeter came with a mini-CD with application software for Windows. I installed the SPO2 Assistant exe, which included a CP210x USB to UART Bridge Driver Installer.

Two programs are installed: "SPO2 Review v1.5" and "SPO2 manager v1.5"

"SPO2 manager v1.5" automatically saves the live data to "C:\program files\Sp02\Data" in both binary and CSV format! Yay