Sylvia M
Sylvia M

Reputation: 1

Nonin Oximeter 3231

I am trying to read in data from the Nonin Pulse Oximeter model 3231 using the USB connection. The data is coming out in this from (b'\x14\x00\x02B\x02\xc2b\x00N\x03\x02\n') when I am reading it in using the pyserial documentation. I am not sure how to turn this into the SpO2 and heart rate data that I am looking for.

Does anyone have any experience with this?

import serial import binascii s = serial.Serial("/dev/cu.usbmodem5055968061",9600, bytesize=serial.NINEBITS)

try: while True: data = s.readline()

    print(s.is_open)
   # decode_hex = data.decode("ascii")
    #decoded_bytes = binascii.unhexlify(data)
    #decoded_string = decoded_bytes.decode('ascii')
    # Process the received data
    print("Received:", data)
    #print("Hex:",decode_hex)
    #print("Edit:", decoded_bytes) # So we are receiving, but not receiving data.

except KeyboardInterrupt: # Close the serial port when interrupted s.close()

Upvotes: 0

Views: 101

Answers (1)

James McIntyre
James McIntyre

Reputation: 1

It is raw binary data and not encoded. From this post I found that you can convert each line read to a list of bytes.

Reading and printing from the port looks something like this:

import serial
ser = serial.Serial("COM8")

while True:
     cc = list(ser.readline())
     print(cc)

The output looks like:

[20, 0, 0, 247, 0, 109, 98, 0, 52, 3, 2, 10]

[20, 0, 0, 241, 0, 110, 98, 0, 52, 3, 2, 10]

[20, 0, 0, 241, 0, 111, 98, 0, 52, 3, 2, 10]

From the device screen, I have 98% SpO2 and and HR of 52, which would suggest that cc[6] is HR and cc[8] is SpO2. there is a sample count (in seconds?) at cc[5] which is 109, 110, 111 in this example.

Upvotes: 0

Related Questions