Go Down

Topic: Transfer data via Serial USB with Serial Monitor closed (Read 2093 times) previous topic - next topic

Feb 11, 2011, 11:17 pm Last Edit: Feb 11, 2011, 11:28 pm by crazystress Reason: 1
Hi all,

I'm a newby, so pls, forgive me in case I'm asking somethink a bit stupid   :smiley-roll-sweat:

I had been looking long time a solution to send data trough USB Serial port with the serial monitor closed from the PC to the Arduino but always is needed to have the Serial Monitor Open. Is possible to send data with serial monitor closed?

During the development phase could not be a real problem, but once the project is finished, my project will need to receive data from PC using the USB. If I need to have the Arduino IDE open will be a bit weird.

Thanks for your help!

retrolefty


Hi all,

I'm a newby, so pls, forgive me in case I'm asking somethink a bit stupid   :smiley-roll-sweat:

I had been looking long time a solution to send data trough USB Serial port from the PC to the Arduino but always is needed to have the Serial Monitor Open. Is possible to send data with serial monitor closed?

During the development phase could not a real problem, but once the project is finished, my project will need to receive data from PC using the USB. If I need to have the Arduino SDK open will be a bit weird.

Thanks for your help!


The Arduino communicates with the PC as a simple serial comm port. Any PC software that can connect to a PC's comm port can then send or receive from an Arduino. The Arduino serial statements are not limited to just sending or receiving from the Arduino IDE serial monitor.

You are free to use the the Arduino IDE serial monitor to test and debug your sketch, but once done the serial link is available and usable for any PC application program that can work with a comm port.

That make sense?

Lefty

Thanks for answer. I agree with you, but maybe I'm doing something wrong because when I'm sending data from PC to the Arduino with the serial monitor CLOSED, I can't receive nothing from the PC. In case the Serial Monitor is open, everything works smoothly...

This is the code I'm using:
Code: [Select]
  while( Serial.available() > 0 ) {
    sCadena += String( byte( Serial.read() ) );

    if( sCadena.endsWith("#$#$!#") ) {
      bReset = true;
      break;
    }
  }


PaulS

What application, on the PC, is sending the serial data? What operating system are you using?

I'm sending the data from the following PHP script:

Code: [Select]
$lenstr = strlen( $sString );
$fp = fopen("/dev/cu.usbmodem1a21", "w");
fwrite( $fp, $streamType . $sString . "#$#$!#");
fclose($fp);


I tried the script from Mac OS X and Windows 7 with Arduino 0022, always with the same result: Everything works, but Only if the Serial Monitor window is open.

billroy

The Arduino resets when you open the serial port, and hangs out in the bootloader.  Perhaps your fwrite() is being sent before your program is running and listening for it.

Try a short delay (1000-2000 ms) after the fopen().

-br
http://bitlash.net
http://entropymouse.com

PaulS

Quote
Try a short delay (1000-2000 ms) after the fopen().

Or, try handshaking. That is, wait for the Arduino to say "ready" (or anything) before sending it data.

Go Up