I built a circuit that detects tempretuares from 5 different places using an Arduino nano.
Then I used Serial port library in Javascript to read the data in the Terminal(I'm using a Mac).
I can read the data in the terminal now but I'm trying to save the data to a text file but it's not working.
I using node.js but no luck
Here is my javascript code
var SerialPort = require('serialport');
var Readline = SerialPort.parsers.Readline;
var port = new SerialPort('/dev/cu.usbserial-A505BRMT');
var parser = new Readline();
port.pipe(parser);
parser.on('data', console.log);
port.write('ROBOT PLEASE RESPOND\n');
// Creating the parser and piping can be shortened to
var parser = port.pipe(new Readline());
var fs = require('fs')
var readingTotextfile = port.pipe(parser);
fs.appendFile('message.txt', 'My file', function(err) {
console.log('The "data to append" was appended to file!');
});
in my messeage.txt file I only see this "My file". I tried different things some times I saw [object Object]
and other time is saw random things
After I get the data to be saved in a text file, I want to use a chart library to make a graph of my data.
Any help would be great
