Skip to content

Instantly share code, notes, and snippets.

@ridingintraffic
Created October 28, 2016 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ridingintraffic/1cd7476361648d977edb818cd8125be9 to your computer and use it in GitHub Desktop.
Save ridingintraffic/1cd7476361648d977edb818cd8125be9 to your computer and use it in GitHub Desktop.
/*
RF_Sniffer
Hacked from http://code.google.com/p/rc-switch/
by @justy to provide a handy RF code sniffer
*/
#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()) {
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment