Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created September 23, 2019 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/6895e95c97e8dd3318a8d7878231a41f to your computer and use it in GitHub Desktop.
Save elbruno/6895e95c97e8dd3318a8d7878231a41f to your computer and use it in GitHub Desktop.
AzureIoTCSendDeviceProperty.py
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