Blynk RF socket

Hi I used to control RF socket by sending RF signal using Arduino and RF library, Is it possible to use Blynk to control RF Socket.

Yes, it’s possible. I’m controlling everything in my house with Blynk with Infra red signals

Can you please post sample code

I’ve used Arduino Library by Ken Shirriff: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html

  • With this library, I’ve recorded all the codes for each button I needed from remote controllers.
/*
0xC728D OFF
0xCF20D ON
0xC20DF Source
0xCA857 OK
0xCD02F UP
0xC30CF DOWN
0xC28D7 MUTE
0xCA15E BACK
0xC41BE Vol Up
0xCC13E Vol Down
*/
  • Then I set up buttons to Virtual Pins.

Here is a code I’m using to control my projector:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <IRremote.h>

IRsend irsend;

char auth[] = "d79cffb25f0449ffhdhdhddjjdjjdjdjdjd7999";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);
}

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


BLYNK_WRITE(1)
{
  if (param.asInt()){
    irsend.sendNEC(0xCF20D, 32); //  Turn On
    delay(40);
  }else {
    irsend.sendNEC(0xC728D, 32); //  Turn Off
    delay(100);
    irsend.sendNEC(0xC728D, 32);
    delay(100);
  }  
}

BLYNK_WRITE(0)
{
  if (param.asInt()){
    irsend.sendNEC(0xC728D, 32); //  Turn Off
    delay(40);
    irsend.sendNEC(0xC728D, 32);
    delay(40);
    irsend.sendNEC(0xC728D, 32);
  }
}

BLYNK_WRITE(2)
{
  if (param.asInt()){
    irsend.sendNEC(0xC20DF, 32); //  Source
    delay(40);
  }
}

BLYNK_WRITE(3)
{
  if (param.asInt()){
    irsend.sendNEC(0xCD02F, 32); //  Up
    delay(40);
  }
}

BLYNK_WRITE(4)
{
  if (param.asInt()){
    irsend.sendNEC(0xC30CF, 32); //  Down
    delay(40);
  }
}

BLYNK_WRITE(5)
{
  if (param.asInt()){
    irsend.sendNEC(0xCA857, 32); //  OK
    delay(40);
  }
}

BLYNK_WRITE(6)
{
  if (param.asInt()){
    irsend.sendNEC(0xCA15E, 32); //  Back
    delay(40);
  }
}

BLYNK_WRITE(7)
{
  if (param.asInt()){
    irsend.sendNEC(0xC41BE, 32); //  Vol Up
    delay(40);
  }
}


BLYNK_WRITE(8)
{
  if (param.asInt()){
    irsend.sendNEC(0xCC13E, 32); //  Vol Down
    delay(40);
  }
}

So it was pretty easy. It took me about 20 mins to set everything up. Then I did the same with air conditioner.

Many many thanks… for your code, let me try with Arduino RF library with same way.

Hi
How to define transmitting pin ?

Please get used to read comments in the libraries. People tend to spend their time for instructions. If you open the example sketch which goes with the library, you’ll see:

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

Sir,
Thank you for your post

Actually I am trying to control RC socket via Blynk, please find below sample code and let me know I am following the correct way

define BLYNK_PRINT Serial    // Comment this out to disable prints and save space

**#include (librery)

char auth[] = "             ";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);
 mySwitch.enableTransmit(7);
 mySwitch.setPulseLength(321);
}

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

BLYNK_WRITE(1)
{
  if (param.asInt()){
mySwitch.send("100000101100100011001000");
    delay(40);
  }
}

I usually follow this steps when tinkering with Blynk:

  1. Make sure it works without Blynk
  2. Add Blynk on top of working code

Recommend you do the same :wink:

Hey Pavel,

I liked your application. It leaves me with the following question though… when you went on to connect your air conditioner, did you reuse the same arduino/microcontroller or do you have a separate one for each device?

R

Since they are in different rooms, I have to use two. But I’m thinking about next phase of this project, where only one Arduino(or Particle) will be connected to the Internet, serving as a hub, all the other things communicating over simple radio (or ESP8266). The goal is to make it as cheap as possible.

The problem though is that IR library is working well only on Arduino, which makes it difficult to port. I just don’t have time to dive deep into it :smile:

Time is always the problem my friend.

Any thought on my suggestion to allow multiple projects share the same authentication token? Using your project as an example, you could have multiple “project” screens each with the appropriate IR button layout to control multiple items using a single Arduino?

R

Being an active Blynk user (as you might imagine :smile: ), I still had no problems with the lack of space. + you can always use Bridge Widget for it.