Simple way to integrate Twitter to your projects using Photon and IFTTT

The folks at Particle (erstwhile Spark) are awesome – they make great IoT products and are really super nice people. They gifted Omkar a Photon at the MakerFaire. His summer break just started and this was his priority #1.

Omkar wanted a way to know when someone mentions or follows @IoT4Kids. Particle makes this incredibly easy to do with just a few lines of code. You essentially can make any action happen (light up or move something and/or make some noise) based on Twitter activity using their Arduino compatible WiFi integrated micro-controller and their integration with IFTTT.

This simple example lights up an LED.

BTW, the display box is 3D printed using Printrbot Simple which is another awesome product for kids to get started with 3D printing.

This is all made so easy with the Particle Spark.Function() that is triggered ‘automagically’ 🙂 from IFTTT. All you need is the code below and create a recipe with Twitter trigger and Particle action.


int ledpin = D7;
void setup()
{
// register the cloud function
Spark.function("tweet", twittermessage);
pinMode(ledpin, OUTPUT);

}

void loop()
{
delay(5000);
digitalWrite(ledpin, LOW);
delay(5000);
}

// this function automagically gets called upon a tweet mention
int twittermessage(String ignore)
{
digitalWrite(ledpin, HIGH);
return(0);
}

Here is a more fun example of this by Brian Sherwin. He also has an example of making this with your own node.js application to make the action trigger immediately instead of the 15 min cycle on IFTTT.

So folks, if you liked this please follow or mention @IoT4Kids and light up Omkar’s day. :).

Real-time goal alert – littleBits cloudBit, IFTTT, Arduino

littleBits just launched their cloudBit product. This is Omkar’s first true IoT project that takes data from the cloud to activate something local. In this case, taking goal alerts from a twitter feed to light up LEDs whenever a goal is scored. littleBits cloudBit is truly the easiest way for anyone to make a internet of things project.

The cloudBit works with IFTTT (If This Then That), a cloud service for making ‘Recipes’ to trigger actions based on events. Essentially, you create a Recipe on IFTTT using the the littleBits ‘Channel’ and you have a means to send a signal to the cloudBit based on an event defined in the Recipe.

We had to do a bit of a hack to make this work in real-time as soon as a goal is scored. Most IFTTT recipes don’t trigger in real-time (it usually triggers in 15 minute cycles) except a few. One of the real-time ones is the Email recipe. So for this project we used a work around in order to trigger cloudBit via the Email recipe on IFTTT as illustrated in the video below.

This could be done more simply by writing a web app as well. However, for this project we’ve tried to make it work without any web coding. Some Arduino programming is used to show a more meaningful alert on the device with sounds (though it is not essential to do any coding to make something similar).

Notes and acknowledgements:

  • Thanks to littleBits for choosing us for a early Beta trial of the cloudBit. This project was done during the Worldcup. But we couldn’t publish it before the launch of the cloudBit product.
  • Thanks to  Andy Jiang who created a twitter feed of Worldcup goal alerts that we were able to use as data feed for this project.
  • The goals and alerts shown in the videos are live alerts recording during live game broadcasts.
  • The first video shows a version of this project with the Adafruit Neopixel strip.
  • The project details are available on the littleBits project page.