pull/112/merge
Andrey Voroshilin 1 month ago committed by GitHub
commit e5ae63f6b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -104,9 +104,11 @@ func (d *Dev) Read() (physic.Env, error) {
}
// Verify checksum
checksum := data[0] + data[1] + data[2] + data[3]
if data[4] != checksum {
return physic.Env{}, errors.New("dht22: checksum error")
if len(data) >= 5{
checksum := data[0] + data[1] + data[2] + data[3]
if data[4] != checksum {
return physic.Env{}, errors.New("dht22: checksum error")
}
}
// Parse data (big-endian)

@ -0,0 +1,15 @@
// Copyright 2016 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
//package dht22 is a driver for dht22/am2302 temperature and humidity sensor
//
//to start use function: "New"
//
//to read data from use function: "Read"
//or u can read data continiusly from chanale whate create by function: "SenseContinuous"
//
//datasheet:
//https://cdn-shop.adafruit.com/datasheets/Digital+humidity+and+temperature+sensor+AM2302.pdf
package dht22
Loading…
Cancel
Save