From 18c8adf305d0fffda04f6b495f0d0c43952acf9c Mon Sep 17 00:00:00 2001 From: Victor Chapaev Date: Sat, 28 Sep 2024 11:30:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D1=80=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- cmd/example/example.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 cmd/example/example.go diff --git a/.gitignore b/.gitignore index 5fcce4f..2f7d736 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ go.sum -example +./example +!./cmd/* diff --git a/cmd/example/example.go b/cmd/example/example.go new file mode 100644 index 0000000..fa155fb --- /dev/null +++ b/cmd/example/example.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "gitfox.ru/victor/go-dht" + "gitfox.ru/victor/go-wiringpi" +) + +func main() { + if temp, hum, err := dht.ReadDHT(wiringpi.GPIO_7); err != nil { + fmt.Println(err) + } else { + ftemp := dht.CelsiumToFahrenheit(temp) + fmt.Printf("Temperature (C): %.1f\nTemperature (F): %.1f\nHumidity: %.1f\n", temp, ftemp, hum) + } +}