Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.