Sending commands to temperature monitor; b'\xab', why?

Working on send commands to a temperature monitor. Fiddled a bit and got the following. Not sure what it means or how to convert to usable data (if there is any). Any ideas?

import serial
 
ser.close()
ser = serial.Serial(port='COM5',\
                   baudrate=9600,\
                   parity=serial.PARITY_NONE,\
                   stopbits=serial.STOPBITS_ONE,\
                   bytesize=serial.EIGHTBITS,\
                    timeout=2)
 
print("connected to: " + ser.portstr)
#ser.close()
count=1

while True:
#line = ser.readline()
#print(str(count) + str(': ') + str(line))
#count = count+1
    cmd = input("Enter command or 'exit':")
        # for Python 3
    if cmd == 'exit':
        ser.close()
        quit()
    else:
        ser.write((cmd+'\r\n').encode('utf-8'))
        out = ser.read()#.decode('utf-8')
        print(out)#.decode('utf-8'))
ser.close()

Output is

connected to: COM5
Enter command or ‘exit’: KRDG? 1
b’\xab’

Wondering what b’\xab’ could mean

Please replace your picture of text with preformated text that is easier for us to read and quote from to help you.

Use the </> button to quote text.

```
Like this
```

You need to consult the documentation of the temperature monitor.

Just a note that Serial.read has a default read size of 1.

Maybe try adding a timeout to the Serial setup and doing a longer
read. You might get a more intelligible result. BTW do you know about
what temperature you expect to get?

There’s also Serial.read_until which could be useful if you’re
expecting a “line” of data as a response.

But Matthew’s point is important: what does the documentation say you
should get?

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like

What is the hardware that you are connecting to?
Do you have a link to its documentation?

Thanks Cameron, I’ll give it a shot. It’s a temperature monitor and should be reading out around room temp, currently hovering at ~292.45K

1 Like

I’m connecting to a Lakeshore 218e Temperature Monitor, which has only the RS232 and not the IEEE-488 interface.

User Manual:
218_v2.0.doc (lakeshore.com)
Remote Operation is section 6 (p 65).

Specs:
Model 218 Temperature Monitor (lakeshore.com)

From the manual:

Your instrument uses 7 data bits and one parity bit (odd). You should configure your serial interface like so:

ser = serial.Serial(port='COM5',\
                   baudrate=9600,\
                   parity=serial.PARITY_ODD,\
                   stopbits=serial.STOPBITS_ONE,\
                   bytesize=serial.SEVENBITS,\
                    timeout=2)

Edit: Assuming the final bit is a parity bit, b'\xab' is actually b'\+'. If you read more bytes, numbers are likely to follow.

1 Like

Alexander, my man!! I really should have caught the parity and byte params. Matched them up in the device manager, too. Now to get it to return a string, rather than single characters. Thanks bud!!

Bingo! Thanks Cameron!

1 Like