Pages: [1]   Go Down
Author Topic: python serial communication with arduino in windows [Solved]  (Read 1051 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys, I am totally new to arduino and looking to start by building a LED display with arduino control.  Please note, I have no idea about arduino, but before I begin with arduino, i want to see if I can communicate with my serial display (http://www.ebay.com/itm/RED-LED-Programmable-Scrolling-Name-Badge-Tag-Message-/250873616240?pt=LH_DefaultDomain_0&hash=item3a693b9770

it comes with a pc program that allows me to program the display text through a USB cable which I think is using a usb to serial driver to comm3 port.  I am using a serial port sniffer to capture the commands to the display hoping to emulate it later using an arduino board. But I am having a hard time understanding what is captured and how I can emulate it later on arduino. The display is able to display 6 different messages. In this example, I am using my software to programming the display to show "Hello" as message 1. Using serial monitor, I am able to capture the ASCII data output as
Code:
<20111217002409.996 SYS>
COM is open
<20111217002409.996 SYS>
Set timeouts: ReadInterval=-1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0
<20111217002409.996 SYS>
In/out queue size 4096/0
<20111217002409.996 SYS>
Baud rate 38400
<20111217002409.996 SYS>
RTS on
<20111217002409.996 SYS>
DTR on
<20111217002409.996 SYS>
Data bits=8, Stop bits=1, Parity=None
<20111217002409.996 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20111217002409.996 SYS>
Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL, XOFF_CONTINUE), XonLimit=1024, XoffLimit=1024
<20111217002409.996 SYS>
Baud rate 38400
<20111217002409.996 SYS>
RTS on
<20111217002409.996 SYS>
DTR on
<20111217002409.996 SYS>
Data bits=8, Stop bits=1, Parity=None
<20111217002409.996 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20111217002409.996 SYS>
Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL, XOFF_CONTINUE), XonLimit=1024, XoffLimit=1024
<20111217002409.996 SYS>
DTR on
<20111217002409.996 SYS>
RTS on
<20111217002409.996 SYS>
Baud rate 38400
<20111217002409.996 SYS>
RTS on
<20111217002409.996 SYS>
DTR on
<20111217002409.996 SYS>
Data bits=8, Stop bits=1, Parity=None
<20111217002409.996 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x11, Xoff=0x13
<20111217002409.996 SYS>
Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(TRANSMIT_TOGGLE, RTS_CONTROL, XOFF_CONTINUE), XonLimit=1024, XoffLimit=1024
<20111217002409.997 TX>
<NUL><STX>1<ACK><NUL>51B<ENQ>Hello<NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>Ø<STX>1<ACK>@<NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>w<STX>1<ACK>€<NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>·<STX>1<ACK>À<NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>÷<STX>3<SOH>
<20111217002410.657 SYS>
COM is closed

My question is
  • Am I capturing the required data to figure out what is necessary to work with Arduino?
  • Should I be interested in ASCII or HEX?
  • Do I need to replicate/emulate all this in Arduino to send to the display?
  • What are the required components/boards/shields I would need to send command such as above to the display using Arduino?
  • Am I correct in assuming this is serial communication and should be able to emulate this using an arduino board?

I would appreciate any guidance in this to get this going, I know the information I have provided are very simplistic but I am totally new to this and would appreciate any help.
« Last Edit: December 29, 2011, 04:14:12 am by joefly » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46042
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect that you should forget connecting that device to an Arduino. That device is a USB slave. So is the Arduino. Two slaves can not talk to each other.

There is a USB Host shield available for the Arduino, but you then need to write the driver for the device.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I suspect that you should forget connecting that device to an Arduino. That device is a USB slave. So is the Arduino. Two slaves can not talk to each other.

They can if the master isn't looking! Sorry couldn't help myself, nothing funnier then making jokes about slavery.  smiley-sad
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I suspect that you should forget connecting that device to an Arduino. That device is a USB slave. So is the Arduino. Two slaves can not talk to each other.

They can if the master isn't looking! Sorry couldn't help myself, nothing funnier then making jokes about slavery.  smiley-sad


Hi Paul,  Thanks for your help and saving me a lot of trouble of tinkering with something that was not capable of doing what I wanted.  I finally bought a Arduino Uno and a 20x4 lcd display and just started getting myself familiar with it.  I was hoping if you can guide me in my project.  I am hoping to write a little program on my PC that uses google api (or other api's to grab info from the web) then parse the info from the api and send it to arduino to display it on LCD.  For example, I like to use google API to grab the latest stock price every 5 min and then send this info through the usb to the Arduino board to display.

Here are my questions:

1) I do not have any hardcore programming experience, what is the best environment to program on a PC that I can write a stand alone program and then spit it out over USB to arduino?
2) are there any existing projects that I can follow along and tweak without reinventing the wheel?


Any advice would be greatly appreciated again, Thanks
Happy holidays

update:  I have done some research on stock price APIs, one example is this  http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22aapl%22%29&diagnostics=false&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

there are probably other options that I can get an simpler output with simple stock ticker and price and change.

The question is what program on a PC do I use to scrap the data that I want to output to an arduino?
« Last Edit: December 24, 2011, 08:27:17 am by joefly » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46042
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
1) I do not have any hardcore programming experience, what is the best environment to program on a PC that I can write a stand alone program and then spit it out over USB to arduino?
I like C# for talking to the Arduino. The SerialPort class makes it very easy to send and receive data. C# makes it easy to write code to call web services, too. I'm sure you could find one that would give you all the data you needed about a particular stock.

Web services generally return data as numbers in fields in structures, making the parsing a non-issue.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Paul, I am trying python with pyserial as I had horrible experience with Visual Studio Express before due to it was simply too big and complicated for my purpose. I also found numerous examples related to what I am doing using Python.

However, I am having problems getting the serial port connected using ser = serial.Serial('/dev/tty.usbserial', 9600) it kicks out error as
Code:
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    ser = serial.Serial('/dev/tty.usbserial', 9600)
  File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 31, in __init__
    SerialBase.__init__(self, *args, **kwargs)
  File "C:\Python27\lib\site-packages\serial\serialutil.py", line 261, in __init__
    self.open()
  File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 59, in open
    raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.WinError()))
SerialException: could not open port /dev/tty.usbserial: [Error 3] The system cannot find the path specified.

what am i doing wrong?  FYI, I am running win7 64bit, python27 64bit and pyserial 2.6.  I read somewhere that one should use all versions for 32bit. Is this the problem, should I uninstall python64but and reinstall 32 bit?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

/dev/tty.usbmodem

Wouldn't work in Linux or OS X because there should be a number as part of the device name.  If you are using Windows then it would be COMx.  The serial port name would be the same as the one used by the Arduino IDE.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

james, thanks got it working on COM5
Logged

Pages: [1]   Go Up
Jump to: