I have attached a pulse oximeter (Nonin XPOD) to a Raspberry Pi zero UART.
According to the Nonin manual, I should get 5 bytes/75 times per second.
The code I used and resulting data is shown below.
Notice how I get a variable number of characters per read (e.g. b'\x84' versus b'~')
What might be the reason for this varying size of characters? Perhaps the Raspberry Pi cannot read 5 bytes/75 times per second?
My code:
import serial
sensor = serial.Serial('/dev/ttyS0',timeout=1,baudrate=9600, parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS)
while True:
rcv = sensor.read()
print ("You read: ", rcv)
Results:
You read: b'\x84'
You read: b'\x98'
You read: b'\xa1'
You read: b'\xc6'
You read: b'\x7f'
You read: b'~'
You read: b'\x98'
You read: b'\xa1'
You read: b'\xf7'
You read: b'\x7f'
You read: b'\xaf'
You read: b'\x98'
You read: b'\x9d'
You read: b'\xf2'
You read: b'\x00'
You read: b"'"
You read: b'\x98'