This project uses two files on the SD card to layout CSV file format for data logging and read analog inputs in engineering units.
Mylog.cfg
Mycalibrations.cal
The following link lays out the object used to calibrate the analog inputs into engineering units. It was used to create the file “Mycalibrations.cal” on the SD card. http://forum.espruino.com/conversations/286215/
The following code was used to create the log configuration file:
SaveLog.js
var LogObj1={
Fname:"xxx.csv",
Interval:1000, //milliseconds between samples
items:[
// header is text at top of column in csv file
// cmd source for data in each column
// can be in a different order
// and have more or fewer items
{header:"N",cmd:"count"},
{header:"Date",cmd:"DMY",Args:["-","-"]},
{header:"Time",cmd:"HMS",Args:[":",":"]},
{header:"A0",cmd:"AR",Args:["A0",2]},
{header:"A0",cmd:"SAR",Args:["A0",2]},
{header:"Board Temp C",cmd:"BTC",Args:[2]},
{header:"Board Temp F",cmd:"BTF",Args:[2]}
],
count:0, // Number of lines logged
N:10 // stop logging after count>N
}; //end LogObj1
function saveObject(myobject) {
var Q;
var sss=JSON.stringify(myobject);
if (Q===undefined) {
Q = E.openFile("Mylog.cfg", "w");
Q.write(sss);
Q.close();
Q = undefined;
}//endif
}//end doLog
saveObject(LogObj1);
var a=require("fs").readFileSync("Mylog.cfg");
console.log(a);
console.log(' ');
The left screen when the log configuration file is created:
The logging program. The test portion opens the calibration file and the configuration file and creates a calibration object and two instances of the configuration. The layout is identical (could be different) except that the filename to write, and logging interval in one is 1 second and the other is 3 seconds.
LogCSV3.js
The console output when the program executes:
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
This project uses two files on the SD card to layout CSV file format for data logging and read analog inputs in engineering units.
Mylog.cfg
Mycalibrations.cal
The following link lays out the object used to calibrate the analog inputs into engineering units. It was used to create the file “Mycalibrations.cal” on the SD card.
http://forum.espruino.com/conversations/286215/
The following code was used to create the log configuration file:
SaveLog.js
The left screen when the log configuration file is created:
The logging program. The test portion opens the calibration file and the configuration file and creates a calibration object and two instances of the configuration. The layout is identical (could be different) except that the filename to write, and logging interval in one is 1 second and the other is 3 seconds.
LogCSV3.js
The console output when the program executes:
The CSV files created are: xxx.csv and xx1.csv
6 Attachments