Introduction: Mood Lamp Based on Twitter Hashtags

About: Sitecore/.Net developer by day, IOT developer by night.

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 - where
      • IP( you can get making a "ping" 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

Internet of Things Contest 2017

Participated in the
Internet of Things Contest 2017