Programming of NONIN Pulse Oximeter (OEM III)

Hey peeps, i ordered a NONIN Pulse Oximeter from overseas like 2 weeks back.

Attached below is the module specs & technical information: http://www.nonin.com/documents/OEM%20III%20Module%20Specifications.pdf

I do not know how to write the program for this pulse oximeter on the Ardunio IDE. Can someone kindly help? I will really appreciate your help alot!! :)

moomoo: I do not know how to write the program for this pulse oximeter on the Ardunio IDE.

From this, I'm not sure what you want. I didn't see any reference to the pulse ox being programmable, even if it was it'd be unlikely you could program it with the arduino ide. Do you want to write program for an ardunio that can read the data sent by the pulse ox? If so what is it that you want to do with the data? More information and we'd be able to help you better.

I'm guessing you want to read the data with an ardiuno, this is fairly straight forward, look at http://arduino.cc/en/Reference/Serial, or if you don't want to tie up the hardware serial port http://arduino.cc/en/Reference/SoftwareSerial. I'd set the device up to use serial data format #1 it would be the easiest to process, unless you need the extra information from 2 or 7.

The first thing you need to do is to decide what size resistor you want to use between pin 9 and pin 15 on the sensor. This will define the format of the serial data that the device outputs. See the top of page 5.

The serial format one appears to be the easiest to read.

The three bytes that are sent once per second can be read using NewSoftSerial with the device's TX and RX pins connected to any two pins on the Arduino.

A little bit of bit manipulation will give you the heart rate and oxygen level.

Ok guys...i will go ahead with Serial Data Format #1. I will choose a resistor between 0 - 626 ohms and connect them between pin 9 and 15. :)

Anyway, page 10 of the datasheet shows the different pin connections. I wonder which pins should i be using to connect to the Arduino? I am using an Arduino Pro Mini 5V/16MHz. I want to show the data (SPO2 and pulse rate) from the pulse oximeter onto the serial monitor before transmitting the data wirelessly using the Xbee.

Page 10 tells you that the serial output occurs on pin 11, so that needs to be connected to a digital pin on the Arduino, and identified as the RX pin to NewSoftSerial.

Pin 16 is the Vcc in pin, so that needs to be connected to the Ardiuno's 3.3V pin. Pin 15 is the Gnd pin, so that needs to be connected to the Arduino's Gnd pin.

Pin 13 could be connected to the Arduino, if you need to reset the sensor.

Pin 10 doesn't do anything yet, but it could be connected to a digital pin on the Arduino, as the TX pin for NewSoftSerial.

These are the only connections that need to be made between the sensor board and the Arduino.

Thank you PaulS for your help. So two digital pins on the Arduino Pro Mini for the tx and rx for newsoftserial? How do i write my Arduino program to display the readings (pulse rate & SPo2) on the serial monitor? :)

byte vals[3];

NewSoftSerial nss(??, ??); // Put your TX and RX pins here, in the correct order

void loop()
{
   if(nss.available() >= 3)
   {
      vals[0] = nss.read();
      vals[1] = nss.read();
      vals[2] = nss.read();

      // Then, use bitRead and bitWrite to extract appropriate
      // bits from val and put them into integers, to get the 
      // heart rate and oxygen levels.
   }
}

PaulS, can i ask how will my serial monitor looked like? :) I will program my Pro Mini using the 5V FTDI Breakout Board.

Sorry, i did not phrase my question properly. I want to know what will be shown on my serial monitor after i upload the sketch onto the Pro Mini and open serial monitor. Is it like 97%78 97%78 ?

The values of the SPO2 and pulse rate respectively.

With the code I posted, nothing will show up in the serial monitor. If you replace the comments in that code with some real code, then stuff might show up in the serial monitor. You will be defining what should show up there, so you should know what will appear there.

I have wrote up a program, not sure whether is it right, please guide me along (:

byte vals[3];

NewSoftSerial nss(5, 8); // Put your TX and RX pins here, in the correct order

void loop() { if(nss.available() >= 3) { vals[0] = nss.read(); vals[1] = nss.read(); vals[2] = nss.read(); bitWrite(0,01111111,0); //Status bitWrite(1,01111110,1); //Heart Rate bitWrite(2,01111110,1); //Oxygen level

bitRead(0,01111111); //read bit 0 bitRead(1,01111110); //read bit 1 bitRead(2,01111110); //read bit 1 } }

I have wrote up a program, not sure whether is it right, please guide me along

It's not.

You should be reading several bits from vals[0], vals[1], and vals[2], and writing bits into two ints, heartBeat and oxygenLevel.

Which bits do you need to read for the heart rate? Look at the user's manual. Which bits do you need to write for the heart rate? Look at the user's manual. Which bits do you need to read for the oxygen level? Look at the user's manual. Which bits do you need to write for the oxygen level? Look at the user's manual.

Sorry PaulS, I dont quite understand what you meant. From what I see from the datasheet, HeartRate is from bit0 to bit8 and for oxygen level is bit0 to bit6. They are set to active high. I still dont quite understand how does the bit works. What i do know from the datasheet is that 3 bytes of data are transmitted 1 once per second. Byte 1-Status Byte 2- Heart rate Byte 3- Oxygen level

Is the program written like this?

bitRead(1,1101111111); //read HeartRate bitRead(2,01111111); //read oxygenLevel bitWrite(1,1101111111,1); //write HeartRate bitWrite(2,01111111,1); //write oxygenLevel

1101111111 = 1; 01111111= 2;

No. Look at the user's guide. It tells you which bits in the 3 bytes sent mean what.

then, you use something like: int bit = bitRead(vals[0], 7); // read one of the bits bitWrite(heartRate, 0, bit); // set one of the bits in heart rate

This needs to be done to read several bits from different bytes, setting different bits in heartRate, to get all the bits set.

A similar process is used to get the oxygen level.

So do i have to write out for every single bit to read and write for the heartRate? The program will be written something like this: int bit = bitRead(vals[0], 7); // read one of the bits int bit = bitRead(vals[0], 6); // read one of the bits int bit = bitRead(vals[0], 5); // read one of the bits int bit = bitRead(vals[0], 4); // read one of the bits int bit = bitRead(vals[0], 3); // read one of the bits int bit = bitRead(vals[0], 2); // read one of the bits int bit = bitRead(vals[0], 1); // read one of the bits int bit = bitRead(vals[0], 0); // read one of the bits

bitWrite(heartRate, 0, 7); // set one of the bits in heart rate bitWrite(heartRate, 1, 6); bitWrite(heartRate, 1, 5); bitWrite(heartRate, 1, 4); bitWrite(heartRate, 1, 3); bitWrite(heartRate, 1, 2); bitWrite(heartRate, 1, 1); bitWrite(heartRate, 1, 0);

Please guide me along (: , i am still lost in programming this nonin oem lll module

So do i have to write out for every single bit to read and write for the heartRate?

Yes. Create a function for that.

The program will be written something like this: int bit = bitRead(vals[0], 7); // read one of the bits int bit = bitRead(vals[0], 6); // read one of the bits int bit = bitRead(vals[0], 5); // read one of the bits int bit = bitRead(vals[0], 4); // read one of the bits int bit = bitRead(vals[0], 3); // read one of the bits int bit = bitRead(vals[0], 2); // read one of the bits int bit = bitRead(vals[0], 1); // read one of the bits int bit = bitRead(vals[0], 0); // read one of the bits

Not all the bits for heart rate are in vals[0], and you can't store all the bits in a new variable of the same name as an earlier variable, but, yes, that's the general idea.

So if I were to add both variables such as the heartRate and oxygenLevel, will be the program look like this? According to the datasheet, the heartRate and the oxygenLevel bit 7 will be set to 0, whereas from bit 0 to bit 6 will be set to 1. Thanks for the guidance (: I have a doubt that I wish to clarify. Since we are transmitting the values, using NewSoftSerial, why do we still need to specify the RX pin?

byte vals[8]; //heartRate byte nums[8]; //oxygenLevel

NewSoftSerial nss(5, 8); // Put your TX and RX pins here, in the correct order, nss represent heartRate void loop() { if(nss.available() >= 8) { vals[0] = nss.read(); vals[1] = nss.read(); vals[2] = nss.read(); vals[3] = nss.read(); vals[4] = nss.read(); vals[5] = nss.read(); vals[6] = nss.read(); vals[7] = nss.read();

int bit = bitRead(vals[0], 7); // read one of the bits int bit = bitRead(vals[1], 6); // read one of the bits int bit = bitRead(vals[2], 5); // read one of the bits int bit = bitRead(vals[3], 4); // read one of the bits int bit = bitRead(vals[4], 3); // read one of the bits int bit = bitRead(vals[5], 2); // read one of the bits int bit = bitRead(vals[6], 1); // read one of the bits int bit = bitRead(vals[7], 0); // read one of the bits

bitWrite(heartRate, 0, 7); // set one of the bits in heart rate bitWrite(heartRate, 1, 6); bitWrite(heartRate, 1, 5); bitWrite(heartRate, 1, 4); bitWrite(heartRate, 1, 3); bitWrite(heartRate, 1, 2); bitWrite(heartRate, 1, 1); bitWrite(heartRate, 1, 0);

nums[0] = nss.read(); nums[1] = nss.read(); nums[2] = nss.read(); nums[3] = nss.read(); nums[4] = nss.read(); nums[5] = nss.read(); nums[6] = nss.read(); nums[7] = nss.read();

int bit = bitRead(nums[0], 7); // read one of the bits int bit = bitRead(nums[1], 6); // read one of the bits int bit = bitRead(nums[2], 5); // read one of the bits int bit = bitRead(nums[3], 4); // read one of the bits int bit = bitRead(nums[4], 3); // read one of the bits int bit = bitRead(nums[5], 2); // read one of the bits int bit = bitRead(nums[6], 1); // read one of the bits int bit = bitRead(nums[7], 0); // read one of the bits

bitWrite(oxygenLevel, 0, 7); // set one of the bits in oxygenLevel bitWrite(oxygenLevel, 1, 6); bitWrite(oxygenLevel, 1, 5); bitWrite(oxygenLevel, 1, 4); bitWrite(oxygenLevel, 1, 3); bitWrite(oxygenLevel, 1, 2); bitWrite(oxygenLevel, 1, 1); bitWrite(oxygenLevel, 1, 0); } }

So if I were to add both variables such as the heartRate and oxygenLevel, will be the program look like this?

If you tried compiling that, you'd know that the answer was no.

According to the datasheet, the heartRate and the oxygenLevel bit 7 will be set to 0, whereas from bit 0 to bit 6 will be set to 1.

Not sure what you are reading. On page 5, under serial data format #1, it says that the device will send 3 bytes of serial data.

Bits 0 and 1 of the first byte, and bits 0 to 6 of the second byte make up the 8 bits of the heart rate.

int vals[3];
int heartRate, oxyLevel;

vals[0] = nss.Read();
vals[1] = nss.Read();
vals[2] = nss.Read();

int bit;
heartRate = 0; // Sets all 8 bits to 0
bitWrite(heartRate, 0, bitRead(vals[1], 0)); // Set bit 0
bitWrite(heartRate, 1, bitRead(vals[1], 1)); // Set bit 1
bitWrite(heartRate, 2, bitRead(vals[1], 2)); // Set bit 2
bitWrite(heartRate, 3, bitRead(vals[1], 3)); // Set bit 3
bitWrite(heartRate, 4, bitRead(vals[1], 4)); // Set bit 4
bitWrite(heartRate, 5, bitRead(vals[1], 5)); // Set bit 5
bitWrite(heartRate, 6, bitRead(vals[0], 0)); // Set bit 6
bitWrite(heartRate, 7, bitRead(vals[0], 1)); // Set bit 7

Notice that the last 2 bits are read from a different byte.

Now, you go read the table, and figure out how to get/set the oxygen level. Here's a hint. It's a lot simpler, since all the bits are in one byte, and in order.

If you get stuck, it looks like this:

oxyLevel = vals[2];

Thanks for the help and advice, I have write up the program, could you help me check whether is it correct? (: PaulS, according to the datasheet, it says that the heartRate has 9 bits(0-8bits), how come the program that you write up has only 8 bits?

bytes vals[3];

NewSoftSerial nss(5, 8); // Put your TX and RX pins here, in the correct order

int vals[3]; int heartRate, oxyLevel;

vals[0] = nss.Read(); //represent byte 1 vals[1] = nss.Read(); //represent byte 2 vals[2] = nss.Read(); //represent byte 3

int bit; heartRate = 0; // Sets all 8 bits to 0 oxygenLevel = 0; // Sets all 8 bits to 0 void loop() { if(nss.available() >= 3) {

int bit = bitRead(vals[1], 0); // read bit 0 int bit = bitRead(vals[1], 1); // read bit 1 int bit = bitRead(vals[1], 2); // read bit 2 int bit = bitRead(vals[1], 3); // read bit 3 int bit = bitRead(vals[1], 4); // read bit 4 int bit = bitRead(vals[1], 5); // read bit 5 int bit = bitRead(vals[0], 0); // read bit 6 int bit = bitRead(vals[0], 1); // read bit 7

bitWrite(heartRate, 0, bitRead(vals[1], 0)); // Set bit 0 bitWrite(heartRate, 1, bitRead(vals[1], 1)); // Set bit 1 bitWrite(heartRate, 2, bitRead(vals[1], 2)); // Set bit 2 bitWrite(heartRate, 3, bitRead(vals[1], 3)); // Set bit 3 bitWrite(heartRate, 4, bitRead(vals[1], 4)); // Set bit 4 bitWrite(heartRate, 5, bitRead(vals[1], 5)); // Set bit 5 bitWrite(heartRate, 6, bitRead(vals[0], 0)); // Set bit 6 bitWrite(heartRate, 7, bitRead(vals[0], 1)); // Set bit 7

int bit = bitRead(vals[2], 0); // read bit 0 int bit = bitRead(vals[2], 1); // read bit 1 int bit = bitRead(vals[2], 2); // read bit 2 int bit = bitRead(vals[2], 3); // read bit 3 int bit = bitRead(vals[2], 4); // read bit 4 int bit = bitRead(vals[2], 5); // read bit 5 int bit = bitRead(vals[2], 6); // read bit 6 int bit = bitRead(vals[2], 7); // read bit 7 bitWrite(oxygenLevel, 0, bitRead(vals[2], 0); // Set bit 0 bitWrite(oxygenLevel, 1, bitRead(vals[2], 1); // Set bit 1 bitWrite(oxygenLevel, 2, bitRead(vals[2], 2); // Set bit 2 bitWrite(oxygenLevel, 3, bitRead(vals[2], 3); // Set bit 3 bitWrite(oxygenLevel, 4, bitRead(vals[2], 4); // Set bit 4 bitWrite(oxygenLevel, 5, bitRead(vals[2], 5); // Set bit 5 bitWrite(oxygenLevel, 6, bitRead(vals[2], 6); // Set bit 6 bitWrite(oxygenLevel, 7, bitRead(vals[2], 7); // Set bit 7 } }