Transmitting code on 433 MHz

Hello everyone,

I’m developing a project where I want to control my shutters with the Blynk app. At home, every shutter motor has a receiver on 433 MHz. I have a remote (sender) with 20 channels, only 8 of them are used right now.

I made a receiver with the XLC-RF-5V module for Arduino to catch the code my shutter remote sends to the shutters. I found out the codes the old fashion way by reading the analog output of the receiver and reading the high and low signal lengths. Then, I wrote a code to send that same signal again with my sender module (FS1000A). When I use my function transmitCode (see code below) in setup() with the code for one channel, it works. But now, I integrated this code into the Blynk code, but it doesn’t seem to work.

The idea with the blynk app is that I have a selection widget with 9 options and below, I have 3 buttons: one for making a shutter go up, one to make it go down and one to make it stop. According to which option is selected from the widget, those 3 buttons have a different function (they send the code for up, down or stop from the selected shutter).

Can anyone explain why this code works if I put “transmitCode(kanaal_1_op);” in the setup() but doesn’t work when called in the Blynk.write() function?

Thanks in advance!
Alexander

My app:

My code:

/*
  Transmit sketch - RF Calibration
     Written by ScottC 17 July 2014
     Arduino IDE version 1.0.5
     Website: http://arduinobasics.blogspot.com.au/2014/07/433-mhz-rf-module-with-arduino-tutorial.html
     Transmitter: FS1000A/XY-FST
     Description: A simple sketch used to calibrate RF transmission.
  ------------------------------------------------------------- */
//433 MHz:
#define rfTransmitPin 51  //RF Transmitter pin = digital pin 22
#define ledPin 13        //Onboard LED = digital pin 13

//Blynk:
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
char auth[] = "6k530qBs2SLxqQge4cb4lXu57xuyzwhd";

//basis van code (vast deel): {15,5,5,2,2,2,5,2,2,2,5,2,2,2,2,2,2,2,2,5,5,2,2,5,2,2,2,2,2}

const int codeSize = 41;      //lengte van de code (aantal posities in de arrays hieronder)
int codeToTransmit[codeSize]; //The array used to hold the RF code
int kanaal_0_op[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 8}; //Code voor kanaal 1 op
int kanaal_0_neer[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 8}; //Code voor kanaal 1 neer
int kanaal_0_stop[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 5, 2, 5, 2, 8}; //Code voor kanaal 1 stop
int kanaal_1_op[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 8}; //Code voor kanaal 1 op
int kanaal_1_neer[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 5, 5, 2, 2, 5, 8}; //Code voor kanaal 1 neer
int kanaal_1_stop[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 5, 2, 5, 2, 5, 2, 8}; //Code voor kanaal 1 stop
int kanaal_2_op[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 5, 2, 2, 2, 8};
int kanaal_2_neer[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 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, 2, 5, 5, 5, 2, 2, 5, 5, 2, 2, 5, 8};
int kanaal_7_stop[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 5, 5, 5, 2, 5, 2, 5, 2, 5, 2, 8};
int kanaal_8_op[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 8};
int kanaal_8_neer[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 8};
int kanaal_8_stop[] = {15, 5, 5, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 5, 2, 5, 2, 5, 2, 8};

int kanaal_test1_op[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 8}; //Code voor kanaal 1 op
int kanaal_test1_neer[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 5, 5, 2, 2, 5, 8}; //Code voor kanaal 1 neer
int kanaal_test1_stop[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 2, 5, 2, 5, 2, 5, 2, 8}; //Code voor kanaal 1 stop
int kanaal_test2_op[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 5, 2, 2, 2, 6};
int kanaal_test2_neer[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 2, 5, 5, 2, 2, 5, 6};
int kanaal_test2_stop[] = {15, 5, 15, 15, 2, 2, 5, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 2, 5, 5, 2, 2, 5, 2, 2, 2, 2, 2, 2, 2, 5, 2, 2, 5, 2, 5, 2, 5, 2, 6};


int codeToggler = 0;  //Used to switch between turning the light ON and OFF
int timeDelay = 115;    // The variable used to calibrate the RF signal lengths. Delay = tussen 95-125 voor rolluiksturing

int geselecteerdOp[codeSize];
int geselecteerdNeer[codeSize];
int geselecteerdStop[codeSize];

void setup() {
  Serial.begin(9600);        // Turn the Serial Protocol ON
  pinMode(rfTransmitPin, OUTPUT);   //Transmit pin is an output
  pinMode(ledPin, OUTPUT);

  delay(2000);

  Blynk.begin(auth);
  Blynk.virtualWrite(V1, 0);
  Blynk.virtualWrite(V2, 0);
  Blynk.virtualWrite(V3, 0);

}



void loop() {

  Blynk.run();

}

/*----------------------------------------------------------------
  BLYNK CODE
  ------------------------------------------------------------------*/

BLYNK_WRITE(V0) {
  Blynk.virtualWrite(V1, 0);
  Blynk.virtualWrite(V2, 0);
  Blynk.virtualWrite(V3, 0);


  switch (param.asInt())
  {
    case 1: // Alles
      equalArray(geselecteerdOp, kanaal_1_op);
      equalArray(geselecteerdNeer, kanaal_1_neer);
      equalArray(geselecteerdStop, kanaal_1_stop);
      Serial.println("Alles geselecteerd");
      break;
    case 2: // Keuken klein
      equalArray(geselecteerdOp, kanaal_2_op);
      equalArray(geselecteerdNeer, kanaal_2_neer);
      equalArray(geselecteerdStop, kanaal_2_stop);
      Serial.println("Keuken klein geselecteerd");
      break;
    case 3: // Keuken groot
      equalArray(geselecteerdOp, kanaal_2_op);
      equalArray(geselecteerdNeer, kanaal_2_neer);
      equalArray(geselecteerdStop, kanaal_2_stop);
      Serial.println("Keuken groot geselecteerd");
      break;
    case 4: // Keuken hoek
      equalArray(geselecteerdOp, kanaal_3_op);
      equalArray(geselecteerdNeer, kanaal_3_neer);
      equalArray(geselecteerdStop, kanaal_3_stop);
      Serial.println("Keuken hoek geselecteerd");
      break;
    case 5: // Living achter
      equalArray(geselecteerdOp, kanaal_4_op);
      equalArray(geselecteerdNeer, kanaal_4_neer);
      equalArray(geselecteerdStop, kanaal_4_stop);
      Serial.println("Living achter geselecteerd");
      break;
    case 6: // Living achter klein
      //equalArray(geselecteerdOp,kanaal_5_op);
      //equalArray(geselecteerdNeer,kanaal_5_neer);
      //equalArray(geselecteerdStop,kanaal_5_stop);
      Serial.println("Living achter klein geselecteerd");
      break;
    case 7: // Living klein
      equalArray(geselecteerdOp, kanaal_6_op);
      equalArray(geselecteerdNeer, kanaal_6_neer);
      equalArray(geselecteerdStop, kanaal_6_stop);
      Serial.println("Living klein geselecteerd");
      break;
    case 8: // Living voor klein
      equalArray(geselecteerdOp, kanaal_7_op);
      equalArray(geselecteerdNeer, kanaal_7_neer);
      equalArray(geselecteerdStop, kanaal_7_stop);
      Serial.println("Living voor klein geselecteerd");
      break;
    case 9: // Living voor
      equalArray(geselecteerdOp, kanaal_8_op);
      equalArray(geselecteerdNeer, kanaal_8_neer);
      equalArray(geselecteerdStop, kanaal_8_stop);
      Serial.println("Living voor geselecteerd");
      break;
    default:
      Serial.println("Niks geselecteerd");
  }
}

void equalArray(int teWijzigenArray[], int referentieArray[])
{
  for (int i = 0; i < 41; i++)
  {
    teWijzigenArray[i] = referentieArray[i];
  }
}

void printArray(int tePrintenArray[])
{
  Serial.print("Ingestelde Array: ");
  for (int i = 0; i < 41; i++)
  {
    Serial.print(tePrintenArray[i]);
    Serial.print(",");
  }
  Serial.println();
}


BLYNK_WRITE(V1)
{
  int value = param.asInt(); // Get value as integer
  if (value == 1)
  {
    transmitCode(geselecteerdOp);
    Serial.println("op");
  }




}

BLYNK_WRITE(V2)
{
  int value = param.asInt(); // Get value as integer
  if (value == 1)
  {
    transmitCode(geselecteerdStop);
    Serial.println("stop");
  }

}

BLYNK_WRITE(V3)
{
  int value = param.asInt(); // Get value as integer
  if (value == 1)
  {
    transmitCode(geselecteerdNeer);
    Serial.println("neer");
  }


}


/*-----------------------------------------------------------------
  433 MHz CODE
  -------------------------------------------------------------------*/

/*-----------------------------------------------------------------
  transmitCode(): Used to transmit the signal to the RF receiver on
                  the fan/light. There are 6 different HIGH-LOW signal combinations.

                  SH = short high   or  LH = long high
                                   PLUS
       SL = short low    or    LL = long low    or    VLL = very long low

  -------------------------------------------------------------------*/
void transmitCode(int code[]) {
  // The LED will be turned on to create a visual signal transmission indicator.
  digitalWrite(ledPin, HIGH);
  printArray(geselecteerdOp);
  printArray(geselecteerdNeer);
  printArray(geselecteerdStop);

  //initialise the variables
  int highLength = 0;
  int lowLength = 0;

  //The signal is transmitted 6 times in succession - this may vary with your remote.
  // 2-6-14-46
  for (int j = 0; j < 6; j++) {
    for (int i = 0; i < codeSize; i++) {
      switch (code[i]) {
        case 1: // SL + SH
          highLength = 2;
          lowLength = 2;
          break;
        case 2: // SL + MH
          highLength = 6;
          lowLength = 2;
          break;
        case 3: // SL + LH
          highLength = 14;
          lowLength = 2;
          break;
        case 4: // SL + VLH
          highLength = 38;
          lowLength = 2;
          break;
        case 5: // ML + SH
          highLength = 2;
          lowLength = 6;
          break;
        case 6: // ML + MH
          highLength = 6;
          lowLength = 6;
          break;
        case 7: // ML + LH
          highLength = 14;
          lowLength = 6;
          break;
        case 8: // ML + VLH
          highLength = 38;
          lowLength = 6;
          break;
        case 9: // LL + SH
          highLength = 2;
          lowLength = 14;
          break;
        case 10: // LL + MH
          highLength = 6;
          lowLength = 14;
          break;
        case 11: // LL + LH
          highLength = 14;
          lowLength = 14;
          break;
        case 12: // LL + VLH
          highLength = 38;
          lowLength = 14;
          break;
        case 13: // VLL + SH
          highLength = 2;
          lowLength = 46;
          break;
        case 14: // VLL + MH
          highLength = 6;
          lowLength = 46;
          break;
        case 15: // VLL + LH
          highLength = 14;
          lowLength = 46;
          break;
        case 16: // VLL + VLH
          highLength = 38;
          lowLength = 46;
          break;

      }

      /* Transmit a HIGH signal - the duration of transmission will be determined
         by the highLength and timeDelay variables */
      digitalWrite(rfTransmitPin, HIGH);
      delayMicroseconds(lowLength * timeDelay);  // was highLength

      /* Transmit a LOW signal - the duration of transmission will be determined
         by the lowLength and timeDelay variables */
      digitalWrite(rfTransmitPin, LOW);
      delayMicroseconds(highLength * timeDelay); // was lowLength
    }
  }
  //Turn the LED off after the code has been transmitted.
  digitalWrite(ledPin, LOW);
}

you know this is not the same pin as the comment right:)

it’s not totally clear for me why you do this?

You use three buttons, but I see 4 virtual adresses (V0,V1,V2 and V3)
I think it would help if you check the Blynk Example Browser about the “Virtual pin read”

for example:

    BLYNK_WRITE(V1)
    {
      int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
      // process received value
    }

This will get the value of the button if you press it or not.
but it’s (as far as I know) only stored in the temporary pinvalue.
if you change the code for one button to:

BLYNK_WRITE(V2) //Send button
{
  int pinValue = param.asInt(); // assigning incoming value from pin V2 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  // Serial.print("Button V2 value is: ");
  // Serial.println(pinValue);
  if (pinValue==1)
  {
    transmit_command();  
  }
  
}

pinvalue ==1 means the button is pressed.
then create a

void transmit_command()
{ insert all your send stuff}

oops. I see you did this trick more in the bottom of your routine… :slight_smile:

Not sure what happens here. can you elaborate?

I know the pin value is not the same as in the comment, but all of that works, because when I call the function transmitCode() in the setup() part, it works.

I have indeed 3 buttons assigned to virtual pins V1, V2 and V3. I set them to zero in the setup part.
The V0 virtual pin is assigned to the shutter selector. It gives back the values 1,2,3,…,9.

Alexander

I find the switch case process and the corresponding equalArray process to be rather clumsy and unnecessary.

There may be some issues with this process, and from what you are saying, when you bypass this and call transmitCode directly the process works okay.
I’d try a simplified version of the BLYNK_WRITE(V0) code to try to track down what the issues are, and look very carefully at the variable values long the way.

I went through a very similar process to you in order to capture the up, stop and down codes for three tubular motors that control external awnings. My way of sending these codes to the three different motors was much simpler than yours.
My motors use a preamble followed by 40 data bits then a pause, before the data is repeated. I modified some existing code to send these three elements with the correct timing and this worked very well.
If you’re interested I’ll dig out the code and share it.

Pete.

Hi Pete,

Thank you for the quick response.
I know this code is probably not the most esthetic one and therefore maybe not working very well.
Maybe I’ll test this code with just one shutter en just the 3 buttons, no selector, and see how this goes.

About the way I reproduce the signal, I know it’s maybe a little onorthodox but it works.
The reason I did it this way is because I first tried using the RC library, but this didn’t work for my remote. That’s why I followed a tutorial that I understood very well and made me understand how my remote sends a signal. That tutorial seems to be offline by now… But actually, I am interested in the code you used for the awnings. At least I can learn from it.

If I tested the simplified code, I’ll come back to you.

Alexander

Hi Pete,

I tested some different codes and from what I see is that even with simplified buttons, it doesn’t work.
Even when I put my function transmitCode(kanaal_test1_op) in the void loop(), it doesn’t work. I just found out the following:

This code for the void setup() doesn’t work:

void setup() {
Serial.begin(9600); // Turn the Serial Protocol ON
pinMode(rfTransmitPin, OUTPUT); //Transmit pin is an output
pinMode(ledPin, OUTPUT);

delay(2000);

Blynk.begin(auth);
transmitCode(kanaal_test1_op);
}

This code for the void setup() DOES work… mind the place of Blynk.begin(auth):

void setup() {
Serial.begin(9600); // Turn the Serial Protocol ON
pinMode(rfTransmitPin, OUTPUT); //Transmit pin is an output
pinMode(ledPin, OUTPUT);

delay(2000);

transmitCode(kanaal_test1_op);
Blynk.begin(auth);

}

Any idea why this happens?

Alexander

Is your serial monitor showing that Blynk is successfully connecting and giving a reasonable ping time?

Pete.

Hi Pete,

I just verified and yes, it succesfully connects with a ping of 34 ms.
So when the Blynk.begin(auth) comes first in my setup code, I read on my other Arduino with the receiver a random code that doesn’t make sense. But when I call the transmitCode function before the Blynk authentification, I read the correct and stable code on the receiver (just like it came from my original remote).

Alexander

The Arduino board communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega . On both boards, pin 10 is used as SS

It seems that you’ve chosen a pin that is internally connected to the Ethernet shield.

Pete.

1 Like

Pete,

This is it… With my original code and changing the pin from 51 to 41, it works!
Kind of stupid, but thank you very much for the help!

Alexander

1 Like

That might work. But it is better to call it on a timer so it won’t cause timeouts as it is tying up the processor that Blynk wants.

I was quite surprised to read that the Mega used pin 51 for the Ethernet shield, but your description of it working before connecting to Blynk and not working afterwards was what started me looking at that.

I assume from your previous description that you are using a 433 receiver connected to a sound card, and Audacity to analyse the results?
When you view the waveform in Audacity do you see something like this:

The image shows a Preamble where the signal is HIGH for 4785 micros and LOW for 1596 micros.

There are then 40 data bits, with 1’s being represented by a longer HIGH period than you get with a 0.
The important thing is that the period between the rising edge of the next waveform is always the same period (1075 micros in this case) from the last one.

My data has 40 data bits, then a terminating quiet (LOW) period before the next preamble.

If your data looks similar then I have a simple software solution to transmit the various 40 bit strings of 1’s and 0’s in a much neater way than the code that you’re using.

Pete.