From 732d1963ed83abf4e5f1b06ec451a6943421d716 Mon Sep 17 00:00:00 2001
From: Guo Wenxue <guowenxue@gmail.com>
Date: Thu, 22 Sep 2022 00:36:11 +0800
Subject: [PATCH] update ds18b20.c to snprintf

---
 modules/c/ds18b20.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/c/ds18b20.c b/modules/c/ds18b20.c
index 447bf28..29fbdc3 100644
--- a/modules/c/ds18b20.c
+++ b/modules/c/ds18b20.c
@@ -8,8 +8,20 @@
  *        Version:  1.0.0(2018/10/14)
  *         Author:  Guo Wenxue <guowenxue@gmail.com>
  *      ChangeLog:  1, Release initial version on "2018/10/14 12:13:26"
- *                 
+ *
+ *
+ * Pin connection:
+ *
+ *          vcc   --- #Pin1 ( 3.3v )
+ *          DQ    --- #Pin7 (BCM GPIO4)
+ *          GND   --- #Pin9 ( GND  )
+ *
+ * /boot/config.txt:
+ *
+ *          dtoverlay=w1-gpio-pullup,gpiopin=4
+ *
  ********************************************************************************/
+
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -32,7 +44,7 @@
                 return 1;
         }
 
-        printf("DS19B20 get temperature: %f ℃\n", temp);
+        printf("DS18B20 get temperature: %f ℃\n", temp);
         return 0;
 }
 
@@ -116,5 +128,7 @@
     /* convert string value to float value */
     *temp = atof(ptr)/1000;
    
+    close(fd);
+
     return 0;
 }

--
Gitblit v1.9.1