javascript - Getting old and new data in an array on serialport - Arduino uno, nodejs, socket.io and sensor -


i have attached sensor arduino , trying pull data using serial port nodejs. using make graph.

data pushed serial port, when printed on terminal looks this:

1,2  1,2 1,3  1,2 1,3 1,4  1,2 1,3 1,4 1,5 

as can see previous data pushed again :/ dont want that

expected output

1,2 1,3 1,4 1,5 1,6 

format here : <value 1> , <value 2>

later splitting these incoming data , push 2 different datasets, in-order graph this:

http://www.chartjs.org/samples/latest/charts/line/multi-axis.html

code - nodejs

var serialport = require("serialport"); var serialport = new serialport("com4");  var received = "";  serialport.on('open', function(){     console.log('serial port opend');      serialport.on('data', function(data){       received += data.tostring();       console.log("incoming data: " + received);     nsp.emit('live-data', received);   }); }); 

serial output code arduino

void serialoutput(){   // decide how output serial.   switch(outputtype){     case processing_visualizer:       senddatatoserial('s', signal);     // goes senddatatoserial function       break;     case serial_plotter:  // open arduino serial plotter visualize these data       serial.print(bpm);       serial.print(",");       serial.println(signal);       break;     default:       break;   }  } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -