Mechatronics LAB
Published © MIT

Raspberry Pi Email send with IFTTT

You went to do Raspberry Pi Email send with the IFTTT project. Today I show you How to send an email with IFTTT Using Raspberry Pi step

BeginnerFull instructions provided1 hour599
Raspberry Pi Email send with IFTTT

Things used in this project

Hardware components

raspberry pi
×1

Story

Read more

Schematics

Raspberry Pi Email send with IFTTT

Raspberry Pi Email send with IFTTT

Code

Code snippet #3

Plain text
import time, os, urllib, urllib2

MAX_TEMP = 37.0
MIN_T_BETWEEN_WARNINGS = 60 # Minutes

EVENT = 'raspberry'
BASE_URL = 'https://maker.ifttt.com/trigger/'
KEY = 'hLTwmMC3A5J9KnUXwoITVfHEJ2d5eVpvcNsqi85OhDA'

def send_notification(temp):
    data = urllib.urlencode({'value1' : str(temp)})
    url = BASE_URL + EVENT + '/with/key/' + KEY
    response = urllib2.urlopen(url=url, data=data)
    print(response.read())


def cpu_temp():
    dev = os.popen('/opt/vc/bin/vcgencmd measure_temp')
    cpu_temp = dev.read()[5:-3]
    return float(cpu_temp)
    
while True:
    temp = cpu_temp()
    print("CPU Temp (C): " + str(temp))
    if temp > MAX_TEMP:
        print("CPU TOO HOT!")
        send_notification(temp)
        print("No more notifications for: " + str(MIN_T_BETWEEN_WARNINGS) + 
" mins")
        time.sleep(MIN_T_BETWEEN_WARNINGS * 60)
    time.sleep(1)

Credits

Mechatronics LAB
75 projects • 47 followers
I am Sarful , I am a Mechatronics Engineer & also a teacher I am Interested in the evolution of technology in the automation industry .
Contact

Comments

Please log in or sign up to comment.