Created
October 23, 2018 07:14
-
-
Save r1cebank/9f88abd86083e50b22cd1902c0458ab7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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