mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 04:43:25 +00:00
dht: fix error check in example
This commit is contained in:
@@ -12,7 +12,7 @@ func main() {
|
|||||||
dhtSensor := dht.New(pin, dht.DHT11)
|
dhtSensor := dht.New(pin, dht.DHT11)
|
||||||
for {
|
for {
|
||||||
temp, hum, err := dhtSensor.Measurements()
|
temp, hum, err := dhtSensor.Measurements()
|
||||||
if err != nil {
|
if err == nil {
|
||||||
fmt.Printf("Temperature: %02d.%d°C, Humidity: %02d.%d%%\n", temp/10, temp%10, hum/10, hum%10)
|
fmt.Printf("Temperature: %02d.%d°C, Humidity: %02d.%d%%\n", temp/10, temp%10, hum/10, hum%10)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Could not take measurements from the sensor: %s\n", err.Error())
|
fmt.Printf("Could not take measurements from the sensor: %s\n", err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user