Reading thermocouple data with pyserial/Configure DAQ device

Viewed 30

I am new to Python in general and data acquisition/instrumentation. I am trying to get a temperature reading from a thermocouple connected to a Measurement Computing USB-204 DAQ. I want to output the data from the serial port to a csv file using pyserial. I searched for guides on the topic, but I have not found anything directly explaining how to do this. Firstly, I was wondering if there are any resources that would be useful for this goal specifically. Otherwise, This guide from MakerPortal essentially describes what I want to do, and the code they use is below.

import serial
ser = serial.Serial('/dev/ttyACM0')
ser.flushInput()

while True:
    try:
        ser_bytes = ser.readline()
        decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))
        print(decoded_bytes)
    except:
        print("Keyboard Interrupt")
        break

I want to do this, but using my USB port. Do I just need to use the name of my port in place, or are there additional configuration steps I'm missing? I understand this question is kind of all over the place, but a step in the right direction would be appreciated.

0 Answers
Related