Go Down

Topic: Reading arduino serial connection in python: Unknown characters (Read 75 times) previous topic - next topic

sashko_s

I'm using Python to talk to my Arduino using the pyserial module.

Code: [Select]
import serial
ser=serial.Serial('/dev/ttyUSB0', 115200)


I get the following results:

Code: [Select]
ser.read(20)
'y8\t0.16\t0.16\t-0.65\r\n'


That's what I need.

But if I close port and open it again, I get the following:

Code: [Select]
ser.close()
ser=serial.Serial('/dev/ttyUSB0', 115200)
ser.read(20)
'4\xfa\x9a\xf9t\xff\x1a\xffA\xff<\xf2x\xf68\xf6A\xffA\xff'


What are these symbols? How do I get the correct characters?

My OS is Ubuntu

PaulS

Quote
How do I get the correct characters?
Send the correct ones.

Opening the serial port resets the Arduino. Reading serial data while it is resetting is silly.


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy