possible for computer to receive messages?

I'm wondering if its possible for the computer to receive messages from the arduino? In other words, have the arduino print the word "hello" or whatever, and have it show up on the computer?

I'm guessing if so it's using the Serial class, but I'm not sure how to receive the messages. I'm on Windows if it matters.

Thanks for any help.

http://arduino.cc/en/Reference/HomePage

read up on all the serial commands, in particular serial.print and serial.printLn

In other words, have the arduino print the word "hello" or whatever, and have it show up on the computer?

Serial.println("hello")

You will need to Interface With Software and make a program that runs on your computer, listening for serial data. Often called a proxy.

You could also google for a piece of software with the name gobetwino. :) Written by a formum member for the purpose of making pc and arduino talk.

Thanks, the gobetwino works. I made a little Python script that works too if anyone needs it:

import time, wmi, serial

def find_arduino():

    c = wmi.WMI ()
    for device in c.Win32_PnPEntity ():

        current = device.Name

        if "(com" in current.lower():

            if "FTDI" in device.Manufacturer:
                # figure out the port # with a horrible bit of duct tape
                # other way to get the port number?
                comport = device.Caption.replace("USB Serial Port (COM", "")
                comport = comport.replace(")", "")

                try: comport = int(comport)
                except ValueError: return None

                return comport



print "Searching for the arduino, this might take a moment..."

comport = find_arduino()

else: comport = 6

if comport: print "Hallelujia, I found it! Its at COM" + str(comport) + "..."
else: print "Whoops, I didn't find an arduino..." 



baud = 9600
ser = serial.Serial(comport - 1, baud, timeout=.25)

while True:    
    ln = ser.readline()
    ln = ln.replace("\n", "") # get rid of the extra hard return
    print ln

Note that this is written for Windows. The only semi slick thing it does is find the Arduino's serial port automatically, at least on my computer. It does this using the Windows WMI interface using a bit of duct tape. Its slow since it iterates through the entire PNP interface, but it works reliably for me.

Would probably be better to hardcode the serial port if you're running it often.

And also note that you'll need to install the pyserial module from here: http://pyserial.wiki.sourceforge.net/pySerial

And I think to use WMI you need to install the Windows extensions for Python.

That enumeration process is a clever way to save users some effort, but, if you add an optional command-line parameter to your Python script, people can create batch files that skip it and save time.

Ran

True, but personally I see a commandline switch as a hassle since that means not being able to run it with a mouse click. I suppose someone could make a shortcut with the switch included or a batch file, but still that's extra work.

Something like this might be easier:

comport = raw_input("What's the number of your com port? ")

Or better yet just hard code the comport number in the script and have the user edit the script manually, since the comport number probably won't change on any given computer:

comport = 6

If I get a chance I'll wrap it in a simple gui using WxPython, my gui framework of choice. I'm not sure how much need there is for one though since gobetwino works.

I wrapped a gui around it:

http://gizmoware.net/arduinospy/ArduinoSpy.exe

For now its Windows only, but its Python so once I get the kinks out I'll cross-compile. Still definitely beta. For example I'd like to change the way the serial port is getting polled to make it a bit more efficient. I'll release the Python sourcecode once I finish it. No clue whether it works on Vista, feedback invited.

A few features:

  • not meant to be a general purpose arduino/computer bridge like gobetwino, this is just to see println messages from the Arduino for debugging.

  • single file, no installer. Sorry about the file size, the program itself is very small but I have to include all the Python libraries.

  • minimal interface, and resizable and remembers window size & position.

  • global hotkey: printscreen or scrolllock will connect/disconnect from the arduino. So if you need to upload a new version of your script to the arduino, hit printscreen to disconnect without having to focus on arduinospy.

  • can optionally try to find your arduino

  • if you need to go to device manager to look up your arduino's comport number, view --> show device manager

  • button turns green when connected, red when not. The idea is you can see connection state at a glance

For future reference, I just discovered that the Arduino IDE can monitor the arduino just fine. Click the serial port button at the top right of the IDE....