# Pulse Oximeter Wireless Data Logger

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/090/572/medium800/biometric_IMG_1966.jpg?1587567157)

![](https://cdn-learn.adafruit.com/assets/assets/000/090/589/medium800/biometric_data2.png?1587580700)

You can measure your blood oxygen level and pulse rate using a fingertip pulse oximeter -- and now with this project you can log that data wirelessly onto an SD card! Bring the comma-separated log file into your graphing software or quantified self apps for total control of your data!

Using a **Feather nRF52840 Express** with the **Adalogger FeatherWing** for real-time clock and SD card read/write capabilities. Code it all in CircuitPython and you'll be automatically logging data each time you use the pulse oximeter.

## Parts
### Adafruit Feather nRF52840 Express

[Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
The **Adafruit Feather nRF52840 Express** is the new Feather family member with Bluetooth® Low Energy and _native USB support_ featuring the nRF52840!&nbsp; It's our take on an 'all-in-one' Arduino-compatible + Bluetooth® Low Energy with built-in USB...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4062)
[Related Guides to the Product](https://learn.adafruit.com/products/4062/guides)
![Angled shot of a Adafruit Feather nRF52840 Express. ](https://cdn-shop.adafruit.com/640x480/4062-02.jpg)

### Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards

[Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards](https://www.adafruit.com/product/2922)
A Feather board without ambition is a Feather board without FeatherWings! This is the **Adalogger FeatherWing** : it adds both a battery-backed Real Time Clock and micro SD card storage to any Feather main board. Using our [Feather...](https://www.adafruit.com/products/2830)

In Stock
[Buy Now](https://www.adafruit.com/product/2922)
[Related Guides to the Product](https://learn.adafruit.com/products/2922/guides)
![Adalogger FeatherWing with Real time clock and SD card slot.](https://cdn-shop.adafruit.com/640x480/2922-11.jpg)

### CR1220 12mm Diameter - 3V Lithium Coin Cell Battery

[CR1220 12mm Diameter - 3V Lithium Coin Cell Battery](https://www.adafruit.com/product/380)
These are the highest quality & capacity batteries, the same as shipped with the iCufflinks,&nbsp;iNecklace, Datalogging and GPS Shields, GPS HAT, etc. One battery per order (you'll want one battery per cufflink or pendant.)  
  
Brand may vary but all battery brands are verified...

In Stock
[Buy Now](https://www.adafruit.com/product/380)
[Related Guides to the Product](https://learn.adafruit.com/products/380/guides)
![Angled shot of CR1220 12mm Diameter - 3V Lithium Coin Cell Battery - CR1220.](https://cdn-shop.adafruit.com/640x480/380-01.jpg)

### FeatherWing Doubler - Prototyping Add-on For All Feather Boards

[FeatherWing Doubler - Prototyping Add-on For All Feather Boards](https://www.adafruit.com/product/2890)
This is the **FeatherWing Doubler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are two! The magic of the Doubler comes when stacking a Feather and another...

In Stock
[Buy Now](https://www.adafruit.com/product/2890)
[Related Guides to the Product](https://learn.adafruit.com/products/2890/guides)
![Double prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/2890-01.jpg)

### USB A/Micro Cable - 2m

[USB A/Micro Cable - 2m](https://www.adafruit.com/product/2185)
This is your standard USB A-Plug&nbsp;to Micro-USB cable. It's 2 meters long so you'll have plenty of cord to work with for those longer extensions.

Out of Stock
[Buy Now](https://www.adafruit.com/product/2185)
[Related Guides to the Product](https://learn.adafruit.com/products/2185/guides)
![USB Cable with Type A and Micro B ends](https://cdn-shop.adafruit.com/640x480/2185-00.jpg)

### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
![Slim Lithium Ion Polymer Battery 3.7v 400mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/3898-05.jpg)

# Pulse Oximeter Wireless Data Logger

## CircuitPython for Feather nRF52840

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

The following instructions will show you how to install CircuitPython. If you've already installed CircuitPython but are looking to update it or reinstall it, the same steps work for that as well!

## Set up CircuitPython Quick Start!

Follow this quick step-by-step for super-fast Python power :)

[Download the latest version of CircuitPython for this board via CircuitPython.org](https://circuitpython.org/board/feather_nrf52840_express/)
 **Click the link above to download the latest UF2 file.**

&nbsp;

Download and save it to your desktop (or wherever is handy).

![circuitpython_nRF52840_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/070/318/medium640/circuitpython_nRF52840_UF2.png?1548963877)

Plug your Feather nRF52840 into your computer using a known-good USB cable.

**A lot of people end up using charge-only USB cables and it is very frustrating! So make sure you have a USB cable you know is good for data sync.**

Double-click the **Reset** button next to the USB connector on your board, and you will see the NeoPixel RGB LED turn green (identified by the arrow in the image). If it turns red, check the USB cable, try another USB port, etc. **Note:** The little red LED next to the USB connector will pulse red. That's ok!

If double-clicking doesn't work the first time, try again. Sometimes it can take a few tries to get the rhythm right!

![circuitpython_FeathernRF52840_Top_Product_Image.jpg](https://cdn-learn.adafruit.com/assets/assets/000/070/319/medium640/circuitpython_FeathernRF52840_Top_Product_Image.jpg?1548963972)

You will see a new disk drive appear called **FTHR840BOOT**.

&nbsp;

&nbsp;

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **FTHR840BOOT****.**

![circuitpython_FTHR840BOOT.png](https://cdn-learn.adafruit.com/assets/assets/000/070/320/medium640/circuitpython_FTHR840BOOT.png?1548964488)

![circuitpython_Drag_nRF52840_UF2.png](https://cdn-learn.adafruit.com/assets/assets/000/070/321/medium640/circuitpython_Drag_nRF52840_UF2.png?1548964497)

The LED will flash. Then, the&nbsp; **FTHR840BOOT** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

&nbsp;

That's it, you're done! :)

![circuitpython_nRF52840_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/070/322/medium640/circuitpython_nRF52840_CIRCUITPY.png?1548964511)

# Pulse Oximeter Wireless Data Logger

## Assemble the Adalogger and Feather Doubler

![](https://cdn-learn.adafruit.com/assets/assets/000/090/569/medium800/biometric_IMG_1965.jpg?1587566438)

We'll use a FeatherWing Doubler to connect the Adalogger FeatherWing to the Feather nRF52840. This provides a nice, accessible layout.

The FeatherWing Doubler provides the same connections between the pins of the Adalogger and the Feather as if they were stacked in the more typical arrangement, so all data, power, and ground connections will work as normal.

You may, of course, choose a different arrangement, such as stacking the boards if you like.

## Header Pins

Solder male headers to the underside of both the Feather nRF52840 and the Adalogger FeatherWing.

[This guide has good tips](https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/assembly#soldering-in-plain-headers-3-7) on soldering in the headers.

You will also need to install the battery (with the + side up) into the Adalogger's battery holder -- this powers the real-time clock so it is accurate even when the Feather is powered down.

You can also insert the SD card at this point.

![biometric_feather_2922-02.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/561/medium640/biometric_feather_2922-02.jpg?1587565031)

![biometric_feather_3010-01.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/563/medium640/biometric_feather_3010-01.jpg?1587565233)

![biometric_IMG_1958.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/564/medium640/biometric_IMG_1958.jpg?1587566401)

![biometric_IMG_1959.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/565/medium640/biometric_IMG_1959.jpg?1587566408)

## Header Sockets

Solder female socket headers to the top side of the Feather Doubler.

![biometric_adafruit_products_Doubler_iso_demo_01_ORIG.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/562/medium640/biometric_adafruit_products_Doubler_iso_demo_01_ORIG.jpg?1587565200)

## Combine Boards

Now, you can insert the Adalogger and the Feather into the Doubler.

![biometric_IMG_1962.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/573/medium640/biometric_IMG_1962.jpg?1587567208)

![biometric_IMG_1963.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/574/medium640/biometric_IMG_1963.jpg?1587567221)

![biometric_IMG_1964.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/575/medium640/biometric_IMG_1964.jpg?1587567228)

![biometric_IMG_1965.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/576/medium640/biometric_IMG_1965.jpg?1587567235)

This is now ready for coding!

# Pulse Oximeter Wireless Data Logger

## Code the Pulse Oximeter Logger

Warning: 

[Follow these steps to create the /sd directory](https://learn.adafruit.com/adafruit-memento-camera-board/circuitpython-memento-starter-projects)
Once your Feather nRF52840 is set up with CircuitPython, you'll also need to add some libraries. [Follow this page](https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries) for information on how to download and add libraries to your Feather.

From the library bundle you downloaded in that guide page, transfer the following libraries onto the Feather's **/lib** directory:

- **adafruit\_ble**
- **adafruit\_ble\_berrymed\_pulse\_oximeter**
- **adafruit\_bus\_device**
- **adafruit\_register**
- **neopixel.mpy**
- **adafruit\_pcf8523.mpy**

![biometric_libraries.jpg](https://cdn-learn.adafruit.com/assets/assets/000/090/509/medium640/biometric_libraries.jpg?1587483786)

## Text Editor

Adafruit recommends using the Mu editor for using your CircuitPython code with the Feather boards. You can get more info in [this guide](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

Alternatively, you can use any text editor that saves files.

## Code.py

Copy the code below and paste it into Mu. Then, save it to your Feather as **code.py**.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Pulse_Oximeter_Logger/code.py

## How it Works

The code does the following things:

- Imports necessary libraries, including **adafruit\_ble\_berrymed\_pulse\_oximeter** library
- Sets up SD card interface to use as a file system
- Sets up the real-time clock (RTC) on the I2C bus for setting and then keeping track of the day, date, and time
- Scan for and connect to a Bluetooth LE peripheral advertising the BerryMed pulse oximeter service
- Receive pulse oximeter service messages and unpack their values into SpO2%, pulse rate, and pleth (pulse strength graph)
- When a valid pulse oximeter message is received, log the values along with the day, date, and time from the RTC onto the SD card in a file called `log.txt`
- Repeat this process after the specified `log_interval` (a couple of seconds for example)
- If/when the connection is dropped, go back to BLE search mode

Now, let's try it out!

# Pulse Oximeter Wireless Data Logger

## Log and Graph the Data

https://youtu.be/EidJ5WrnsKs

## Data Logging

When you're ready to log the data, here are the steps (as shown in the video above):

- While the Feather is unpowered, insert the SD card into the Adalogger card slot
- Power on the Feather using USB or battery power
- Place your finger in the pulse oximeter reader and power it on
- Wear the pulse oximeter for as long as you'd like to log the data
- Remove the pulse oximeter from your finger and allow it to power down
- Power down the Feather
- Remove the SD card

The data will have been written to the SD card in a file called **log.txt**. Let's look at how to graph that data.

# Graphing the Data
Using an SD card reader, and SD card adapter if necessary, plug your SD card into your computer. You'll have a file called **log.txt** appear on it. Copy that file to your computer.

The log file contents will look something like this:

`Tuesday 21/4/2020 18:15:34, 99, 74, 46.00`  
`Tuesday 21/4/2020 18:15:36, 99, 75, 67.00`  
`Tuesday 21/4/2020 18:15:38, 99, 75, 26.00`  
`Tuesday 21/4/2020 18:15:40, 99, 75, 91.00`  
`Tuesday 21/4/2020 18:15:43, 99, 75, 91.00`  
`Tuesday 21/4/2020 18:15:45, 97, 76, 71.00`  
`Tuesday 21/4/2020 18:15:47, 97, 76, 16.00`

This has the day/date/time stamp followed by the SpO2%, pulse, and pleth, all separated by commas.

Info: 

Next, open the file into a spreadsheet program of your choice. We've used Google Sheets. Open a new spreadsheet.

Click **File** and choose **Import**.

![biometric_DataLoggerFileMenuImport.png](https://cdn-learn.adafruit.com/assets/assets/000/090/583/medium640/biometric_DataLoggerFileMenuImport.png?1587577876)

At the top of the **Import file** window, click **Upload**. Then click " **Select a file from your computer**" and choose your **log.txt** file.

![biometric_DataLoggerImportFileUpload.png](https://cdn-learn.adafruit.com/assets/assets/000/090/584/medium640/biometric_DataLoggerImportFileUpload.png?1587577942)

No changes are needed in the **Import File** dialog box - the defaults work for our project.

Click **Import data**.

![biometric_DataLoggerImportFileDialogBox.png](https://cdn-learn.adafruit.com/assets/assets/000/090/585/medium640/biometric_DataLoggerImportFileDialogBox.png?1587578000)

Now we have our data! It's almost ready to graph.

You can see here that the automatic delimiter detection worked well -- it placed the time-date stamp in one column and each piece of data in its own column, all based on the commas found in the original **log.txt** file.

![biometric_datainsheet.png](https://cdn-learn.adafruit.com/assets/assets/000/090/586/medium640/biometric_datainsheet.png?1587579459)

You can now select the data you want to graph and click **Insert \> Chart** in the menus.

You can adjust the chart drawing style, labels, colors, and more to your satisfaction.

[Here's an intro guide](https://support.google.com/docs/answer/63824?co=GENIE.Platform%3DDesktop&hl=en) on using charts in Sheets.

There's also some [great info in this guide](https://learn.adafruit.com/data-logging-with-feather-and-circuitpython/graphing-your-data) to tuning your data logging graphs.

![biometric_data1.png](https://cdn-learn.adafruit.com/assets/assets/000/090/587/medium640/biometric_data1.png?1587580499)

![](https://cdn-learn.adafruit.com/assets/assets/000/090/588/medium800/biometric_data2.png?1587580588)

While your data should ideally be pretty consistent, you can try running around and doing jumping jacks to get some bigger changes in the data you log, just be safe!


## Featured Products

### Adafruit Feather nRF52840 Express

[Adafruit Feather nRF52840 Express](https://www.adafruit.com/product/4062)
The **Adafruit Feather nRF52840 Express** is the new Feather family member with Bluetooth® Low Energy and _native USB support_ featuring the nRF52840!&nbsp; It's our take on an 'all-in-one' Arduino-compatible + Bluetooth® Low Energy with built-in USB...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4062)
[Related Guides to the Product](https://learn.adafruit.com/products/4062/guides)
### Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards

[Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards](https://www.adafruit.com/product/2922)
A Feather board without ambition is a Feather board without FeatherWings! This is the **Adalogger FeatherWing** : it adds both a battery-backed Real Time Clock and micro SD card storage to any Feather main board. Using our [Feather...](https://www.adafruit.com/products/2830)

In Stock
[Buy Now](https://www.adafruit.com/product/2922)
[Related Guides to the Product](https://learn.adafruit.com/products/2922/guides)
### Finger Pulse Oximeter with Bluetooth LE

[Finger Pulse Oximeter with Bluetooth LE](https://www.adafruit.com/product/4582)
[Discontinued - **you can grab the&nbsp;** Finger Pulse Oximeter - BM1000 **instead!**](https://www.adafruit.com/product/4580)

This&nbsp; **Finger Pulse Oximeter with Bluetooth LE&nbsp;** is great&nbsp;for monitoring your blood oxygen levels and&nbsp;pulse...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/4582)
[Related Guides to the Product](https://learn.adafruit.com/products/4582/guides)
### SD/MicroSD Memory Card - 16GB Class 10 - Adapter Included

[SD/MicroSD Memory Card - 16GB Class 10 - Adapter Included](https://www.adafruit.com/product/2693)
Add speedy mega-storage in a jiffy using this 16 GB Class 10 micro-SD card. It comes with a SD adapter so you can use it with any of our shields or adapters! Preformatted to FAT so it works out of the box with our projects. Works great with any device in the Adafruit shop that uses micro-SD...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2693)
[Related Guides to the Product](https://learn.adafruit.com/products/2693/guides)
### FeatherWing Doubler - Prototyping Add-on For All Feather Boards

[FeatherWing Doubler - Prototyping Add-on For All Feather Boards](https://www.adafruit.com/product/2890)
This is the **FeatherWing Doubler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are two! The magic of the Doubler comes when stacking a Feather and another...

In Stock
[Buy Now](https://www.adafruit.com/product/2890)
[Related Guides to the Product](https://learn.adafruit.com/products/2890/guides)
### USB A/Micro Cable - 2m

[USB A/Micro Cable - 2m](https://www.adafruit.com/product/2185)
This is your standard USB A-Plug&nbsp;to Micro-USB cable. It's 2 meters long so you'll have plenty of cord to work with for those longer extensions.

Out of Stock
[Buy Now](https://www.adafruit.com/product/2185)
[Related Guides to the Product](https://learn.adafruit.com/products/2185/guides)
### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
### CR1220 12mm Diameter - 3V Lithium Coin Cell Battery

[CR1220 12mm Diameter - 3V Lithium Coin Cell Battery](https://www.adafruit.com/product/380)
These are the highest quality & capacity batteries, the same as shipped with the iCufflinks,&nbsp;iNecklace, Datalogging and GPS Shields, GPS HAT, etc. One battery per order (you'll want one battery per cufflink or pendant.)  
  
Brand may vary but all battery brands are verified...

In Stock
[Buy Now](https://www.adafruit.com/product/380)
[Related Guides to the Product](https://learn.adafruit.com/products/380/guides)

## Related Guides

- [Introducing the Adafruit nRF52840 Feather](https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather.md)
- [Adafruit CAN Bus FeatherWing](https://learn.adafruit.com/adafruit-can-bus-featherwing.md)
- [Bluetooth Controlled NeoPixel Lightbox](https://learn.adafruit.com/bluetooth-neopixel-lightbox.md)
- [MAC Address Finder](https://learn.adafruit.com/mac-address-finder.md)
- [Nunchuck Controlled Laser Cat Toy](https://learn.adafruit.com/nunchuck-controlled-laser-cat-toy.md)
- [RP2040 RunCPM Emulator with USB Keyboard & HDMI screen](https://learn.adafruit.com/rp2040-runcpm-emulator-with-usb-keyboard-hdmi-screen.md)
- [NES Emulator for RP2040 & RP2350 DVI Boards](https://learn.adafruit.com/nes-emulator-for-rp2040-dvi-boards.md)
- [CircusPython: Jump through Hoops with CircuitPython Bluetooth LE](https://learn.adafruit.com/circuspython-jump-through-hoops-with-bluetooth-le.md)
- [Quickstart - Raspberry Pi RP2040 with BLE and CircuitPython](https://learn.adafruit.com/quickstart-raspberry-pi-rp2040-with-ble-and-circuitpython.md)
- [A CircuitPython BLE Remote Control On/Off Switch](https://learn.adafruit.com/circuitpython-ble-remote-control-on-off.md)
- [BLE Sniffer with nRF52840](https://learn.adafruit.com/ble-sniffer-with-nrf52840.md)
- [Easy Alexa (Echo) Control of your ESP8266 Huzzah](https://learn.adafruit.com/easy-alexa-or-echo-control-of-your-esp8266-huzzah.md)
- [Doomscroll and Chill - A Wireless BLE Scroll Wheel Remote](https://learn.adafruit.com/doomscroll-and-chill-wireless-ble-scroll-wheel-rotary-encoder-remote.md)
- [Motorized POV LED Display](https://learn.adafruit.com/motorized-pov-led-display.md)
- [CircuitPython 101: State Machines, Two Ways](https://learn.adafruit.com/circuitpython-101-state-machines.md)
- [Bluefruit Ouija Board](https://learn.adafruit.com/bluefruit-ouija-board.md)
