Hi everyone! Ummm... engg. What module are you using? Maybe:
https://github.com/voodootikigod/node-serialport In general, the stream programmer writes expecting you consume the stream with something like: stream.on('data', function(data) { .... with one parameter, instead of: stream.on('data', function(data, data1, data2) { .... Am I write? Or your module (or some version of stream) accepts three parameters? Another question: Where are receivedData1,receivedData2 in your code? I see them only at console.log I don't see Serial.print(',') the comma in your Arduino output: 181 32 23 191 31 28 ................. nor the Serial.print of a new line. I guess you receive an string, you must use stream.on('data', function(data) { // parse the data and collect in an array }); If you are using node-serialport, you have parsers: https://github.com/voodootikigod/node-serialport#parsers My first approach: use a parser with a delimeter, maybe \n if you have it at your Arduino output. Nice to know Node.js has a serial port implementation, even in Windows! I gave a talk at Cuenca, Ecuador, last year, and some of the attendants found some serial port support for their project, but I never tried it. Baud rates, old good times ;-) Angel "Java" Lopez @ajlopez On Sat, Jul 20, 2013 at 12:06 AM, <[email protected]> wrote: > I have my arduino connected in serial with my laptop. The arduino has > three sensors. > The reading of the sensors is given by > > Serial.print(sensor1); > Serial.print(","); > Serial.print(sensor2); > Serial.print(","); > Serial.print(sensor3); > Serial.print(","); > > The arduino serial monitor is showing data perfectly > 181 32 23 > 191 31 28 > ................. > > In node.Js I wrote like this > > function serialListener(debug) > { > var receivedData = ""; > var receivedData1 = ""; > serialPort = new SerialPort(portName, { > baudrate: 9600, > // defaults for Arduino serial communication > dataBits: 8, > parity: 'none', > stopBits: 1, > flowControl: false > }); > serialPort.on("open", function () { > console.log('open serial communication'); > // Listens to incoming data > serialPort.on('data',function(data,data1,data2) { > receivedData += data.toString(); > receivedData += data1.toString(); > receivedData += data2.toString(); > console.log(receivedData, receivedData1,receivedData2); > }); > > }); > } > > The console is giving results like this > 181,32,23,191,31,28........... > This means I will not be able to extract independent values. > > Please help me how to listen to individual multiple values and get them > with HTML. > Thanks > > Please note that I am getting perfect results with single sensor both in > node.js and in HTML > > Thanks in advance > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
