Need help:Esp8266+433 mhz sockets+Blynk

Hi !!
How i said in the post,i have use the SendDemo example of RcSwitch library,with binary and tristate codes,and sockets works fine.Also i sniff the codes with an arduino nano and a 433 mhz receiver,and serial monitor shows that the codes and the pulse length was perfect.
As i said no matter what value i put in sketch,Blynk always send codes in a pulse length between 350-356 microseconds,instead of 187 microseconds.
Later i will try post the sketch,but i’m beginner,and this is not ease for me yet.

Thanks for answer me.

Hi,again.
When you say my code,do you want to say my sketch without Blynk?
If that is yes,how i do that?.

Enter 3 backticks
Paste your code starting on the next line
Three more backticks on a new line

or paste the code, highlight it all and press </> button.

#define BLYNK_PRINT Serial
#include <ESP8266wifi.h>
#include <blynkSimpleEsp8266.h>

//-------- rcswitch------
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

char* socket1On = “010100000101010100110011”;
char* socket1Off = “010100000101010100111100”;
char* socket2On = “010100000101010111000011”;
char* socket2Off = “010100000101010111001100”;
char* socket3On = “010100000101011100000011”;
char* socket3Off = “010100000101011100001100”;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxx”; //insert here your token generated by Blynk

void setup()
{
Serial.begin(9600);
Blynk.begin(auth, “XXXXXX”, “XXXXXX”); //insert here your SSID and password

mySwitch.enableTransmit(2);
mySwitch.setPulseLength(187);
mySwitch.setProtocol(1);
}

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

//-------rcswitch------
BLYNK_WRITE(0) { //virtual pin 0

mySwitch.send(socket1On);
}

BLYNK_WRITE(1) {
mySwitch.send(socket1Off);
}

BLYNK_WRITE(2) {
mySwitch.send(socket2On);
}

BLYNK_WRITE(3) {
mySwitch.send(socket2Off);
}
BLYNK_WRITE(4) {
mySwitch.send(socket3On);

}
BLYNK_WRITE(5) {
mySwitch.send(socket3Off);
}Preformatted text

This is a version of sketch i found in internet.
Sorry for the mess!!!

The missing part is:include ESP8266WIFI.h,and include blynkSimpleEsp8266.h,sorry but i could not fix the post.

Have you tried the latest master branch of the RCSwitch library by sui77? The last official release was just over a year ago but the master branch has 102 commits and some are ESP related.

We have a detailed thread about RF with ESP at Connect your existing RF devices to the internet with Blynk

I think your problem is button assign to send rf act as PUSH than when you press button, button send to hardware 2 values 0 and 1 than rcswitch send 2 times of code in a very short time. inside BLYNK_WRITE maybe you need handle value send from app

1 Like

What @NHN is saying a typical BLYNK_WRITE() for you should perhaps be:

BLYNK_WRITE(0) { //virtual pin 0
  if(param.asInt()){  // only send RF when virtual switch is HIGH, 1
    mySwitch.send(socket1On);
  }
}
2 Likes

I’m working on same project and I figure out like that:

BLYNK_WRITE(1) {
  mySwitch.send(SWITCH_1_ON, PACKET_LENGTH);
}

where

#define PACKET_LENGTH 24
#define SWITCH_1_ON  230568
1 Like

I´ll try.Thank you

NHN

I hay tried with push,and other sketches that uses buttons as swtiches,does not matter,the problem is the same.
In mine,every button sends codes twice,but the same code,1 or 0.

Thanks for answer.

Costas

I´ll try all options and inform you.

Thakyou very much.

Costas

The serial monitor,when i sniff what Blynk sends,only shows codes,1 or 0 ,when i press buttons.While not.
thanks.

Looking at your code you don’t have the RF transmitter hooked up to a physical pin. Let me know if you need the code for this.

edit; perhaps you do on pin 2.

@cachofeiro with the code below and V0 in SWITCH mode it flashes the onboard LED on a WeMos for ON and OFF.

BLYNK_WRITE(0) { //virtual pin 0 in Switch mode
  if(param.asInt()){  // only send RF when virtual switch is HIGH, 1
    mySwitch.send(socket1On);
    Serial.println("Socket 1 ON");  
  }
  else{
    mySwitch.send(socket1Off);
    Serial.println("Socket 1 OFF");       
  }
}

If this doesn’t work for you let me know and I will hook up one of my transmitters to GPIO 2.

Yes,Costas.

mySwitch.enable Transmit(2); I use GPIO2

Costas:i would like to try my sketch,using two momentary switches, one for (socket1On) and another for (socket1Off),to know where is the problem.If using my sketch driving de RF emitter through the switches,i think ,i can to know if problem,is code or Blynk.
I was trying with this,but when i verify/compile sketch,i take errors,that i don’t know how to fix,because i’m good with hardware,but not with software.
can you help me ???
I will appreciate.Thanks.

Do you mean virtual momentary switches or physical momentary switches?

If you post your code and the compilation errors we can take a look.

Physical switches,because is the only way to know where is the problem.

I have added some lines the code,to use phisycal switches,for socket 1 ON and OFF,trying to emulate the virtual pins of Blynk,but as i said,i’m not good programming.and the sketch not compile good.
That’s is why i need help.

Thanks.

OK paste the sketch.