Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: Can't use pyserial to read serial data from Arduino on: April 12, 2012, 06:04:36 am
if you continue having issues you might consider using pytty. i helped write it and since then i've been using it for about 2 years in the HacDC occupancy sensor with no problems (due to pytty atleast smiley-razz). it's much more straight forward to use and is pure python so it's a bit less hassle if you don't need to do more than read and write to the device.

Thanks! I'll be trying this as well, I do like pure python.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: Can't use pyserial to read serial data from Arduino on: April 12, 2012, 06:04:12 am

If you don't want to send a newline from your sketch, try this python code instead:
Code:

while 1:
        byte = ser.read(size=1)
        print byte,

WOW! this worked! thank you!
3  Using Arduino / Interfacing w/ Software on the Computer / Re: Can't use pyserial to read serial data from Arduino on: April 10, 2012, 07:26:33 am
Wow, thanks! Never thought about the new line thing.  I'll try it when I get home today.

Also, I had tried my script with a "print set.readline()" to no avail before.  I'll give this a shot though.
4  Using Arduino / Interfacing w/ Software on the Computer / Re: Can't use pyserial to read serial data from Arduino on: April 10, 2012, 06:49:12 am
I should also say that my Arduino's TX LED is blinking appropriately.
5  Using Arduino / Interfacing w/ Software on the Computer / Re: Can't use pyserial to read serial data from Arduino on: April 10, 2012, 06:47:54 am
Quote
My Arduino is running this code:
Code:
Serial.write("test");
Why? Are you sending binary data somewhere? No, you are not. You should be using Serial.print() to send ASCII data.

Opening the serial port, by pyserial, resets the Arduino. It does not look like your pyserial code does any kind of looping. The code to read the Arduino output appears to expect data once, immediately. Since there is no data available immediately, the pyserial code gives up and moves on.

Okay, I've changed Arduino to:

Code:
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.print("test");
delay(500);
}

And Python to:

Code:
import serial

serialport = "/dev/tty.usbserial-A6008hrf"
ser = serial.Serial(serialport, 9600)
while(1):
    ser.readline()

Still no luck. 
6  Using Arduino / Interfacing w/ Software on the Computer / Can't use pyserial to read serial data from Arduino on: April 10, 2012, 06:37:42 am
Hello,

I'm having some trouble interfacing Python with my Arduino.

My Arduino is running this code:

Code:
void setup() {
Serial.begin(9600);
}

void loop() {
Serial.write("test");
delay(500);
}

And Python is running this code:

Code:
import serial

serialport = "/dev/tty.usbserial-A6008hrf"
ser = serial.Serial(serialport, 9600)
ser.readline()

This doesn't do anything, it just sits there not receiving anything.  I'm able to use Arduino's serial monitor to view the output though, and I'm able to send serial data to the Arduino using pyserial and the same serial port.  It's very odd...

My computer:
2011 Macbook Pro running 10.7.3 and Apple-supplied Python 2.7 and latest PySerial

Any suggestions?
Pages: [1]