Created
September 23, 2019 20:30
-
-
Save elbruno/6895e95c97e8dd3318a8d7878231a41f to your computer and use it in GitHub Desktop.
AzureIoTCSendDeviceProperty.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import iotc | |
def getCPUtemperature(): | |
res = os.popen('vcgencmd measure_temp').readline() | |
return(res.replace("temp=","").replace("'C\n","")) | |
def sendTempAndConnectionDate(): | |
print("Sending temp and connection date ..") | |
propJson = "{\"rpiTemp\": \"" + str(getCPUtemperature()) + "\"}" | |
iotc.sendProperty(propJson) | |
telemetryMessage = "{\"temp\": " + str(getCPUtemperature()) + "}" | |
iotc.sendTelemetry(telemetryMessage) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment