Go Down

Topic: Arduino Result to text file (Read 3307 times) previous topic - next topic

GSim

Hiii i need to know how to save my Arduino Uno distance Results into a Text File in order to display the result in an android application, that the Arduino board is connected to the pc via USB?? Any help?

florinc

There are many ways to do that:
1. save the data on SD card (text file);
2. send data through Bluetooth directly to your Android app;
3. send data through USB (serial port) to PC.

GSim

Thanks a lot but i don't have SD Card nor Bluetooth connected to the Arduino Board , So Am using USB , but the problem is i am not understanding how , I found this code
http://timewitharduino.blogspot.com/2009/05/getting-arduino-to-write-to-or-read.html , but I can't understand it or determine if it is useful or not can you explain it or sth ? . thanks again ...

PeterH

What operating system does the PC run? If it's Microsoft Windows, you can use Gobetwino to write data supplied by the Arduino to a file on the PC. I'm not clear how you would get it from there to the Android, but since you don't seem to have provided any other way to get the data off the Arduino, getting it onto a file the PC would seem to be a useful first step.
I only provide help via the forum - please do not contact me for private consultancy.

MikMo

GoBetwino can run on your PC and ave data coming from Arduino to a txt file on the PC.

florinc

The code you linked to is a VB script (running on Windows) that reads characters on a COM (serial) port and saves them to the specified file.
Did you try running it? What part of the code you don't understand?

GSim

I have downloaded GobetWino but I didn't understand how it functions well ..
and Florinc I understand the code but i keep getting "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in DataReader.exe" while running !! and I can't figure out how to solve it ... can you help?

florinc

What version of Windows are you running on?
What COM port are you using?
Can you post your code?

MikMo

If you check the sample code that comes with GoBetwino you can find an example of how to log data to a txt file on the PC.

GSim

I am running on Windows 7, using Com Port 25 and here is my code
Imports Scripting
Imports System.Threading.Thread
Imports System.Windows.Forms.SendKeys



Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Try
            Const ForReading = 1
            Const ForWriting = 2
            Dim fso

            Dim com
            Dim objFSO
            Dim objFile
            Dim s

            Dim WShell

            WShell = CreateObject("WScript.Shell")
            fso = CreateObject("Scripting.FileSystemObject")
           
            com = fso.OpenTextFile("COM25:9600,N,8,0", ForReading)




            objFSO = CreateObject("Scripting.FileSystemObject")
            objFile = objFSO.OpenTextFile("D:\Data.txt", ForWriting, True)

            MsgBox("Start to read data from COM")

            Do While com.AtEndOfStream <> True
                s = com.ReadLine
                objFile.WriteLine(s)
                System.Threading.Thread.Sleep(100)
            Loop

            objFile.Close()
            com.Close()

        Catch
            MessageBox.Show("Unable to read file ")
        End Try

    End Sub
End Class


Iactually used it from this site : http://timewitharduino.blogspot.com/2009/05/getting-arduino-to-write-to-or-read.html
I keep getting file not found, the error is on line :com = fso.OpenTextFile("COM25:9600,N,8,0", ForReading)
thanks a lot

And for the Gobetwino I found out that it doesn't work on Windows 7 that's why it couldn't run on my pc ... thanks !!1 :)

PeterH


And for the Gobetwino I found out that it doesn't work on Windows 7 that's why it couldn't run on my pc ... thanks !!1 :)


I am running it on Windows 7.
I only provide help via the forum - please do not contact me for private consultancy.

GSim

Thats Greaaat!! then could you help me understand how to use it??? it didn't work for me,I guess I was using it wrong then !

MikMo

I dont' think there' any problem running GoBetwino on Window 7.

PeterH

I only provide help via the forum - please do not contact me for private consultancy.

florinc

According to this microsoft article
http://support.microsoft.com/kb/115831
COM ports higher than 9 are named like this: \\.\COM10

I don't have windows 7 to test it, but I think it will work if you change the line to:
Code: [Select]
  com = fso.OpenTextFile("\\\\.\\COM25:9600,N,8,0", ForReading)


Go Up