Go Down

Topic: can't get RF sniffer to work (Read 728 times) previous topic - next topic

Gaetanodd

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 https://github.com/sui77/rc-switch/releases/tag/2.6.2

I am using the following Sketch:

</*
  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 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.

Gaetanodd

Some more info, the plug I used was 2.4Ghz so that one would not work with the 433Mhz shield, so to make sure I had a compatible plug to test with, I just bought one that says 433Mhz and the same thing happens, i.e. nothing, the first IF statement is evaluated as FALSE and the sketch keeps looping around.

KrisAndrews

Hi,

It could be that your 433 MHz sockets use a protocol not known by rc-switch.

I have sockets from Nexa that work totally differently, so I have written some code to read and transmit this protocol, if nothing else it might help you to figure how to control your sockets.

At the moment these are just sketch files, eventually I plan to change them into libraries.

For the 433 MHz I just used some cheap transmitters and receivers from Amazon (around £6 for 3 each!).

https://github.com/kaandrews/Arduino-Nexa-Control

Hope it helps!

Kris.

Gaetanodd


Hi Kris, thanks for your reply. I could be wrong, but I believe that if the protocol was unknown, the message "unknown protocol" would be thrown out by the sketch.

Meanwhile I have read the rcswitch.h file and it includes a variety of other libraries, e.g. if the board is Arduino, include arduino.h, so I copied that library into the rc-switch folder and as I did that, other missing libraries were causing compilation errors. I added them all and now the compilation log says there is an issue compiling for Arduino Genuino/Uno and says something like "if you have ended here, you may need to check the processor on your board", which sounds to me like I am not selecting the right board in the IDE but I am sure it is an Uno board.

Another thing that sounds odd is that I had to copy the libraries into the RC switch folder, aren't those libraries supposed to be available to all sketches through the PATH variable of windows?

I use a clone Uno board, a cheapie one, and I also tried on a more expensive one from OSEPP, same result.

I am now trying to connect the data pin to the in-line of my computer's sound card to record the pulses and verify that the receiver works but no luck so far, Windows doesn't have a decent built-in recorder so I will try Audigy which was recommended in a tutorial.

KrisAndrews

#4
Jan 21, 2018, 06:43 pm Last Edit: Jan 21, 2018, 06:55 pm by KrisAndrews Reason: Forgot one reply..
Hello,
With my transmitter I didn't get anything from rc-switch, no messages at all.

I have heard of people using a sound card and connecting the receiver to it to record the transmission, if you can record a WAV file and get a look at what the transmission looks like then you could quite easily make a sketch to transmit the same code.

That is pretty much what I have just done, but I used a cheap RTL-SDR USB radio to pick up the signal https://www.rtl-sdr.com/buy-rtl-sdr-dvb-t-dongles/ (no affiliation!)

Making the Arduino into a transmitter was a lot easier than programming as a receiver...  I've only been using the Arduino for about 2 months and it was quite a challenge!

Just to give an idea of what you can expect I have attached a screen shot of the transmission my my Nexa system and the copy of it transmitter from the Arduino.  This shows the WAV files zoomed in a lot on Audacity.

As for the headers and libraries, I have never had to manually copy any around.  If the code compiled when you first loaded it then it should be fine, you would get a warning if a library was missing.

If you do get a picture of the transmission feel free to post it or send me a copy and I'll see if I can help.
Cheers,
Kris.

I forgot to mention, I had a look at the code for rc-switch.available()

Code: [Select]
bool RCSwitch::available() {
  return RCSwitch::nReceivedValue != 0;
}


All this does it wait until a code is received and decoded, if rc-switch can't recognise the transmission then it looks like it will just keep looping.

Gaetanodd

Thanks Kris, that helps!

Meanwhile, I have indeed gone down the path of using my audio card in-line and while the first attempt did not produce any results, I realised I had not paired a plug yet, so I paired a plug and then the RC started emitting the expected codes - I guess that made sense to anyone with some experience in the field lol.

I used Audacity and bought a cheap ear-set for $5, ripped off one earpiece and used that to connect to the RF receiver's data pin.

I wonder if the Arduino will also start recording the codes now, I will post a follow-up to confirm.

I am not sure if I will continue down this path because the box of plugs says the codes are changing, so it may prove hard to hack that RC for my project if I need to figure out the algorithm... The other thing about the RC of my plug is that it does not have any soldering, so I am not sure if I can reliably just integrate the PCB board on my own circuit to bypass the decoding requirement altogether because it is not obvious where I need to solder the wires to.

Cheers,
Gaetano.

Go Up