-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
26 lines (26 loc) · 863 Bytes
/
main.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
"use strict";
var dht11 = 0;
var temp = null;
/**
* control.runInParallel(function () { forever(function () { serial.writeLine("?" + serial.readString()); pause(1000); }); }) Write to the SPI slave and return the response @param value Data to be sent to the SPI slave
*/
/**
* dht.read(function (data: { raw: number[]; rh: number; t: number; err: boolean; }) { console.log(`Temperature is: ${data.t}`) })
*/
serial.setBaudRate(BaudRate.BaudRate115200);
// serial.attachToConsole();
var dht = new DHT11(pins.D11);
forever(function () {
temp = dht.temperature();
var dhtResult = {
id: "sensor",
temperature: temp.tc,
humidity: temp.rh,
channel: 6
};
var dhtJson = JSON.stringify(dhtResult);
serial.writeLine(dhtJson);
// console.log("" + dhtJson); console.log("" +
// riseFall);
pause(60000);
});