Introduction: Mood Lamp Based on Twitter Hashtags

I decided that i want to make a Mood Lamp based on twitter hashtags, i`ve seen similar projects here, but this time i made one using Wemos D1 + Blynk + IFTTT.

This project does not contain enterprise level code, so feel free to do some refactoring. :) Also, IFTTT have a delay of 30sec to ~5min after tweet has posted.

Step 1: Material

In this tutorial the following things are necessary:

  • Wemos D1 mini
  • Wemos RGB shield
  • Usb cable to power and program Wemos D1 mini
  • Random lamp

The advantage of using Wemos D1 mini is it`s size, and since this project is easy one, we don`t need as much analog/digital pins as in e.g Arduino UNO. Advantage of using Wemos RGB shield is that we don`t need to use any jumper wires or make our own PCB`s, we can just place it on top of the D1 mini and we are ready to go.

Step 2: Blynk

For getting started with Blynk, go to Blynk official site - Blynk - getting started.

To set up Blynk project:

  • Create new project and give a name to it.
  • Choose a wifi module from list of them. Wemos D1 have integrated ESP8266 wifi module.
  • You will see app id, keep that in mind because we will use it later.
  • Add new button to your project, choose a virtual pin and name it after color of your choice.

That`s it for Blynk set up.

Step 3: IFTTT(If This Then That)

We will use IFTTT(If This Then That) service to trigger every new tweet by specific hashtag, and to make PUT request to Blynk app that will turn on specific color.

To set up your IFTTT account and get started, go to IFTTT official site - IFTTT.

To set up first trigger:

  • Search for "twitter" and select Twitter service.
  • Select "New tweet from search" action.
  • Enter some hashtag e.g - #angry in "Search for" input box and click "Create trigger".
  • Press "THEN" and search for "webhooks".
  • Select "Maker Webhooks" service and choose the only action it has.
  • Fill out required data as follows:
    • URL e.g - http://139.59.206.133/1a6cb5d9b000000000000000661bb2d5c1/pin/V1 where
      • IP(139.59.206.133) you can get making a "ping cloud.blynk.cc" request using cmd(command prompt)
      • "1a6cb5d9b000000000000000661bb2d5c1" this should be your Blynk project id(app id).
      • "V1" is virtual pin 1 which we defined in our Blynk app.
    • Method - PUT
    • Content type - application/json
    • Body - ["1"]. 1 means button state is ON, 0 Means button if turned off.
  • Press "Create action".

Do this for all virtual pins you have defined in Blynk app.

Step 4: Code

The code is not robust at all, and if you take a look in reference links below, you will be able to understand what it does. In this example we will use NeoPixel library to control colors of the LED, but it is not required, you can simply call e.g - setColor(255, 0, 0); // red. For wifi connection we will use WiFiManager library, because it gives us ability to connect to whatever wifi we want, and we don`t have to hard code our wifi credentials in code. Blynk library we use for ability to communicate with Blynk app, and ESP8266 library is ESP8266 shield that is integrated in Wemos D1.

For this sample to work, make sure you add your Blynk app id to the code.

References to the libraries used:

Blynk - Blynk

Wifi Manager - WiFiManager

Neopixel - Adafruit NeoPixel

ESP8266 wifi shield - ESP8266

Comments

author
tittiamo68 (author)2017-06-10

Very nice and useful project

voted

author
KristiānsV (author)tittiamo682017-06-10

Thanks :)

author
Swansong (author)2017-06-06

That's a fun idea :)

About This Instructable

524views

16favorites

License:

Bio: Sitecore/.Net developer by day, IOT developer by night.
More by KristiānsV:Mood Lamp Based on Twitter Hashtags
Add instructable to: