Started wather station

This commit is contained in:
plane000
2018-08-17 21:07:15 +01:00
parent caff458774
commit f2ef456bf5
5 changed files with 1932 additions and 29 deletions

View File

@@ -0,0 +1,28 @@
const SerialPort = require('serialport');
const parsers = SerialPort.parsers;
const fs = require('fs');
let express = require('express');
let app = express();
const parser = new parsers.Readline({
delimiter: '\r\n'
});
const port = new SerialPort('COM3', {
baudRate: 115200
});
port.pipe(parser);
let temperature;
port.on('data', async (data) => {
if (data.toString().startsWith('VALID')) {
if (parseFloat(data.toString().substring(5)) % 1) {} else return;
let temp = parseFloat(data.toString().substring(5));
temperature = temp;
console.log(temp);
}
});