2

I am trying to use this example code from the RCSwitch library:

/*
  Simple example for receiving

  https://github.com/sui77/rc-switch
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
}

void loop() {
  if (mySwitch.available()) {
    Serial.print("Is avail");
    int value = mySwitch.getReceivedValue();

    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
    }

    mySwitch.resetAvailable();
  }
}

It seems like the mySwitch.available() is returning false, but since there seems to be no documentation for the library I don't know what it means.

So why is that?

I am trying to use this code on a A-Star 32U4 Micro, which supports Arduino code.

CharlieHanson
  • 1,400
  • 1
  • 11
  • 25
rablentain
  • 163
  • 1
  • 9

2 Answers2

1

I think that the value of available just determine if there is a message to receive or not.

rablentain
  • 163
  • 1
  • 9
0

Your code is OK. It seems that the transmitter's remote control frequency is different from the receiver. Both transmitters and receivers must have the same frequency. 433MHZ - TX with 433MHZ - RX 315MHZ - TX with 315MHZ - RX

  • HI,I checked,The wall switch is labeled with "433.92Mhz", reciever is https://www.ebay.co.uk/itm/Wireless-Arduino-Board-433-Mhz-ARM-MCU-WL-RF-Transmitter-Receiver-Module/383290224258?_trkparms=aid%3D111001%26algo%3DREC.SEED%26ao%3D1%26asc%3D225076%26meid%3De6c2980a03e448be9d95fa63b1712d9d%26pid%3D100675%26rk%3D1%26rkt%3D15%26mehot%3Dnone%26sd%3D383290224258%26itm%3D383290224258%26pmt%3D1%26noa%3D1%26pg%3D2380057&_trksid=p2380057.c100675.m4236&_trkparms=pageci%3A9e380796-6c8a-11ea-95a5-74dbd180ac79%7Cparentrq%3A04508ddc1710ad30d3145344ffc97aa4%7Ciid%3A1. It make me crazy :-( I have to miss smt – user1722245 Mar 22 '20 at 22:15