황원재 황원재 2022-12-01
test
@eda03c5738cd1384843b6e58672ab7e2b5ef00fa
221020/edgex/Temp_Hum_Sensor.py
--- 221020/edgex/Temp_Hum_Sensor.py
+++ 221020/edgex/Temp_Hum_Sensor.py
@@ -4,7 +4,7 @@
 sensor = Adafruit_DHT.DHT11
 pin = 11
 
-#edgexip = "192.168.0.131"
+edgexip = "edgex-ip-address"
 
 try:
 
@@ -13,17 +13,16 @@
         rawHum, rawTemp = Adafruit_DHT.read_retry(sensor, pin)
 
         if rawHum is not None and rawTemp is not None :
-            #print("Temperature = {0:0.1f}*C Humidity = {1:0.1f}%".format(rawHum, rawTemp))
-            
-#            urlTemp = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/temperature' % edgexip
-#            urlHum  = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/humidity' % edgexip
+
+            urlTemp = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/temperature' % edgexip
+            urlHum  = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/humidity' % edgexip
 
             humval = str(rawHum)
             tempval = str(rawTemp)
 
-#            headers = {'content-type': 'application/json'}
-#            response = requests.post(urlTemp, data=json.dumps(int(rawTemp)), headers=headers,verify=False)
-#            response = requests.post(urlHum, data=json.dumps(int(rawHum)), headers=headers,verify=False)
+            headers = {'content-type': 'application/json'}
+            response = requests.post(urlTemp, data=json.dumps(int(rawTemp)), headers=headers,verify=False)
+            response = requests.post(urlHum, data=json.dumps(int(rawHum)), headers=headers,verify=False)
 
             print("Temp: %s\N{DEGREE SIGN}C, humidity: %s%%" % (tempval, humval))
 
@@ -35,3 +34,4 @@
 
 finally:
     print("End of Program")
+
Add a comment
List