finding a bug

This commit is contained in:
Daniel Ledda
2020-10-31 16:23:25 +01:00
parent af9fe5152c
commit 7e86f0e5cf

View File

@@ -59,7 +59,7 @@ func readDataFromDHT(pin *gpio.Pin) ([5]byte, error) {
pin.PullUp()
pin.Input()
time.Sleep(30 * time.Microsecond)
// Wait for high low signal
// Wait for low high signal
cyclesLo := cyclesForReading(pin, gpio.Low)
if cyclesLo == Timeout {
return [5]byte{}, errors.New(fmt.Sprintf(TimeoutErrInitial, "low"))
@@ -102,9 +102,9 @@ func storeCycleCountsAsBinarySequence(cycles *[80]int) ([5]byte, error) {
for i := 0; i < 40; i++ {
lowCycles := cycles[2 * i]
highCycles := cycles[2 * i + 1]
if (lowCycles == Timeout) || (highCycles == Timeout) {
return [5]byte{}, errors.New("timed out waiting for sensor pulse")
}
//if (lowCycles == Timeout) || (highCycles == Timeout) {
// return [5]byte{}, errors.New("timed out waiting for sensor pulse")
//}
data[i / 8] <<= 1
if highCycles > lowCycles {
data[i / 8] |= 1