From 3f4a9d82f7bf37d59a982aeb7f0cf6e56a1b73b9 Mon Sep 17 00:00:00 2001 From: sago35 Date: Tue, 16 Jul 2024 09:00:34 +0900 Subject: [PATCH] Add check for which --- dht20/dht20.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dht20/dht20.go b/dht20/dht20.go index a34c0b9..769be73 100644 --- a/dht20/dht20.go +++ b/dht20/dht20.go @@ -71,6 +71,10 @@ func (d *Device) initRegisters() { // Note that the values obtained by this function are from the previous call to Update. // If you want to use the most recent values, shorten the interval at which Update is called. func (d *Device) Update(which drivers.Measurement) error { + if which&drivers.Temperature == 0 && which&drivers.Humidity == 0 { + return nil + } + // Check if 80ms have passed since the last access if time.Since(d.prevAccessTime) < 80*time.Millisecond { return errUpdateCalledTooSoon