Last active
August 29, 2017 06:49
-
-
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.
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 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