Results 1 to 5 of 5

Thread: Arduino serial ouput to file?

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Arduino serial ouput to file?

    Hi all,
    Yesterday I started using the Arduino. I'm happy at easy everything seems to be. What I haven't figured out yet is how to send the serial output to a file. The device is mounted at /dev/ttyACM0
    Code:
    void setup()                    
    {
      Serial.begin(9600);              // set up Serial library at 9600 bps
      Serial.println("Hello world!");  // prints hello with ending line break 
    }
    void loop()                       
    {
                                      // do nothing!
    }
    For example, how could I send that to a file on my computer?
    Last edited by conradin; October 24th, 2012 at 03:11 PM. Reason: / typo
    ~Conradin~

  2. #2
    Join Date
    Jun 2008
    Location
    Mumbai
    Beans
    223
    Distro
    Ubuntu

    Re: Arduino serial ouput to file?

    i dnt know but may be u will have to write any kernal module ....why dnt u use putty may be it will have any option to write in file (but not sure)

  3. #3
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,125
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Arduino serial ouput to file?

    I just tried:
    Code:
    #!/bin/bash
    #http://www.yetanother.eu/arduino/articles/temp_basic.php 
    # Port setting
    stty -F /dev/ttyACM0 raw speed 9600
     
    # Loop
    while [ 1 ]; do
    READ=`dd if=/dev/ttyACM0 count=1`
    echo $READ >> filename
    done
    but the output is broken.
    Code:
    $ cat filename 
    Hello world!
    Hell
    Hello
    Hello wo
    
    Hello w
    Hello
    for clarity, I changed my arduino code to:
    Code:
    void setup()                    
    {
      Serial.begin(9600);              // set up Serial library at 9600 bps
    }
    void loop()                       
    {
     delay(9000); 
     Serial.println("Hello world!");  // prints hello with ending line break 
    }
    so that I have a stream to read.
    I imagine I could write a server app and have it listen on a socket for the arduino. That strikes me as less easy but something which would work.
    The problem with bash script above is its not listening, its just copying, its not waiting for data to get there, which is why I'm missing data.

    I assume this is a common task for arduino users so I'm just looking for the best ways to get it done. The end result will be to get sensor data from an areo-flexor Im going to build. But I need to figure out how to store data from that system first.
    Last edited by conradin; October 24th, 2012 at 04:24 PM. Reason: typo
    ~Conradin~

  4. #4
    Join Date
    Mar 2008
    Location
    Queensland Australia
    Beans
    664
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Arduino serial ouput to file?


  5. #5
    Join Date
    Jun 2008
    Location
    Mumbai
    Beans
    223
    Distro
    Ubuntu

    Re: Arduino serial ouput to file?

    try this
    stty raw ; cat > received.txt

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •