Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Seafox_C
Published © GPL3+

Connect Alexa to Any Arduino with Broadlink IR

Two years ago I searched for a way to connect my Arduino with my Alexa and came up with this simple solution.

BeginnerFull instructions provided1 hour2,330

Things used in this project

Hardware components

Alexa echo Dot
×1
Broadlink RM mini
Here is the Amazon link: https://amzn.to/3fGsH08
×1
Arduino Nano
×1
IR receiver diode (generic)
The Amozon link: https://amzn.to/3hMmeT7
×1

Software apps and online services

Arduino IDE
Arduino IDE
Broadlink IHC app
Alexa Voice Service
Amazon Alexa Alexa Voice Service

Story

Read more

Schematics

Schematics with Arduino Nano

Code

Arduino_Alexa_GooleHome IR sketch template

C/C++
// A hacky way to use a smart remote to control your Arduino remotly with Alexa. 

// Adding addition signals
// To add additional signals go to the broadlink app and pick any TV brand. Then test the remote in the app by pressing the on/off button. 
// Connect your Arduino to your pc and read out the serial monitor. You should receive the code. Test if the code is not used previously in the program.
// Test the code a couple of times to make sure it is always the same code (some signals are more complex and should not be used for this). 
// If you have an new code you want to use copy the code of the last signal and input your signal. 


// Import library. To install this make sure you are connected to the internet and in press Ctr+shift+i.
// Then you search for the library in the searbox 'IRremote' Install the one by Sherriff and press install.
#include <IRremote.h>

const int RECV_PIN = 7; // The pin you connected the IR receiver with. This must be a pin with PWM.
IRrecv irrecv(RECV_PIN);
decode_results results;


void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true); // This makes the LED blink when receiving an IR command. 
}

void loop(){
  if (irrecv.decode(&results)){
       Serial.println(results.value, HEX);


  if (results.value == 0xC)
{
      Serial.println("Seafox 1 = signal C");
        
      // put your code to do the action you want to do here. 
           
  }


  if (results.value == 0xA90)
{
      Serial.println("Seafox 2 = signal A90");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0xFFE21D)
{
      Serial.println("Seafox 3 = signal FFE21D");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0x80c)
{
      Serial.println("Seafox 4 = signal 80c");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0x7070D02F)
{
      Serial.println("Seafox 5 = signal 7070D02F");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0xFF629D)
{
      Serial.println("Seafox 6 = signal FF629D");
        
      // put your code to do the action you want to do here. 
           
  }



  if (results.value == 0xFB030D00)
{
      Serial.println("Seafox 7 = signal FB030D00");
        
      // put your code to do the action you want to do here. 
           
  }

   if (results.value == 0x8D1F6BD6)
{
      Serial.println("Seafox 8 = signal 8D1F6BD6");
        
      // put your code to do the action you want to do here. 
           
  }


   if (results.value == 0x84c)
{
      Serial.println("Seafox 9 = signal 84c");
        
      // put your code to do the action you want to do here. 
           
  }


   if (results.value == 0x1010F00F)
{
      Serial.println("Seafox 10 = signal 1010F00F");
        
      // put your code to do the action you want to do here. 
           
  }



delay(500);  
irrecv.resume();
        
  }




}

Arduino IR Alexa file used as demo in video with two servo motors

C/C++
// A hacky way to use a smart remote to control your Arduino remotly with Alexa. 



// Import library. To install this make sure you are connected to the internet and in press Ctr+shift+i.
// Then you search for the library in the searbox 'IRremote' Install the one by Sherriff and press install.
#include <IRremote.h>
#include <Servo.h>

int Servo1 = 3;  //PWM pin that is connected to the servo_1
int Servo2 = 5;  //PWM pin that is connected to the servo_2
const int RECV_PIN = 10; // The pin you connected the IR receiver with. This must be a pin with PWM.
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo demoServo;        //create a servo object


void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true); // This makes the LED blink when receiving an IR command. 
  

}

void loop(){
  
if (irrecv.decode(&results)){
       Serial.println(results.value, HEX);


// Why I attach and detach the pins is because I had troubles with my Arduino Mini and the siganel of the servo. 
// When I don't use the detach the signal of the servomotor would be interpeted as IR codes and caused errors when reading IR codes.

  if (results.value == 0xC)
{
      demoServo.attach(Servo1);
      Serial.println("Seafox 1 = signal C");
      demoServo.write(180);
      Serial.println("servo 180");
      delay(4000);
      Serial.println("end of delay");
      demoServo.write(60); 
      Serial.println("servo 60");
      delay(100);
      demoServo.detach();

           
  }


  if (results.value == 0xA90)
{
      demoServo.attach(Servo2);
      Serial.println("Seafox 2 = signal A90");
      demoServo.write(180);
      Serial.println("servo 180");
      delay(10000);
      Serial.println("end of delay");
      demoServo.write(60); 
      Serial.println("servo 60");
      delay(100);
      demoServo.detach();
           
  }

  if (results.value == 0xFFE21D)
{
      Serial.println("Seafox 3 = signal FFE21D");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0x80c)
{
      Serial.println("Seafox 4 = signal 80c");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0x7070D02F)
{
      Serial.println("Seafox 5 = signal 7070D02F");
        
      // put your code to do the action you want to do here. 
           
  }

  if (results.value == 0xFF629D)
{
      Serial.println("Seafox 6 = signal FF629D");
        
      // put your code to do the action you want to do here. 
           
  }



  if (results.value == 0xFB030D00)
{
      Serial.println("Seafox 7 = signal FB030D00");
        
      // put your code to do the action you want to do here. 
           
  }

   if (results.value == 0x8D1F6BD6)
{
      Serial.println("Seafox 8 = signal 8D1F6BD6");
        
      // put your code to do the action you want to do here. 
           
  }


   if (results.value == 0x84c)
{
      Serial.println("Seafox 9 = signal 84c");
        
      // put your code to do the action you want to do here. 
           
  }


   if (results.value == 0x1010F00F)
{
      Serial.println("Seafox 10 = signal 1010F00F");
        
      // put your code to do the action you want to do here. 
           
  }

delay(100);
irrecv.resume();
        
  }



}

Credits

Seafox_C
10 projects • 49 followers
I'm 29 years old and live in Belgium. I love the Arduino community and like to learn and make projects.

Comments