--- 221020/edgex/Temp_Hum_Sensor.py
+++ 221020/edgex/Temp_Hum_Sensor.py
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 |
sensor = Adafruit_DHT.DHT11 |
5 | 5 |
pin = 11 |
6 | 6 |
|
7 |
-#edgexip = "192.168.0.131" |
|
7 |
+edgexip = "edgex-ip-address" |
|
8 | 8 |
|
9 | 9 |
try: |
10 | 10 |
|
... | ... | @@ -13,17 +13,16 @@ |
13 | 13 |
rawHum, rawTemp = Adafruit_DHT.read_retry(sensor, pin) |
14 | 14 |
|
15 | 15 |
if rawHum is not None and rawTemp is not None : |
16 |
- #print("Temperature = {0:0.1f}*C Humidity = {1:0.1f}%".format(rawHum, rawTemp)) |
|
17 |
- |
|
18 |
-# urlTemp = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/temperature' % edgexip |
|
19 |
-# urlHum = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/humidity' % edgexip |
|
16 |
+ |
|
17 |
+ urlTemp = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/temperature' % edgexip |
|
18 |
+ urlHum = 'http://%s:49986/api/v1/resource/Temp_and_Humidity_sensor_cluster_01/humidity' % edgexip |
|
20 | 19 |
|
21 | 20 |
humval = str(rawHum) |
22 | 21 |
tempval = str(rawTemp) |
23 | 22 |
|
24 |
-# headers = {'content-type': 'application/json'} |
|
25 |
-# response = requests.post(urlTemp, data=json.dumps(int(rawTemp)), headers=headers,verify=False) |
|
26 |
-# response = requests.post(urlHum, data=json.dumps(int(rawHum)), headers=headers,verify=False) |
|
23 |
+ headers = {'content-type': 'application/json'} |
|
24 |
+ response = requests.post(urlTemp, data=json.dumps(int(rawTemp)), headers=headers,verify=False) |
|
25 |
+ response = requests.post(urlHum, data=json.dumps(int(rawHum)), headers=headers,verify=False) |
|
27 | 26 |
|
28 | 27 |
print("Temp: %s\N{DEGREE SIGN}C, humidity: %s%%" % (tempval, humval)) |
29 | 28 |
|
... | ... | @@ -35,3 +34,4 @@ |
35 | 34 |
|
36 | 35 |
finally: |
37 | 36 |
print("End of Program") |
37 |
+ |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?