How to Control Your BLINDS With Cayenne IoT and Make a Sun Natural Alarm Clock

Hi! I’m Neoxelox, and today I will show you how to control your BLINDS (Pull up/down and stop) with Cayenne IoT, and with it’s schedule manager make an Sun natural alarm clock!

We need:

Step 1: Connect the IR Emitter to Arduino and also the Triggers
Connect the IR Emitter to Arduino board.

Pinout:

IR Emitter / Arduino

pin “-” —> pin GND

this pin doesn’t have any letter so, the middle pin —> pin 5V

pin “S” —> digital pin 3 or other digital pin (It cannot be pin 0,1,2 or 13)

Triggers:

I was thinking what is the easiest way to do this project, and I realized if we connect a wire through digital pin 9 to 8 and digital pin 7 to 6 is the best way to do it, so:

Connect Arduino digital pin 9 to Arduino digital pin 8, repeat with 7 to 6.

Step 2: The Code
As you can see my Blinds Remote Control has 3 options:


Just copy that (Obviously you need to change the line 33 with your IR Emitter digital pin.

And also you have to know what speed you IR Emitter works with (mine 38 khz).

And one thing important is that you have to know what are your Blinds IR Raws, I mean the numbers that represent the action “Pull Blinds Up/Down and Stop”. If you don’t know this, you can dumb your remote control with this library and with a IR Receiver (In the library you have and example of “Dump”, just execute that and press the buttons of your remote control).

    /* 
Cayenne Button Widget Example 
This sketch shows how to set up a Button Widget with Cayenne. 
The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager. 
Steps: 
1. In the Cayenne Dashboard add a new Button Custom Widget. 
2. Select a digital pin number. Do not use digital pins 0 or 1 since those conflict with the use of Serial. 
3. Attach a digital output device (e.g. a LED) to the digital pin on your Arduino matching the selected pin. 
4. Set the token variable to match the Arduino token from the Dashboard. 
5. Compile and upload this sketch. 
6. Once the Arduino connects to the Dashboard you should be able to control the digital output device with the Button widget. 
Notice that there isn't much coding involved to interact with the digital pins. 
Most of it is handled automatically from the Cayenne library. 
For further examples of how to receive data from Cayenne see the example sketches under Actuators. 
*/ 
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space 
// If you're not using the Ethernet W5100 shield, change this to match your connection type. See Communications examples. 
#include <CayenneEthernet.h> 
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard. 
char token[] = "********"; 
#include <IRremote.h> 
#include <IRremoteInt.h> 
IRsend irsend; 
IRrecv irrecv(3); 
int khz = 38; 
unsigned int PullBlindsUp[] = {6000, 4200, 560, 760, 560, 560, 360, 1690, 560, 560, 860, 560, 560, 560, 560, 560, 560, 260, 560, 1690, 560, 1890, 560, 560, 560, 1390, 160, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; 
unsigned int PullBlindsDown[] = 6000, 5600, 860, 760, 560, 560, 360, 2690, 560, 560, 860, 660, 560, 560, 460, 560, 560, 560, 560, 1690, 560, 1890, 560, 560, 560, 1690, 160, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; 
unsigned int StopBlinds[] = {2000, 3200, 960, 760, 560, 560, 360, 1790, 560, 560, 860, 560, 760, 560, 560, 560, 560, 960, 560, 1690, 560, 1890, 560, 560, 560, 1490, 160, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 39416, 9000, 2210, 560}; 
void setup() { 
pinMode(8, INPUT); 
pinMode(6, INPUT); 
Serial.begin(9600); 
 Cayenne.begin(token); 
} 
void loop() { 
Cayenne.run(); 
if(digitalRead(8)==HIGH){ 
  irsend.sendRaw(PullBlindsUp, sizeof(PullBlindsUp) / sizeof(PullBlindsUp[0]), khz); 
  while(digitalRead(8)==HIGH){} 
}else{ 
  irsend.sendRaw(StopBlinds, sizeof(StopBlinds) / sizeof(StopBlinds[0]), khz); 
} 
if(digitalRead(6)==HIGH){ 
  irsend.sendRaw(PullBlindsDown, sizeof(PullBlindsDown) / sizeof(PullBlindsDown[0]), khz); 
  while(digitalRead(6)==HIGH){} 
}else{ 
  irsend.sendRaw(StopBlinds, sizeof(StopBlinds) / sizeof(StopBlinds[0]), khz); 
} 
}  

Step 3: Set Up Cayenne IoT Buttons
Set Up Cayenne IoT Buttons as the images show.

PD:

You DON’T need a third button called “Stop”, because when you are NOT pressing any of the other buttons the blinds will STOP.

Step 4: Test it and you FINISH!!!
Test it and you will finish!! Hope you like it!!

PD:

There is more below :smiley:

Step 5: (OPTIONAL) You can make a Sun natural alarm clock
You can make a Sun natural alarm clock with Cayenne’s Scheduler manager, just click option button in the Pull Blinds Up, and press Schedule. Then modify it as you want. The blinds will Pull Up, and all the solar light will enter into your room. :smiley:

1 Like

Oh its seems that I didn’t put well the code :C, I don’t know how to edit my post, please help!

Hi again @Neoxelox,

Another cool project, thanks for sharing these with our community.

You can edit your post by looking for the pencil icon which will appear on your posts when you scroll to them while logged in as yourself. I’ve highlighted it in this image:

Oh, thanks I didn’t noticed that.

Oh one more thing, how I can put code in a post, because i press the code button and it doesn’t do nothing

If you surround your code block with the backtick character ` on each side, then the forum will render it as fixed-width font and easier to read as code.

Here is an example of how your code block would look

Sometimes the forum software gets caught up on the code itself though, so even easier is to paste your code into the editor, highlight it, and then click the “Preformatted Text” button, at which point it should render the block as code.

Perfect, thanks!