My daughter has some health issues that requires her to be hooked up to a pulse oximeter at night that monitors her oxygen level and heart rate. We have night nurses so we can sleep, but sometimes we wake up at night and want to “check her numbers” without going into her bedroom and possibly waking her up (our daughter is usually a very light sleeper). The pulseox does have (very loud) alarms that go off according to limits we set, but there are subtle trends that we may watch for according to what type of day she had. Again, the standard way to check these in the middle of the night would be to walk into her room, look at the current numbers and listen to how she is breathing, and then ask the nurse about any “non-alarm” trends she may have noticed. I knew there had to be a better way to do this.
The simplest approach seemed to just put a baby monitor with video in front of the pulseox device and then we could bring up the camera on our phone to see the numbers. Besides the cost and quality issues of most nightime baby monitors, there did not seem to be a location in the room to put the baby monitor that would not either block the nurse’s view of the numbers or be too far away from our daughter for the audio to pick up well. We also already own an audio baby monitor that works very well, so it seems a waste to buy another one just to add the remote video to see the current numbers and not even tell us average/trend information.
The device that the home health company provides us is a Masimo RAD-8. It has a serial/RS232 port on the back of it. I was happy to find that the data coming off the port is not protected, so getting the data from the pulseox device to a remote display seemed possible (similar to how they do it at a hospital’s nurse station). I chose to use a Raspberry Pi to capture the data, process it, and present it on a web server where we could then load a web page with our phone. The main reasons for choosing this device were low cost, small size, and it has an established community in case I ran into any problems.
Step 1: Hardware List
- Masimo RAD-8 Pulse Oximeter
- Raspberry Pi Model B+ with power adapter
- Wifi dongle (optional)
- RPi case(optional)
- 8GB MicroSD (you can find these with Raspbian pre-installed)
- USB->Serial/RS232 Adapter Cable (I had one already from an old exercise bike, but here is a similar one on Amazon for ~$20. Note that the chipset in mine is in the FTDI D2XX family. This seems to be a popular chipset and it does work on RPi, but other cables/chipsets may not)
- RS232 extension (optional)
You can buy kits online that package #2-5 above for $50-$60. If you don’t have the #6 like I did and want the #7 extension cable, this entire project from scratch will cost about $90. I am not including the cost of the actual pulse oximeter.
Step 2: Software List
On the Raspberry Pi:
Optional software used:
All of this software is free. I won’t go into detail on how to configure all the layers as there are install guides from each link above. Most were installed simply using the “sudo apt-get install ” command, as the default respositories in Raspbian were able to find them.
The zip file attached to this step contains 2 files
- poxs.php is the script for the background process that collect data and inserts into the database
- gpulse.php is the web page code that retrieves from the database and displays output
Step 3: The raw data
First I need to see the format of raw data coming out of the machine. I hooked up the usb->serial cable from the RPi to the back of the pulseox machine, put the sensor on my finger and turned on it.
I needed to know the name of the usb->serial adapter device on the RPi so I could watch it for incoming data. I found this with the following commands:
pi@raspberrypi ~ $ lsusb Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
The last line was obviously my device and now I know the type of chip in it and who made it. There was a device listed in the /dev directory called ttyUSB0, so this was probably the right one. To confirm, I checked the output from dmesg just after connecting the cable:
pi@raspberrypi ~ $ dmesg | grep FTD [ 3.711017] usb 1-1.5: Manufacturer: FTDI [ 3.718342] usb 1-1.5: SerialNumber: FTDDCQ7W [ 9.429993] usbserial: USB Serial support registered for FTDI USB Serial Device [ 9.929322] ftdi_sio 1-1.5:1.0: FTDI USB Serial Device converter detected [ 10.722481] usb 1-1.5: FTDI USB Serial Device converter now attached to ttyUSB0
Every terminal device has specific settings it expects, such as connect speed, bits per character, etc. I found an Operator’s Manual for this pulseox through a Google search that gave me the info I needed to setup using the stty command:
- Baud Rate: 9600
- Bits per character: 8
- Parity: None
- Bits: 1 start, 1 stop
- Handshaking: None
Even if I didn’t find these settings from a web search, they are fairly common (8-N-1) settings for a device like this, so some settings can be left default or guessed in lieu of a spec, without impact to the simple code for this project. The command needed to setup according to above:
stty -F /dev/ttyUSB0 9600 cs8 -parenb -cstopb -crtscts
The last thing to do is use the cat command to check for output:
cat /dev/ttyUSB0 12/30/14 22:40:35 SN=0000057681 SPO2=096% BPM=106 PI=01.68% SPCO=--.-% SPMET=--.-% DESAT=-- PIDELTA=+-- ALARM=0000 EXC=000800
Great, so the data looks pretty simple to parse, feed into a database, and present on a web page. Besides the date/time, the only pieces that I want right now are percent oxygen saturation (spo2) and heart rate (bpm). If anyone knows the purpose of the other fields, I have some academic curiousity but don’t need them for this project.
Step 4: Create Database
SQLite is a very simple to use database. From the command line I executed the following:
sqlite3 pulseox.db "CREATE TABLE pulseox(stampdate text, stamptime text, spo2 text, bpm text, id integer primary key)"
To test the database and the id column, I issued the following insert/select command:
sqlite3 pulseoxdb "INSERT into pulseox(stampdate, stamptime, spo2, bpm) values('12/30/14','08:00:00','SPO2=100%','BPM=100');SELECT * from pulseox" 12/30/14|08:00:00|SPO2=100%|BPM=100|1
Now that the database is setup, I can move on to parsing realtime data and inserting it into this table.
For more detail: Pulse Oximeter Data Capture with Raspberry Pi