Welcome to my living room (IR + 433MHz + RGB LED stips)


#1

About This Project

###Welcome to my living room!

This project explains how to monitor devices in your home. This Arduino project is an All in One project with several wireless technologies:

  • Infrared
  • RF 433 MHz

to control several devices:

  • TV
  • Living room lamps
  • Bedroom lamp
  • RGB LED strips
  • Raspberry pi
  • … or all your devices based on IR or RF wireless technologie

It’s thus easy to manage your TV or other IR device, lamps in your home (not only in the living room :)) plugged to 433MHz power outlet and LED strip colors.

I created this project because it was very complicated to manage several remotes controls types

  • IR remote controls
  • 433MHz Chacon remote control
  • 433MHz Etekcity remote control

and I couldn’t create events / triggers without Cayenne features :wink:

###Control all your devices with wireless technologies

| 433MHz power outlet | Room | Devices
| Etekcity 1 | Living room | Projector light
| Etekcity 2 | Living room | Circle LED light
| Etekcity 4 | Living room | Samsung TV
| Chacon 2 | Living room | Raspberry pi
| Chacon 4 | Kitchen | Light
| Chacon 3 | Bed room | Light
| Etekcity 3 | Entrance | LED garland

| IR remote control | Room | Devices
| TV | Living room | Samsung TV remote
| Speaker | Living room | Sony speaker remote
| Circle LED light | Living room | Circle LED light remote

| LED strips | Room | Devices
| TV strip | Living room | Horizontal LED strip
| Furniture strip | Living room | Vertical LED strip

Cayenne replaces all remote controls !

Now my living room is fully connected.

###Demo

What’s Connected

  • 2 x RGB 5050 LED Strips
  • 433MHz power outlet (Chacon & Zap)
  • 433MHz transmitter
  • 1 x IR LED
  • Arduino Ethernet shield or
  • Wemos D1 Wifi (based on esp8266) or
  • Arduino wifi esp8266 module
  • 1 x 9V / 12V external power supply
  • Wago connectors
  • 2 x ULN2803

I made this Iot project with 1 breadboard to minimize space. It’s not perfect yet but I optimized as much as possible the space.

My sketch is fully compatible with

  • Arduino Ethernet shield
  • Wemos D1 Wifi based on esp8266

I prefer to use Wemos D1 to have a wireless connection to Cayenne because my internet box is on the other side of my living room and I don’t want to pull RJ45 cables in my home.

The project is transportable, the whole is on a breadboard (arduino board plugged with elastic + all required components)

Triggers & Alerts

It’s easy to create interaction between your device with Cayenne features.

  • If I turn on my TV, Then I turn on TV LED strip
  • If I turn off my TV, Then I turn off TV LED strip

Scheduling

It’s easy to create automations with Cayenne features.

  • Turn on the light in my bedroom automatically at 7:00 am
  • Turn on the light in my living room automatically at 7:10 am
  • Turn off the light in my living room automatically at 9:00 am
  • Turn on the light in my living room automatically at 8:00 pm

With Cayenne buttons:

  • Good night dashboard button to turn all (IR + 433MHz + LED strips) OFF
  • Good morning dashboard button to turn all (IR + 433MHz + LED strips) ON
  • Ambiance 1 button to turn 1 lamp + 1 LED Strip ON
  • Ambiance 2 button to turn 2 lamps + 2 LED Strips + Sony speaker ON
  • Ambiance 3 button to turn 4 lamps + 2 LED Strips + Samsung TV ON

Dashboard Screenshots

Photos of the Project

Video

There are several scripts in this video:

  • Turn on / off specific device.
  • Turn on / off all devices. (Good night button: Great feature before going to bed :))
  • Turn on / off several devices with scenario.
  • Change LED strips colors and Circle LED strip light.
  • Run Cayenne triggers (example: if I turn on tv, the TV LED strip automatically turn on…)

Watch my video & turn up the sound to hear action clicks (I hope you like dogs :wink: ):

Alt Video

Documentation

Readme, Sketch, Wiring and more on my GitHub https://github.com/ibenot/Arduino/tree/master/TP6_RGB_LED_strips_433MHz_Cayenne

Send me your feedback or comments
Follow me on Twitter: https://twitter.com/ibenot

07 April Update:

I just updated my project to make it fully compatible with official Arduino board. Please read my comment here.


The Judges Have Spoken! ~CONTEST RESULTS~
#2

I think you should use an Arduino brand board to take part in this contest.


#3

Ouch! If needed, I can use my (official) Arduino board + Ethernet shield for this project :slight_smile: Same board used for the FlowerDuino project.

It’s the only way because I don’t have other Arduino board :frowning:
It’s just much more transportable / easy to plug / smaller with Wifi connection but it’s not mandatory. It’s also working with Arduino + Ethernet shield.

To configure wifi or ethernet, please select the right library:

//wifi
include "CayenneWiFiClient.h"

or

//ethernet
include "CayenneEthernet.h"

This is the only way for me to run FlowerDuino (ethernet connection) and this project (wifi connection) at the same time in my living room.

What’s the best way to have wifi on Arduino board ? Could you advise me an ethernet shield ?

Don’t hesitate to tell me if I have to update my project / code / photos with my Arduino + Ethernet shield to take part in this contest.

Ben


#4

Well, I’m sorry for your problem, but as the contest is with parternship with arduino, I suppose that you should use an official Arduino board, you can read all the contest guidelines [here] (Automation Around the Home - Contest Guidelines)

If you want to make a wifi based project try Arduino MKR1000


#5

Thanks for your reply I will update my project and read more about your arduino wifi board. It seems to be an expensive solution… that why I bought wemos d1 :wink:


#6

Well… I know it is expensive… I recommended you that board because I though you would use it for the contest, however there is another solution (but not arduino offcial) sooo cheap, its the NodeMcu Lua ESP8266 CP2102 ,it’s about 2$ :heart_eyes: . It’s definetly my favourite wifi board :smiley:


#7

Thank you so much for your explanations! I will try it for other projects :grinning:


#8

Hi guys!

I just updated my project to make it fully compatible with Arduino board. I was forced to make many changes, especially because of the PWM pins in my Arduino UNO + Ethernet shield. It was not easy but it working :wink:

After reading a thousand times Arduino documentation about analogWrite & PWM, I was forced to update my sketch + wiring. (I’m web developer and I have some knowledge in electrical but I need to improve my wiring skills because It’s still the beginning for me in Arduino world. My best friend offered me a Arduino Starter kit for my birthday only 4 months ago… :gift: :heart_eyes:

It would be easier if I had Arduino Mega because it has more available PWM pins but I didn’t buy this kind of Arduino board yet. Bad choice for me :frowning:

Fist of all, I had to connect my RGB LED strips together. It allows me to get more PWM pins to plug my hardware:

  • 1 x 433MHz transmitter
  • 1 x IR LED
  • 1 x ULN2803 (instead of 2)

Then, I had to update IRremoteInt.h (from IRremote library) to force to use another Timer with PWM Pin #9 instead of PWM Pin #3. (Because my PWM Pin #3 is already used by RGB LED strips)

// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
#else
	#define IR_USE_TIMER1   	// tx = pin 9
	//#define IR_USE_TIMER2    // tx = pin 3
#endif

Then, I plugged:

  • LED strip Blue to PWM pin 3
  • LED strip Red to PWM pin 5
  • LED strip Green to PWM pin 6
  • IR LED to PWM pin 9
  • 433MHz transmitter to PWM pin 10

Then, I had to update my sketch:

#define CAYENNE_PRINT Serial  

#include "CayenneDefines.h"
#include "RCSwitch.h"
#include "IRremote.h"
#include "CayenneEthernet.h"

char token[] = "XXXXXXXXXX";        //your Cayenne token

int loadingTimeChaconZap = 20000;   //enable 433MHz 20 seconds after board boot

#define VIRTUAL_PIN_0 V0    //uptime
#define VIRTUAL_PIN_6 V6    //led R
#define VIRTUAL_PIN_7 V7    //led V
#define VIRTUAL_PIN_8 V8    //led B
//Chacon
#define VIRTUAL_PIN_9 V9    //Chacon2
#define VIRTUAL_PIN_10 V10  //Chacon3
#define VIRTUAL_PIN_11 V11  //Chacon4
//Zap
#define VIRTUAL_PIN_12 V12  //Zap1
#define VIRTUAL_PIN_13 V13  //Zap2
#define VIRTUAL_PIN_14 V14  //Zap3
#define VIRTUAL_PIN_15 V15  //Zap4
//All 
#define VIRTUAL_PIN_16 V16  //turn on/off all Chacon + Zap
#define VIRTUAL_PIN_17 V17  //turn on/off all Zap
#define VIRTUAL_PIN_18 V18  //turn on/off all Chacon
//IR LED lamp
#define VIRTUAL_PIN_23 V23  //IR LED lamp

//433MHz
RCSwitch mySwitch = RCSwitch();
int transmit_pin = 10;
int pulseLength = 185;       
int repeatTransmit = 5;
int transmitterDelay = 100;  //Delay between 433 transmitter actions

//RGB LED strip
int LED_STRIP_2_BLUE  = 3;
int LED_STRIP_2_RED   = 5;
int LED_STRIP_2_GREEN = 6;

//IR
IRsend irsend;

void setup()
{
  //Serial
  Serial.begin(9600);
  
  //Init LED
  pinMode(LED_STRIP_2_RED, OUTPUT);
  pinMode(LED_STRIP_2_GREEN, OUTPUT);
  pinMode(LED_STRIP_2_BLUE, OUTPUT);
  
  //433MHz Transmitter
  mySwitch.enableTransmit(transmit_pin); 
  mySwitch.setPulseLength(pulseLength);
  mySwitch.setRepeatTransmit(repeatTransmit);

  //LED strip is green
  analogWrite(LED_STRIP_2_RED, 0); 
  analogWrite(LED_STRIP_2_GREEN, 255); 
  analogWrite(LED_STRIP_2_BLUE, 0);

  //Cayenne
  Cayenne.begin(token);
}

void loop()
{
  Cayenne.run();  
}

//Uptime
CAYENNE_OUT(VIRTUAL_PIN_0){ 
  int uptime = millis() / 1000;
  Cayenne.virtualWrite(VIRTUAL_PIN_0, uptime); 
}

//Led RED
CAYENNE_IN(VIRTUAL_PIN_6)
{
  if(millis() > loadingTimeChaconZap){
    float currentValue = getValue.asDouble();
    currentValue = currentValue / 1023;
    int led2RED = currentValue;  
    setLED2Red(led2RED);  // custom red
  }
}

//Led GREEN
CAYENNE_IN(VIRTUAL_PIN_7)
{
  if(millis() > loadingTimeChaconZap){
    float currentValue = getValue.asDouble();
    currentValue = currentValue / 1023;
    int led2GREEN = currentValue;  
    setLED2Green(led2GREEN);
  }
}

//Led BLUE
CAYENNE_IN(VIRTUAL_PIN_8)
{
  if(millis() > loadingTimeChaconZap){
    float currentValue = getValue.asDouble();
    currentValue = currentValue / 1023;
    int led2BLUE = currentValue;  
    setLED2Blue(led2BLUE);
  }
}

//Chacon 2 on/off
CAYENNE_IN(VIRTUAL_PIN_9)
{
  if(millis() > loadingTimeChaconZap){
    int currentValue = getValue.asInt(); // 0 to 1
    if(currentValue == 1){
      chacon2_on();
    }
    else{
      chacon2_off();
    }
  }
}

//Chacon 3 on/off
CAYENNE_IN(VIRTUAL_PIN_10)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      chacon3_on();
    }
    else{
      chacon3_off();
    }
  }
}

//Chacon 4 on/off
CAYENNE_IN(VIRTUAL_PIN_11)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      chacon4_on();
    }
    else{
      chacon4_off();
    }
  }
}

//Zap 1 on/off
CAYENNE_IN(VIRTUAL_PIN_12)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      zap1_on();
    }
    else{
      zap1_off();
    }
  }
}

//Zap 2 on/off
CAYENNE_IN(VIRTUAL_PIN_13)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      zap2_on();
    }
    else{
      zap2_off();
    }
  }
}

//Zap 3 on/off
CAYENNE_IN(VIRTUAL_PIN_14)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      zap3_on();
    }
    else{
      zap3_off();
    }
  }
}

//Zap 4 on/off
CAYENNE_IN(VIRTUAL_PIN_15)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      zap4_on();
    }
    else{
      zap4_off();
    }
  }
}

//turn on/off all
CAYENNE_IN(VIRTUAL_PIN_16)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      turn_on_all();
    }
    else{
      turn_off_all();
    }
  }
}

//turn on/off Zaps
CAYENNE_IN(VIRTUAL_PIN_17)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      zap_on();
    }
    else{
      zap_off();
    }
  }
}

//turn on/off Chacons
CAYENNE_IN(VIRTUAL_PIN_18)
{
  if(millis() > loadingTimeChaconZap){
    if(getValue.asInt() == 1){
      chacon_on();
    }
    else{
      chacon_off();
    }
  }
}

//IR Slider
CAYENNE_IN(VIRTUAL_PIN_23) { 
  if(millis() > loadingTimeChaconZap){
    
    float currentValue = getValue.asDouble();
    currentValue = currentValue / 1023;
    
    if(currentValue == 85){
      irsend.sendNEC(0xFF1AE5, 32); 
      Serial.println("Circle is RED");
    }
    if(currentValue == 170){
      irsend.sendNEC(0xFF9A65, 32);
      Serial.println("Circle is GREEN"); 
    }
    if(currentValue == 255){
      irsend.sendNEC(0xFFA25D, 32); 
      Serial.println("Circle is BLUE");
    }
  }
}

//Set LED strip custom RVB color by strip id
void setColorLED(int red, int green, int blue, int strip)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
    green = 255 - green;
    blue = 255 - blue;
  #endif
  analogWrite(LED_STRIP_2_RED, red); 
  analogWrite(LED_STRIP_2_GREEN, green); 
  analogWrite(LED_STRIP_2_BLUE, blue);   
}



//Set LED custom Red value 0 - 255
void setLED2Red(int red)
{
  #ifdef COMMON_ANODE
    red = 255 - red;
  #endif
  analogWrite(LED_STRIP_2_RED, red); 
}

//Set LED custom Green value 0 - 255
void setLED2Green(int green)
{
  #ifdef COMMON_ANODE
    green = 255 - green;
  #endif
  analogWrite(LED_STRIP_2_GREEN, green); 
}

//Set LED custom Blue value 0 - 255
void setLED2Blue(int blue)
{
  #ifdef COMMON_ANODE
    blue = 255 - blue;
  #endif
  analogWrite(LED_STRIP_2_BLUE, blue); 
}

void chacon2_on(){
  mySwitch.sendTriState("0FFFF0FFFFFF"); delay(transmitterDelay); //Serial.println("Chacon #2: ON"); 
}
void chacon3_on(){
  mySwitch.sendTriState("0FFFFF0FFFFF"); delay(transmitterDelay); //Serial.println("Chacon #3: ON");
}
void chacon4_on(){
  mySwitch.sendTriState("0FFFFFF0FFFF"); delay(transmitterDelay); //Serial.println("Chacon #4: ON");
}
void chacon2_off(){
  mySwitch.sendTriState("0FFFF0FF0000"); delay(transmitterDelay); //Serial.println("Chacon #2: OFF");
}
void chacon3_off(){
  mySwitch.sendTriState("0FFFFF0FFFF0"); delay(transmitterDelay); //Serial.println("Chacon #3: OFF");
}
void chacon4_off(){
  mySwitch.sendTriState("0FFFFFF0FFF0"); delay(transmitterDelay); //Serial.println("Chacon #4: OFF");
}
void zap1_on(){
  mySwitch.sendTriState("F00F0FFF0101"); delay(transmitterDelay); //Serial.println("Zap #1: ON"); 
}
void zap2_on(){
  mySwitch.sendTriState("F00F0FFF1001"); delay(transmitterDelay); //Serial.println("Zap #2: ON"); 
}
void zap3_on(){
  mySwitch.sendTriState("F00F0FF10001"); delay(transmitterDelay); //Serial.println("Zap #3: ON"); 
}
void zap4_on(){
  mySwitch.sendTriState("F00F0F1F0001"); delay(transmitterDelay); //Serial.println("Zap #4: ON"); 
}
void zap1_off(){
  mySwitch.sendTriState("F00F0FFF0110"); delay(transmitterDelay); //Serial.println("Zap #1: OFF");
}
void zap2_off(){
  mySwitch.sendTriState("F00F0FFF1010"); delay(transmitterDelay); //Serial.println("Zap #2: OFF");
}
void zap3_off(){
  mySwitch.sendTriState("F00F0FF10010"); delay(transmitterDelay); //Serial.println("Zap #3: OFF");
}
void zap4_off(){
  mySwitch.sendTriState("F00F0F1F0010"); delay(transmitterDelay); //Serial.println("Zap #4: OFF");
}

//turn on all Zap
void zap_on(){
  if(millis() > loadingTimeChaconZap){
    zap1_on(); zap2_on(); zap3_on(); zap4_on();
  }
}

//turn off all Zap
void zap_off(){
  if(millis() > loadingTimeChaconZap){
    zap1_off(); zap2_off(); zap3_off(); zap4_off();
  }
}

//turn on all Chacon
void chacon_on(){
  if(millis() > loadingTimeChaconZap){
    chacon2_on(); chacon3_on(); chacon4_on();
  }
}

//turn off all Zap
void chacon_off(){
  if(millis() > loadingTimeChaconZap){
    chacon2_off(); chacon3_off(); chacon4_off();
  }
}

//turn on all
void turn_on_all(){
  if(millis() > loadingTimeChaconZap){
    
    //Turn ON Chacon
    chacon4_on(); //chacon2_on(); chacon3_on();
    delay(10);
    
    //Turn ON Zap
    zap1_on(); zap2_on(); zap3_on(); zap4_on();
    delay(10);
    
    //Turn ON LED Strip
    setColorLED(0, 255, 0, 2);
  }
}

//turn off all
void turn_off_all(){
  if(millis() > loadingTimeChaconZap){

    //Turn OFF Chacon
    chacon4_off(); //chacon2_off(); chacon3_off();
    delay(10);

    //Turn OFF Zap
    zap1_off(); zap2_off(); zap3_off(); zap4_off();
    delay(10);

    //Turn OFF LED Strip
    setColorLED(0, 0, 0, 2);
  }
}

With this updated sketch, it’s working :wink:

I created new Trigger to change circle light color automatically. For example, if I set LED strip to Blue, trigger sends an IR value to set the circle light to blue.

At last, I create new Cayenne dashboard to controle my living room devices.

Thanks to Cayenne, I can play with IR + 433MHz + RGB LED strips using official Arduino board.

Don’t hesitate to reply me if there is an easier solution :wink:

@Neoxelox Is it better for you ?

Ben


#9

Awesome! You are very tidy when making code! :thumbsup: