generated from dohack-io/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (34 loc) · 867 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
let net = require('net');
let http = require('http');
let fs = require('fs');
let gpio = require('gpio');
let HOST = '192.168.0.42';
const request = require('request')
function sendData() {
let jstring = "";
let co2 = 400 + 2600*Math.random();//400 - 3000
let hum = 10 + 90*Math.random();
let voc = 400 + 600*Math.random();
let tmp = 5 + 25*Math.random();
//jstring = "{" + "\"name\":\"Besprechungsraum 1\"," +
//"\"co2\":\"" + co2.toString() +"\",\"hum\":\"" +
//hum.toString()"\",\"voc\":\"" + voc.toString() + "\",\"tmp\":\"" +
//tmp.toString() + "\" }";
request.post(HOST,
{
name: 'Neo1',
co2: co2,
hum: hum,
voc: voc,
tmp: tmp
}
, (error, res, body) => {
if (error) {
console.error(error)
return
}
console.log(`statusCode: ${res.statusCode}`)
console.log(body)
})
setTimeout(sendData, 1000);
}