Skip to content

Instantly share code, notes, and snippets.

@pthorin
Last active August 29, 2017 06:49
Show Gist options
  • Save pthorin/c7ccb09411ec20750aea42c747521afc to your computer and use it in GitHub Desktop.
Save pthorin/c7ccb09411ec20750aea42c747521afc to your computer and use it in GitHub Desktop.
Small script using the Sense HAT (https://www.raspberrypi.org/products/sense-hat/) on a raspberry pi to measure temperature. If the temperature reaches THRESHOLD, send an AWS SNS publish to alert any interested parties.
import boto3
from sense_hat import SenseHat
THRESHOLD=25.0
sense = SenseHat()
humtemp = sense.get_temperature_from_humidity()
presstemp = sense.get_temperature_from_pressure()
avgtemp = (humtemp + presstemp) / 2
if avgtemp >= THRESHOLD:
sns_client = boto3.client('sns')
response = sns_client.publish(
#PhoneNumber='<FILL_ME_IN>',
#TopicArn='<OR_USE_ME>',
Message='WARNING Temperature in server room is %.2f' % avgtemp)
)
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment