Python, Raspberry, and Arduino Communication

Posted by user2924156 on Stack Overflow See other posts from Stack Overflow or by user2924156
Published on 2013-11-10T21:49:32Z Indexed on 2013/11/10 21:53 UTC
Read the original article Hit count: 220

Filed under:
|

I have been working with my Raspberry, Arduino and applying some Python to make them communicate. I also installed pyserial. If I use IDLE and try the following I get my expected results.

  >>> import serial
  >>> ser = serial.Serial('/dev/ttyUSB0',115200)
  >>> ser.write('x:1\n')
  8
  >>> ser.readline()
  'X:1\r\n'

If I write a python scrip and run it I don't get anything back. Here is my python script.

  import serial
  ser = serial.Serial('/dev/ttyUSB0', 115200)
  ser.write('!x:1\n')
  ser.readline()

I am new to Python so looking for some help to understand they this works in IDLE but not as a python script run from terminal.

Thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about arduino