from EEPROM to outside file

I stored some information as integer value in EEPROM memory, on ATmega168. Now I will need to read that information and send them to the computer, to outside file (Notepad or Excel).

How can I extend that program:

#include <EEPROM.h>

// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;

void setup()
{
Serial.begin(19200);
}

void loop()
{
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);

Serial.print(address);
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();

// advance to the next address of the EEPROM
address = address + 1;

// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
// on address 512, wrap around to address 0
if (address == 512)
address = 0;

delay(500);
}

Thanks for any help

What else do you need that program to do?

That program is reading correctly but I need save those values in the separate file to keep them. At that moment I can only see them on the screen. Probably I will need something with functions fputs(), fwrite()?

I haven't used it myself but can't gobetweeno write directly to a file or excel?

either that or use putty and save output to a log file?

If you use a terminal emulator such as HyperTerm or PuTTY, then you can use that so save the data into a file on the host computer. You can't use 'fputs' or 'fwrite' on the Arduino because it has no direct access to the host's file system.

As above. How can I save the value from the right hand side and have it in Excel file . It's showing the temperature from sensor and I need check them later and make graphs etc?

You will need to write an app that reads data from com port and saves it to a file.
Like the crude sample below (which I tested and works):

Const ForReading = 1
Const ForWriting = 2

Set fso = CreateObject("Scripting.FileSystemObject")
Set com = fso.OpenTextFile("COM6:9600,N,8,1", ForReading)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\results.txt", ForWriting, True)

MsgBox("Start to read data from COM")

Do While com.AtEndOfStream <> True
    s = com.ReadLine
    objFile.WriteLine(s)
    WScript.Sleep(200)
Loop

objFile.Close
com.Close()

That's the perfect answer which I needed :slight_smile: Thanks

I just found similar question on forum: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1220897178

Maybe someone have the solution in C or Java. I can not use Visual Basic >:(

The code that I posted earlier is a VB script. Just cut it and paste it in a text file, name it with the extension ".vbs", then double click on the file. The script reads the data from COM port and saves it to the file c:\results.txt.
One more thing: you will need to modify the COM port number in line 5, to suit your case.
Let me know if it works for you (it worked for me).

Hi. I did as you say, changed ports and check everything twice but I still get only error: Permission denied in line 8 or 5. I checked access path and no idea what to do else...

Make sure you don't have the serial monitor open/active in Arduino IDE. Also, as you can see, the script never ends running. So, if you open it a second time, you may get the error. In order to end the script, kill the process "wscript.exe" in Task Manager.

Yeap. It works ;D. I thought that I need to have open serial monitor. :-? Thank you very, very much!!!