PI and Arduino usb/serial trouble - Raspberry Pi Forums
hi all,
facing trouble when trying make pi2 communicate arduino uno thru serial ttyacm0 automatically created when plugged usb pi (in fact plugged thru powered usb hub).
test basic : pi sends request arduino thru serial port, arduino gets request , sends answer, pi has display answer.
to wrote following .py file i'm launching "python myfile.py" arduino code: easy, no ?
problem : got nothing when launching "python myfile.py"
but, if type these same commands directly in python shell (2.7.3), working !
better : if after launch again "python myfile.py", working !!? shell opening or initializing else serial ??
wonder if problem on pi or arduino's side ?
tryed arduino (nano) : same
tryed arduino connected directly pi without usb hub : same
have got idea ???
thanks
facing trouble when trying make pi2 communicate arduino uno thru serial ttyacm0 automatically created when plugged usb pi (in fact plugged thru powered usb hub).
test basic : pi sends request arduino thru serial port, arduino gets request , sends answer, pi has display answer.
to wrote following .py file i'm launching "python myfile.py"
code: select all
import serial, time ser=serial.serial('/dev/ttyacm0',9600,timeout=1) ser.write('?') time.sleep(0.5) print ser.readline() ser.close()
code: select all
void setup() { serial.begin(9600); } void loop() { if (serial.available()) { if (serial.read() == '?') serial.print('hello'); } }
problem : got nothing when launching "python myfile.py"
but, if type these same commands directly in python shell (2.7.3), working !
better : if after launch again "python myfile.py", working !!? shell opening or initializing else serial ??
wonder if problem on pi or arduino's side ?
tryed arduino (nano) : same
tryed arduino connected directly pi without usb hub : same
have got idea ???
thanks
i think python serial.readline(...) waits see newline character in serial data should using serial.println(...) in arduino code. it's not clear how give symptoms you've described there may issue.
debugging technique, might try toggling gpio connected led when arduino receives character. tell whether or not pi arduino path working.
debugging technique, might try toggling gpio connected led when arduino receives character. tell whether or not pi arduino path working.
raspberrypi
Comments
Post a Comment