ESP32 RCSwitch problem with pulsewidth

Hello developers,

I hope it's ok to post this question here even tho it's not an actual arduino. but the ESP32 is programmed with arduino language sooo please have mercy ^^

So I'm building a home automation system. I'm using ESP32 to send data with a 433MHz transmitter to wireless sockets. it works fine. now I bought another set of wireless sockets but from different brand. My old ones use DIP switches. the new ones are programmable. when u plug them in they start to blink and when u press a button it is programmed with this button. with an Arduino and a receiver I checked what codes are sent from the remote. used the RCSwitchSendDemo to send these codes. and it works. BUT, when I send the codes from my own script it doesn't work. the led on the transmitter is flashing but nothing is sent. I double checked with arduino uno receiver, it's not receiving anything. the new model requires a different value of "pulsewidth" and "protocol". the old wireless sockets just worked with "RC switch.switchon / switchoff.

received analysis:
pulsewidth = 405
protocol = 5

so I send using just these parameters.
in the example RCSwitch_Senddemo it works fine.
In my script using exactly the same commands and parameters it doesn't.

played around with the pulsewidth a bit but nothing changed. i mean no matter what pulsewidth, the Uno receiver should've received it right?..
I also played around with repeattransmit option.

here's the code

#include <WiFi.h>
#include <RCSwitch.h>
#include <LiquidCrystal.h>
#include <Arduino.h>

TaskHandle_t main;
TaskHandle_t stby;

const char* ssid = "ImageLine Remote";
const char* password = "chickensoup";

IPAddress local(192, 168, 2, 110);
IPAddress gateway(192, 168, 2, 1);
IPAddress subnetmask(255, 255, 255, 0);

String cmode = "normal";
String tv = "off";
String header = "";
String state_cmode = "normal";
String state_tv = "off";
String state_dev1 = "off";
String state_dev2 = "off";
String state_dev3 = "off";

RCSwitch mySwitch = RCSwitch();
LiquidCrystal lcd(14, 27, 26, 25, 33, 32);
WiFiServer server(80);

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(115200);
  xTaskCreatePinnedToCore(f_stby, "stby", 10000, NULL, 1, &stby, 0);
  delay(500);
  xTaskCreatePinnedToCore(f_main, "main", 10000, NULL, 1, &main, 1);
  delay(500);
  pinMode(4, OUTPUT);
  display_boot();
  Serial.print("connecting to ");
  Serial.print(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.config(local, gateway, subnetmask);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  display_connected();

  Serial.println("");
  Serial.println("Connection Successful!");
  Serial.print("IP: ");
  Serial.print(WiFi.localIP());
  server.begin();
  mySwitch.enableTransmit(12);
}

void f_stby(void * pvParameters) {
  for (;;) {
  }
}

void f_main(void * pvParameters) {
  for (;;) {
    WiFiClient client = server.available();

    if (client) {
      Serial.println("new client");
      String currentLine = "";
      while (client.connected()) {
        if (client.available()) {
          char c = client.read();
          Serial.print(c);
          header += c;
          if (c == '\n') {
            if (currentLine.length() == 0) {
              client.println("HTTP/1.1 200 OK");
              client.println("Content-type:text/html");
              client.println("Connection: close");
              client.println();

              if (header.indexOf("GET /cmode/tv") >= 0) {
                Serial.println("COLOR MODE tv");
                state_cmode = "tv";
                mySwitch.switchOn("11111", "00010");
              }
              else if (header.indexOf("GET /cmode/normal") >= 0) {
                Serial.println("COLOR MODE normal");
                state_cmode = "normal";
                mySwitch.switchOff("11111", "00010");
              }
              else if (header.indexOf("GET /tv/on") >= 0) {
                Serial.println("TV on");
                state_tv = "on";
                mySwitch.switchOn("11111", "00001");
                
              }
              else if (header.indexOf("GET /tv/off") >= 0) {
                Serial.println("TV off");
                state_tv = "off";
                mySwitch.switchOff("11111", "00001");
              }
              else if (header.indexOf("GET /dev1/on") >= 0) {
                Serial.println("DEV1 on");
                state_dev1 = "on";
                mySwitch.send("000010000000000010110000");
              }
              else if (header.indexOf("GET /dev1/off") >= 0) {
                Serial.println("DEV1 off");
                state_dev1 = "off";
                mySwitch.send("000011110110110010010000");
              }
              else if (header.indexOf("GET /dev2/on") >= 0) {
                Serial.println("DEV2 on");
                state_dev1 = "on";
                mySwitch.send("000010110101011001110100");
                delay(700);
              }
              else if (header.indexOf("GET /dev2/off") >= 0) {
                Serial.println("DEV2 off");
                state_dev1 = "off";
                mySwitch.send("000001001101101010100100");
              }
              else if (header.indexOf("GET /dev3/on") >= 0) {
                Serial.println("DEV3 on");
                state_dev1 = "on";
                mySwitch.send("000010000000000010111100");
              }
              else if (header.indexOf("GET /dev3/off") >= 0) {
                Serial.println("DEV3 off");
                state_dev1 = "off";
                mySwitch.send("000011101010000100101100");
              }
              
              break;
            }
            else {
              currentLine = "";
            }
          }
          else if (c != '\r') {
            currentLine += c;
          }
        }
      }
      header = "";
      client.stop();
      Serial.println("client disconnected.");
      Serial.println("");
    }
  }
}

void loop() {
}

void display_boot() {
  lcd.begin(16, 2);
  lcd.print("    STUD.IO");
  lcd.setCursor(0, 1);
  lcd.print("      v2.0      ");
  delay(1000);
  lcd.clear();
  lcd.print("starting server");
  lcd.setCursor(0, 1);
  delay(400);
  
  for (int i=0; i<=4; i++){
    lcd.setCursor(0, 1);
    lcd.print(">");
    delay(50);
    lcd.print(">");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print(" >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("  >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("   >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("    >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("     >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("      >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("       >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("        >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("         >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("          >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("           >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("            >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("             >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("              >>");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("               >");
    delay(50);
    lcd.setCursor(0, 1);
    lcd.print("                ");
    delay(50);
  }
}

void display_connected() {
  lcd.clear();
  lcd.print("SERVER RUNNING!");
  digitalWrite(4, HIGH);
  delay(100);
  digitalWrite(4, LOW);
  lcd.setCursor(0, 1);
  lcd.print("IP:");
  lcd.print(WiFi.localIP());
  lcd.setCursor(0, 0);
  delay(600);
  lcd.print("    STUD.IO     ");
}

and here the code of the example script..

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);
  
  // Transmitter is connected to Arduino Pin #10  
  mySwitch.enableTransmit(12);
  
  // Optional set protocol (default is 1, will work for most outlets)
  mySwitch.setProtocol(5);

  // Optional set pulse length.
  mySwitch.setPulseLength(504);
  
  // Optional set number of transmission repetitions.
  mySwitch.setRepeatTransmit(4);

void loop() {
  /* Same switch as above, but using binary code */
  mySwitch.send("000010000000000010110000");
  delay(1000);  
  mySwitch.send("000011110110110010010000");
  delay(1000);
}
  
}

nobody?? pleasee

juniq:
in the example RCSwitch_Senddemo it works fine.
In my script using exactly the same commands and parameters it doesn't.

There is no .setPulseLength in your code, but in the working example.

juniq:
received analysis:
pulsewidth = 405

  mySwitch.setPulseLength(504);

Why don't you use the analysis value?