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);
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()?
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()
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.