Control LEDs With Alexa or IFTTT (SINRIC PRO TUTORIAL)

Introduction: Control LEDs With Alexa or IFTTT (SINRIC PRO TUTORIAL)

So you'd like to be that person who shows off during a mundane dinner by saying "Alexa turns on the light?" This project is for you!

At the end of this instructables you will be able to control a RGB strip with an Alexa device and IFTTT to create some automations. For example, when the ISS "flies" above my apartment the LEDs blink 😬.

Well, let's go ?

Step 1: What Do We Need?

The part list is going to be quite simple but I will split it in two parts, the basics tools that you need if you want to do the project and you start with nothing, and the more specifics parts.

Also out of a concern for honesty, all links are affiliate which means I get a small commission if you buy a product through my link. This is ABSOLUTELY NOT an obligation to use this links, it just help me to create and build others projects and it isn't more expensive for you. πŸ˜‰

πŸ”ŒBASIC PARTS:

- Iron soldering: link

- Tin: link

- Circuit Board: link

- Shrinking tubes: link

- Wires: link

- Breadboard: link

- Breadboard wires: link

πŸ’‘ PROJECT PARTS:

- ESP8266: link

- Capacitors: link

- RGB strip: link

- logic level converter: link

- 12V power supply: link

- Stepdown converter 12V -> 5V: link

Be careful with the power supply you take according to the length of your LED strip, it could destroy your electronics.

You can get an idea of how much power you need with the following formula:
Each pixel is composed by three LEDs (Red, Green and Blue) and each LED draws about 0.02A

Amps = 3 * 0.02 * NUMBER_OF_LEDs
So in our case with a 60 pixels/meter and 3 meter strip we get: 3 * 0.02 * 3 * 60 = 10.8 Amps

But you get 10.8 Amps if each pixels has R, G and B at full brightness. If you have an under-sized power supply and you don't want to buy a new one, you can also reduce the max brightness in the code but we will see later.

Step 2: Let's Place Everything on a Breadboard

As for every electronics project, you should try everything on a testing breadboard before soldering, it takes more time but at least you don't end up in your bed crying because it doesn't work. Believe me, I've tested it a few times. πŸ˜‡

So le'ts assemble everything on the breadboard:

  1. Place the ESP8266 on your breadboard. Connect the VIN of the ESP to the power rail on the breadboard, do the same for the GND of the ESP. Connect the 3V3 to the other side and run a wire between the GND rails.

    Please refer to picture 1

  2. Place the logic level converter on your breadboard. We need a logic level converter because the ESP8266 sends 3V3 logic levels and the LEDs need a 5V logic level, so we have to convert those logics levels unless we will have unpredictable issues.

    Connect the 5V, the 3V3 and the GND to their respective rails.
    Connect a wire between the 5V side of the level converter and the DATA line of the LED strip.
    Connect a wire between the 3V3 side of the level converter and the D6 pin of the ESP8266

    Please refer to picture 2

  3. Connect the 5V and GND of the LED strip to their respective rails on the breadboard.
    Connect the DIN PIN of the strip to the 5V side of the logic level converter.
    Place a 470 ΞΌF capacitor between the 5V and the GND of the LED strip, it will help prevent the initial onrush of current from damaging the LEDs.

    Please refer to picture 3

  4. Connect the 12 V and the GND of the power supply to the input of the step down converter.

    Please refer to picture 4

  5. Connect the 5V output and the GND of the stepdown converter to the corresponding lines on your breadboard.

    Please refer to picture 5

Well, everything should be wired now πŸ˜€ Congrats!
Now we will do some code testing to see if our electronics is working fine!

Step 3: Blink a LED

WOOOW sounds cool right? no I know this is not what you expected but it will confirm that our system is working which is cool!

We will have to install a board and a library to make that LED blink.

  1. Launch your Arduino IDE, go to preferences, paste this link http://arduino.esp8266.com/stable/package_esp8266com_index.json into Add Board Manager URLs and click OK.

    Please refer to screenshot 1.

    Go to Tools > Board > Board Manager and look for esp8266. Install it.

    Please refer to screenshot 2.

    Go to Tools > Board and select NODEMCU 1.0 (ESP 12E Module)

    Please refer to screenshot 3.
  2. Go to Tools > Manage Libraries and look for FASTLED. Install it.

    Please refer to screenshot 4.
  3. Now download the blinking code on my GitHub blinking file and upload it on the ESP.

It should work !

If you have a color inversion, it could be because of the GRB parameter inside the FastLED.addLeds function, change GRB by RGB.

If it still doesn't work, verify your wiring twice and retry!

Now that the electronics are working you can solder everything in place on a circuit board πŸ’‘.

Step 4: Setup Sinric

Now that we have a working system, we can setup Sinric which create a bridge between our LED strip and Alexa or IFTTT.

  1. Register on Sinric

  2. Pairing Alexa:

    - Open your Amazon Alexa App

    - Go to skills & Games

    - Search for Sinric Pro

    - Click ENABLE TO USE

    - Enter the credentials you created when you registered on Sinric.


  3. Create a new device:

    - Login to your Sinric Pro account on a web-browser

    - Go to devices menu on your left

    - Click Add Device button

    - Enter the device name that you want for your LED strip, a description if you want one and select type as Smart Light Bulb

    - Select Device Acces Key as default and Living Room. You can add rooms if you want in the "Room" section on the left.

    - Hit Save. You should receive a notification on your Alexa App proposing you to add the device you've created.

  4. Upload the code on the ESP8266:

    - In the Arduino IDE, go to Tools > Manage libraries > look for Sinric Pro and install it.

    - Download the arduino code on the Sinric Github: link

    - Enter your WiFi credentials

    - Enter your API KEY and your KEY_SECRET. Go to Sinric Pro > Credentials (menu on the left) and copy them.

    - Enter your device ID. Go to Sinric Pro > Devices (menu on the left) and copy your device ID.

    - Modify NUM_LEDS which the number of LEDs on your strip and LED_PIN which is the pin on your ESP (should be 6).

    - In the Arduino IDE, select Tools > Board > NODEMCU 1.0 (ESP 12E Module) and hit Upload.


Ok, NOW SAY MY NAME. No say something to Alexa, like "Alexa, turn on the light" or "Alexa, change the light in blue" and it should light up! If not got to the troubleshooting page at the end of this instructables.

You can also control the strip directly in the Alexa App or on Sinric Pro (there are Android and iOS apps too).

ENJOY RGB β€οΈπŸ’šπŸ’™

Step 5: Setup IFTTT

Now we can connect IFTTT to Sinric!

  1. Go to Sinric Pro > Credentials (menu on the left) and click on New API key.
  2. Go to IFTTT.com and create a new applet. Select the trigger you want for the IF and for the THEN, search Webhook.

    In the URL part, paste :https://ifttt.sinric.pro/v1/actions

    Select the POST method.

    Select application/json for the Content Type

    In body, paste:

{
"api_key":"API_KEY",
"device_id":"DEVICE_ID",
"action":"setColor",
"value": {
"color": {

"b": 255,
"g": 0,

"r": 0 }
} }

Please refer to screenshot 1.

Webhook will send a JSON file to SINRIC with the following variables.

Enter the API KEY you just created, Add the device_id of you led strip
You can choose between different functions like SetColor or SePowerState for turning on and off the strip

Step 6: Troubleshooting

I hope this part will remain empty 😬 but if needed I'll add some content.

Be the First to Share

    Recommendations

    • Metal Contest

      Metal Contest
    • Backyard Contest

      Backyard Contest
    • First Time Author Contest

      First Time Author Contest

    Comments