element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog Upcycled Clock- Unleash the power using IFTTT
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 28 Apr 2017 7:57 AM Date Created
  • Views 1141 views
  • Likes 4 likes
  • Comments 6 comments
  • upcycledclock
  • upcycle_it
  • upcycle
  • intel_edison
  • iot
  • ifttt
  • philips_hue
Related
Recommended

Upcycled Clock- Unleash the power using IFTTT

carmelito
carmelito
28 Apr 2017

Here is a quick and easy way to get your Intel Edison connected to the Internet !! using the simple python program below to connect to IFTTT.

 

If you have been living under a rock image and not heard about IFTTT, here is a quick intro from Wikipedia - IFTTT (If This Than That)is a free web-based service that people use to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Instagram, or Pinterest. An applet may send an e-mail message if the user tweets using a hashtag or to copy a photo on Facebook to a user's archive if someone tags a user in a photo.

 

In my scenario, the applet is triggered by the python code below and data is posted to the IFTTT maker channel, this basically is the IF side of things.And, as part of the data send you can send sensor values as part of the payload , which in case of the program below is Temperature, Light value and the potentiometer value. And as part of THEN side of things you can basically trigger various things like -

  • Send an email to your self with the sensor values.
  • Send your self a text message if the temperature in your home is to high
  • Turn on the lights in your house when it gets dark, in my case the idea is to turn on the Phillips Hue Lights.
  • And, in addition I have also setup another recipe to cycle through various colors of the Hue bulb, which I am calling party mode image

 

<i will post a short video of the setup over the weekend>

 

To create a new recipe to send sensor values from the the Edison via an email when the python program below is triggered, click the new applet button and follow the steps as shown in the screenshots below

{gallery} IFTTT recipe to send email

image

Once you click the New Applet button , click the + this link

image

As part of the service on the IF side select the Maker Webhooks channel

image

Type in the event name - from_edision and hit Create trigger, this will be refrenced in the python code

image

Now select the +that section

image

As part of the That action seach for Gmail

image

Fill in the details for email, here the Value1, Value2 and Value3 are part of the payload section in the python code.

image

Once done hit the review and finish button.

 

 

 

Here is the python program to trigger the IF side of things aka the Maker webhooks,

 

#!/usr/bin/python
# Create by Carmelito to send sensor data to IFTTT so that you work your magic,this is based on
# Grove Light sensor https://github.com/intel-iot-devkit/upm/blob/master/examples/python/grovelight.py
# Grove Temp https://github.com/intel-iot-devkit/upm/blob/master/examples/python/grovetemp.py
# Grove Pot https://github.com/intel-iot-devkit/upm/blob/master/examples/python/groverotary.py
import requests
from time import sleep
from upm import pyupm_grove as grove

#get the api key from Maker Webhooks channel https://ifttt.com/services/maker_webhooks/settings
#example URL https://maker.ifttt.com/use/xxxxxxxxxxxxxxxxxxxxx
api_key = 'xxxxxxxxxxxxxxxxxxxxx'
event = 'from_edison'
#Grove Pot connected to connected A0 on the Grove shield
potSensor= grove.GroveRotary(0)
#Grove Temperature sensor connected A1
tempSensor = grove.GroveTemp(1)
#Grove Light sensor connected A2
lightSensor = grove.GroveLight(2)

def send_IFTTT_event(api_key, event, temp=None, lightValue=None, potValue= None):
    #posting data to IFTTT
    url = "https://maker.ifttt.com/trigger/{e}/with/key/{k}/".format(e=event,k=api_key)
    payload = {'value1': temp, 'value2': lightValue, 'value3': potValue}
    try:
        requests.post(url, data=payload)
    except requests.exceptions.RequestException as resp:
        print("Error from IFTTT: {e}".format(e=resp))

def main():
    temp = '0'
    lightValue = '00'
    #Getting Pot value
    potValue = potSensor.abs_value()
    print("Pot value: " + str(abs))
    sleep(1)
    #Getting grove temperature value
    print(tempSensor.name())
    for i in range(0, 10):
        celsius = tempSensor.value()
        fahrenheit = celsius * 9.0/5.0 + 32.0;
        print("%d degrees Celsius, or %d degrees Fahrenheit" \
                 % (celsius, fahrenheit))
    temp = fahrenheit
    #Getting light sensor value
    print(lightSensor.name() + " raw value is %d" % lightSensor.raw_value() + \
    ", which is roughly %d" % lightSensor.value() + " lux");
    lightValue = lightSensor.raw_value()
    sleep(1)

    send_IFTTT_event(api_key, event, temp, lightValue, potValue)

if __name__ == "__main__":
    main()

 

As part of the code replace the api_key with your key, which you will find at  https://ifttt.com/services/maker_webhooks/settings

 

image

Here is the sample email recived once the program run

image

 

On the similar lines, you can setup more recipes on IFTTT to trigger as shown in the screenshot below. For the Hue setup you will have to register your Hue bridge online or via the Phillips hue app on your phone.

 

{gallery} More IFTTT recipies

image

Recipe setup to send text messages

image

Sample Text message recived with temperature and light reading from Edsion

image

Recipe to turn on your Hue lamp, for this you will have to select Hue on the Then side of the recipe

image

Recipe for the Hue Color bulb to change the color of the bulb slowly, setting up party mode, for this you will need a Hue Color bulb.

image

Lamp on top of the side table has the Color Hue bulb which cycles through the colors. And the lamp on the floor has the white bulb.

  • Sign in to reply

Top Comments

  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder +3
    In this guide, they show you how to pull data out of elements of a web page. You can also use IFTTT in Node-Red: http://flows.nodered.org/node/node-red-contrib-ifttt
  • gpolder
    gpolder over 8 years ago +2
    great post, I also was thinking of using IFTTT, but dataflow is opposite to your application. Some information on the web (weather, blog likes, etc.) needs to be sent to my edison in order to be displayed…
  • jasonwier92
    jasonwier92 over 8 years ago +2
    Great write up and introduction to IFTTT. I am sure you know this and I am looking to inform others about IFTTT uses. IFTTT is not for real time events. Scheduled events are great, but if you want to flip…
  • carmelito
    carmelito over 8 years ago in reply to jasonwier92

    Thanks jasonwier92 for the link, look like I am going to have to give Node-Red a shot soon, I see a lot of folks are using it..

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 8 years ago

    As one of the sub-terrarium inhabitants, I was aware that services like IFTTT existed, but I have not seen them used.

     

    So I will be following your progress with interest.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    In this guide, they show you how to pull data out of elements of a web page. You can also use IFTTT in Node-Red:

    http://flows.nodered.org/node/node-red-contrib-ifttt

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago in reply to jasonwier92

    Here's a how to:

     

    How to use the Image Gallery

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago

    Great write up and introduction to IFTTT.  I am sure you know this and I am looking to inform others about IFTTT uses.  IFTTT is not for real time events.  Scheduled events are great, but if you want to flip a switch and have a light come on, then IFTTT is not for you.  There will be a lag that is very noticeable.  For what you are using it for and what gpolder mentioned to use it for, it is great.  Every tool has a function it does well and you have shown IFTTT use well.

     

    Also I like the slide shows.  Time to step up the game, because that looks very nice and cuts down on the scrolling for your posts takes for the information conveyed.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube