Read from serial port

suggest change

Initialize serial device

import serial
#Serial takes two parameters: serial device and baudrate
ser = serial.Serial('/dev/ttyUSB0', 9600)

to read a single byte from the serial device

data = ser.read()

to read a given number of bytes from the serial device

data = ser.read(size=5)

to read one line from the serial device.

data = ser.readline()

to read the data from the serial device while something is being written over it.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents