HI there,
I am new to Arduino and am trying to read RF signals form my remote plug switch so I can command it with Arduino.
I downloaded the RCSwitch library and samples from Release 2.6.2 · sui77/rc-switch · GitHub
I am using the following Sketch:
</*
Simple example for receiving
*/
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
Serial.print("Starting to receive");
}
void loop() {
if (mySwitch.available()) {
Serial.print("switch available");
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();
}else {
Serial.print("switch wasn't available");
}
}>
Initially nothing was happening at all despite the sketch loading successfully so I have inserted some Serial.print statements to the original code to understand if anything was happening at all. As it is now, the serial monitor continuously displays "switch was not available", i.e. the mySwith.available() command returns FALSE and bypasses the whole sketch.
I am not sure what this means... how is a Switch identified and detected under the RCSwitch.h file?
I have operated my car key door lock and my plug switch close to the receiver and nothing shows on the serial monitor.
I am attaching the library as well and it is installed under C:\Program Files (x86)\Arduino\libraries\rc-switch-2.6.2.
The receiver I have is was sold as a 433mhz chip with 8 pins, the marking on the chip's board reads 434 though, not sure if this is important. The only other meaningful marking I can detect on the receiver is RXN3-B rev1 (datasheet for the receiver is available here: https://upverter.com/datasheet/bbd798d8c2942000f05de5a1adbcec92cf567e67.pdf) and i bought it from Jaycar a reputable electronics shop in Australia).
I have measured the voltage on the receiver and it does get 5v.
Any help in troubleshooting this issue would be much appreciated.
Cheers,
Gaetano.
RCSwitch.h (5.03 KB)