Skip to content

Instantly share code, notes, and snippets.

@r1cebank
Created October 23, 2018 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r1cebank/9f88abd86083e50b22cd1902c0458ab7 to your computer and use it in GitHub Desktop.
Save r1cebank/9f88abd86083e50b22cd1902c0458ab7 to your computer and use it in GitHub Desktop.
const SerialPort = require('serialport')
const Readline = require('@serialport/parser-readline')
var port = new SerialPort('/dev/ttyUSB0', {
baudRate: 115200
});
const parser = port.pipe(new Readline({ delimiter: '\r\n' }))
parser.on('data', (data) => {
console.log(JSON.parse(data));
})
{ data:
{ gps: { status: 'found', lat: -1, lng: -1, time: '2080-1-5T23-59-47' },
sensors:
{ temperature: 27.46,
pressure: 1000.4,
humidity: 45.242,
gasResistance: 53.75,
altitude: 107.707 } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment