Skip to content
Permalink
Browse files

Indicate sending on sense hat and adjust temperature

  • Loading branch information...
mirontoli committed Oct 31, 2015
1 parent 517e8f1 commit 85784fbfbc6f0d527ee2b7d99cdab8033547cf7d
Showing with 10 additions and 4 deletions.
  1. +10 −4 python_scripts/azure_sense.py
@@ -19,14 +19,20 @@

table_service = TableService(account_name='tolle', account_key='ho2zakf/8rmDckS3pGOTPWwIwCzNwVJxd5hDb3R15wms2fZJG/aX53PDsTWBYsuTPwF7802IKk2QcrJ5FO7i6w==')
table_name = 'climateData'
partition_key = 'climate2'
table_service.create_table(table_name, False)

while True:
sense.show_letter('S', text_colour=[0, 114, 198])
date = datetime.now()
iso_date = date.isoformat()
temp = "{0:.2f}".format(sense.temp)
iso_date = date.isoformat()
raw_temp = sense.temp
#calculate temperature https://www.raspberrypi.org/forums/viewtopic.php?t=111457&p=769672
calctemp = 0.0071 * raw_temp * raw_temp + 0.86 * raw_temp - 10.0
temp = "{0:.2f}".format(calctemp)
humidity = "{0:.2f}".format(sense.humidity)
pressure = "{0:.2f}".format(sense.pressure)
entry = {'PartitionKey': 'climate', 'RowKey': iso_date, 'Temperature': temp, 'Humidity':humidity, 'Pressure':pressure}
entry = {'PartitionKey': partition_key, 'RowKey': iso_date, 'Temperature': temp, 'Humidity':humidity, 'Pressure':pressure}
table_service.insert_entity(table_name, entry)
time.sleep(60) # wait one minute
sense.clear()
time.sleep(60) # wait one minute

0 comments on commit 85784fb

Please sign in to comment.
You can’t perform that action at this time.