1

I have an issue with 433mhz reading. I have two cheap transmitter and receiver boards, the most known ones : Devices

I followed several tutorials, and I'm using the rc switch library.

I'm trying to read the signal sent by a remote control, (stores), as I would like to duplicate it, to control the store. I firstly tried with the basic code to read 433mhz signals, but it didn't work. Assuming that there is an encryption between the two devices, (I'm not sure if that this is the case, but internet didn't help to find if it's usually the cases for those devices, and how to tell if mine has encryption, It would be nice if I can get some help on that too), I decided to upload a code to get raw data, sent by any transmissions.

The problem is that there is absolutely no data coming out from the receptor when I use the rc switch library. I have another Arduino constantly sending float values with a transmitter, and it works if I use virtualwires, but it doesn't show anything on the serial monitor with rc switch. I also tried with my store remote control, and a garage remote control, but nothing is showing up.

Here is the code of the receiver :

/*
  Example for analyzing and proposing unknown new protocols

  https://github.com/Martin-Laclaustra/rc-switch/

  Requires modified rc-switch branch "protocollessreceiver"
  with ReceivedInverted() function exposed.
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on interrupt 0 => that is pin #2
  // Use mySwitch.enableReceive(D2); for ESP8266
  Serial.println("beginned");
}

void loop() {
  if (mySwitch.available()) {

    int value = mySwitch.getReceivedValue();

    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {

      int databuffer[64]; // get a copy of the received timings before they are overwritten
      int numberoftimings = 2 * mySwitch.getReceivedBitlength() + 2;
      if (numberoftimings > 64) numberoftimings = 64;
      for (int i = 0; i < numberoftimings; i++) {
        databuffer[i] = mySwitch.getReceivedRawdata()[i];
      }

      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );

      unsigned int databitsoffset = abs( (int)mySwitch.getReceivedLevelInFirstTiming() - (int)mySwitch.getReceivedInverted());
      //Serial.println( mySwitch.getReceivedLevelInFirstTiming() );
      //Serial.println( mySwitch.getReceivedInverted() );
      //Serial.println( databitsoffset );
      unsigned long dataduration = 0;
      for (unsigned int i = 1 + databitsoffset; i < numberoftimings - 1 + databitsoffset; i++) {
        dataduration += databuffer[i];
      }
      Serial.print("data bits of pulse train duration: ");
      Serial.println( dataduration );
      unsigned int averagebitduration = (int)(0.5 + ((double)dataduration) / mySwitch.getReceivedBitlength());
      unsigned int protocolratio = (unsigned int)(0.5 + ((double)(averagebitduration - mySwitch.getReceivedDelay())) / (double)mySwitch.getReceivedDelay());
      Serial.print("proposed protocol: { ");
      Serial.print(mySwitch.getReceivedDelay());
      Serial.print(", { ");
      Serial.print( (databitsoffset == 0) ?
                    (int) (0.5 + (double)databuffer[2 * mySwitch.getReceivedBitlength() + 1] / (double)mySwitch.getReceivedDelay())
                    :
                    (int) (0.5 + (double)databuffer[0] / (double)mySwitch.getReceivedDelay())
                  );
      Serial.print(", ");
      Serial.print( (databitsoffset == 0) ?
                    (int) (0.5 + (double)databuffer[0] / (double)mySwitch.getReceivedDelay())
                    :
                    (int) (0.5 + (double)databuffer[1] / (double)mySwitch.getReceivedDelay())
                  );
      Serial.print(" }, { ");
      Serial.print("1");
      Serial.print(", ");
      Serial.print(protocolratio);
      Serial.print(" }, { ");
      Serial.print(protocolratio);
      Serial.print(", ");
      Serial.print("1");
      Serial.print(" }, ");
      Serial.print((mySwitch.getReceivedInverted()) ? "true" : "false" );
      Serial.println(" }");

      // raw signal
      Serial.println("====");
      Serial.print("first level ");
      Serial.println((mySwitch.getReceivedLevelInFirstTiming() == 0) ? "down" : "up" );
      for (int i = 0; i < 2 * mySwitch.getReceivedBitlength() + 2 - 1 + databitsoffset; i++) {
        Serial.print(databuffer[i]);
        Serial.print(" ");
        if ((i - databitsoffset) % 16 == 0) Serial.println("");
      }
      if ((2 * mySwitch.getReceivedBitlength() + 2 - 1 + databitsoffset - 1) % 16 != 0) Serial.println("");
      if (databitsoffset != 1) Serial.println(databuffer[2 * mySwitch.getReceivedBitlength() + 1]);
      // plot signal in spreadsheet
      Serial.println("====");

    }

    mySwitch.resetAvailable();
  }
}

I am aware that interruptPin(0) = pin #2 on Arduino

Here is the layout :

Layout

Does anyone have an idea of why I can't get anything on my serial monitor ?, I'll take any help !

3
  • there is no encryption ... it's just a wireless wire ... connect a switch to the transmitter and an LED to the receiver ... otherwise, connect a GPIO output to the transmitter and a GPIO input to the receiver
    – jsotola
    Dec 5, 2022 at 21:45
  • For stores i don't think there is, but I read that garage door have that system, but don't know how to check. For the setup this is exactly what i have done : Data is going out from a GPIO to the transmitter, and reversed for the receiver. What's wrong ?
    – BruceWawe
    Dec 6, 2022 at 10:46
  • try to read with SimpleScanner, you can find sketch here: github.com/sui77/SimpleRcScanner/blob/master/htdocs/Sketchbook/…
    – Black.Jack
    Jul 9 at 23:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.