Raspberry Pi Email send with IFTTT

email 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 by step in the complete process. and in this Project, we show an example that sends an email when the CPU temperature of your Raspberry Pi exceeds a threshold.


≡ Components Required Raspberry Pi Email send IFTTT :


Here is a list of the hardware we suggest for this tutorial on utilizing IFTTT on the Raspberry Pi.

  1. Raspberry pi
  2.  Micro SD Card
  3. Ethernet cable
  4.  Power Supply

This book will help you to gain more knowledge of Raspberry pi  Software and Hardware Problems and Solutions

Raspberry Pi Cookbook


≡ Creates an account with IFTTT for Raspberry Pi Email sent:


In this sectionwe’ll be showing you how to creates an account with IFTTT: for this project.

1. You need to create an account with IFTTT before you’ll be able to begin utilizing it, so visit www.ifttt.com and sign up.

 create an account with IFTTT

2. Now you have to need Click to create in red highlight Option

create an account with IFTTT

3. On this page, we got to start by selecting the trigger for our IFTTT activity. so now clicking the “+This” content, as appeared within the screenshot below

create an account with IFTTT

4. We are planning to show you how to make utilize the webhook service. so That Start by searching “webhook” within the search box and. we got to click the “Webhooks” button like the screenshot below

5. Now time to Click Receive a web request screenshot below

create an account with IFTTT

6. We need to allow an event title for this trigger. This title must not contain any spaces or images of other than the underscore (_) character. For our case event, we are utilizing “Raspberry_Pi_CPU_temperature” as the event title screenshot below.

create an account with IFTTT

7. Let’s now select the “That” activity for the IFTTT trigger screenshot below.

create an account with IFTTT

8. The following step is to choose the service we need to utilize for our actions.  For this tutorialwe are going be making utilize of the “Email” service

This service sends an Email to the IFTTT app when our event is triggered. There are different other services, but Email is one of the easiest to setup
. We got to look up “Email” within the look box. When the “Email” service pops up, click its screenshot below.
create an account with IFTTT
9. Now we have to be select an action provided by this service. In this case, we need to send a basic Email to the IFTTT app screenshot below
create an account with IFTTT
10. now click Create an action No need any change now screenshot below
create an account with IFTTT
11. Now, click the “Finish” button screenshot below
12. Now-Again Back on the webhooks page, click the “Documentation” Option within the best right-hand corner of the screen. Clicking this will take us to the screen were ready to find the API keys we require screenshot below.
create an account with IFTTT
13.you You can see Your API key On this page, copy down the API key  Below you’ll be able to see the URL where we’ll send our webhook calls to. This URL is located underneath the “To trigger an Event” title.
create an account with IFTTT
That’s it—the recipe is now live, and once the Raspberry Pi is prepared to send web requests to it, it’ll start emailing.

≡ Preparing your Raspberry Pi for this project:


In this sectionwe’ll be showing you how to  Raspberry Pi for this project. if you First-time run project you have to need to update your raspberry pi You’ll do this by running the following commands.
sudo apt update
sudo apt upgrade

Now you have to need library install for this project You’ll do this by running the following commands. 

pip install urllib3

Or
sudo apt-get install urllib2

≡ Code Raspberry Pi Email send IFTTT:


The Python program to send the web request

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)

Before running the program, you’ll have to get an get to the key for the Maker Action channel by selecting Channels, and after that searching for Maker. Paste the key into email.py on the line that begins KEY= and then run the program using the screenshot below:

terminal

Notice how the values have been substituted into the email screenshot below 

create an account with IFTTT

If you want to know more about raspberry pi then click on the link below

RASPBERRY PI TUTORIALS FOR BEGINNERS

 263 total views,  1 views today