Skip to content

Commit 7612060

Browse files
committed
fixed typos
changed pin in example
1 parent 0ce626f commit 7612060

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

examples/simpleRead.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const dht = require('../');
22

3-
const dataPin = 5;
3+
const dataPin = 2;
44
const sensor = dht(dataPin);
55

66
setInterval(() => {

index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const eventEmitter = require('events').EventEmitter;
44

55
module.exports = function(pin, type) {
66
const dht = Object.create(new eventEmitter());
7-
const gpio = new Gpio(pin, { mode: Gpio.OUTPUT, pullUpDown: Gpio.PUD_OFF };
7+
const gpio = new Gpio(pin, { mode: Gpio.OUTPUT, pullUpDown: Gpio.PUD_OFF });
88

99
dht.reading = false;
1010

@@ -22,12 +22,12 @@ module.exports = function(pin, type) {
2222
// cancel out if we are already reading
2323
return false;
2424
}
25-
dht.emmit('start');
25+
dht.emit('start');
2626
// Trigger a new relative humidity and temperature reading.
2727
// write low for 18 ms
2828
gpio.digitalWrite(0);
2929
// after that let the line go high and start reading
30-
setTimeout(() => {
30+
setTimeout(() => {
3131
// reset all values
3232
bits = -2; // initialized at -2 because the first 2 lows are the ack
3333
rhumHigh = 0;
@@ -47,7 +47,7 @@ module.exports = function(pin, type) {
4747
dht.reading = false;
4848
gpio.disableAlert();
4949
gpio.mode(Gpio.OUTPUT);
50-
dht.emmit('end');
50+
dht.emit('end');
5151
}
5252

5353
gpio.on('alert', (level, tick) => {
@@ -57,7 +57,7 @@ module.exports = function(pin, type) {
5757
// bits are only accumulated on the low level
5858
if (level == 0) {
5959
let diff = (tick >> 0) - (lastHighTick >> 0);
60-
60+
6161
// Edge length determines if bit is 1 or 0.
6262
let val = 0;
6363
// low bit is between 26 and 28 µs
@@ -75,13 +75,13 @@ module.exports = function(pin, type) {
7575
// we don't need to do anything with these
7676
} else if (bits < 8) {
7777
// in humidity high byte
78-
rhumHigh = (rhumHigh << 1) + val;
78+
rhumHigh = (rhumHigh << 1) + val;
7979
} else if (bits < 16) {
8080
// in humidity low byte
81-
rhumLow = (rhumLow << 1) + val;
81+
rhumLow = (rhumLow << 1) + val;
8282
} else if (bits < 24) {
8383
// in temp high byte
84-
tempHigh = (tempHigh << 1) + val;
84+
tempHigh = (tempHigh << 1) + val;
8585
} else if (bits < 32) {
8686
// in temp low byte
8787
tempLow = (tempLow << 1) + val;
@@ -103,10 +103,10 @@ module.exports = function(pin, type) {
103103
let mult = (tempHigh & 128) ? -0.1 : 0.1;
104104
tempHigh = tempHigh & 127; // strip the sign bit
105105
let temp = ((tempHigh << 8) + tempLow) * mult;
106-
106+
107107
dht.emit('result', { temperature: temp, humidity: rhum });
108108
} else {
109-
dht.emmit('badChecksum');
109+
dht.emit('badChecksum');
110110
}
111111
}
112112
}

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)