RC-Switch vs. Radiohead and cheap china motion/door sensors

So, I have searched and search - but found nothing.

I have one of the dreaded MX-RM-5v wireless receiver modules and my goal is to replace the crappy china "GSM Alarm" system with a custom Arduino based system.

The only thing I want to replace is the actual alarm unit itself. All the EXISTING wireless sensors work. I currently have 3 pir sensors and 3 door sensors.

Now, using RC-Switch library, I am able to receive data from these sensors. Each time I trigger one, I get the data (unique to each sensor) and "Protocol 1".

The first issue is: after 5-10 minutes, the rc-switch library simply stops working. I stop receiving any data from all my sensors. Each sensor (when triggered) usually sends the datagram several times. Over the course of a few minutes, the number of received datagrams continues to reduce until I receive NOTHING. Not just one sensor - but all sensors. It seems like the receiver just gradually stops receiving.

Again, please remember that I am talking about re-built wireless sensors here - not custom made devices.

Anyway, if I power the entire arduino OFF for a couple minutes and back on (receiver module included), it starts working again. I have tried 3 of these receiver modules - all have the same issue.

I decided to try the RF Blink code - just to see how the module was behaving. Well, It seems to be working continually. The serial console spews LOTS of data. Continually. Like WAY more than I can even begin to copy/sort through for analyzing. The interesting thing is: even after an HOUR of leaving the system powered on (arduino w/ receiver) I am STILL getting LOTS of data. So I doubt I have a [hardware] issue with the receivers. This seems to be an issue with rc-switch just not coping with all the background noise after a few minutes and slowly dying. At least this is my best guess.

So, I decided to try Radiohead. Few other souls on the interwebs mentioned Radiohead was much better at handling background noise and was kinda the de-facto standard for this stuff now.

Problem with radiohead is: almost no documentation regarding MY application. 22 24 69

What the heck is an rf22, rf24 or rf69? Wireless transmission protocols I assume? How do I determine which I should be using? I tried a couple randomly - to no avail. Under the the rc-switch library, I know these sensors were sending "24 bit, protocol 1" datagrams. Not sure how that fits into the Radiohead library. There are many examples, but virtually NO documentation.

What pins do I use on the Arduino?
What protocol/example should I be using to just "see" some of the sensor data?

The first issue is: after 5-10 minutes, the rc-switch library simply stops working.

Then something is wrong with the code. Post it, using code tags, as described in the "How to use this forum" post.

What the heck is an rf22, rf24 or rf69

Probably radio modules. Be more specific.

The sample code is nothing more than the STOCK rc-switch "ReceiveDemo_Simple". Completely un-modified. Regardless, here it is:

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

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();
  }
}

Okay... if you install the RadioHead library, go to examples. You will see: ask, cc110, rf22, etc.. So exactly my point - some clarification is needed. Are those chipsets? Or are they radio protocols? Under each, there are sub-menus like "rf24_client", "simple_receiver", etc.

ASK is a protocol (amplitude shift keying), used by the cheap 315/433 MHz modules like the MX-RM-5v.

"cc1100, rf22, etc." are radio modules. Most of the radio modules will be incompatible with your alarm system. You have to match both the frequency of transmission and the data encoding protocol.

If the completely unmodified RC-Switch example code stops working, something is wrong with the hardware, most likely your wiring or your receiver. I have been running that code 24/7 for a couple of years.

jremington:
ASK is a protocol modulation format (amplitude shift keying).

deanrantala:
You will see: ask, cc110, rf22, etc.. So exactly my point - some clarification is needed. Are those chipsets? Or are they radio protocols?

What has Google told you?

@gfvalvo: very helpful to the OP, thanks!

Okay..

  1. I understand these are cheap modules, but 3 out of 3? Seriously? Are these modules just not suitable for any real work? Should I buy a better module?

  2. The fact that this starts working (initially) and slowly stops working (receives less and less data until it receives NOTHING) really seems strange.

  3. Using the rc-switch library, I am unable to make this work on my Arduino Nano or Pro Mini period. I have carefully ensured the data pin is connected directly to data pin 2 (interrupt 0). Nothing in both cases. For the Pro Mini, I have a level-shifter in place - ensuring correct 3.3 <-- 5v operation. Same thing: no data period. Connecting back to the Mega, and things work. On 3 different Mega's, at least I receive signals (albiet only for a few minutes). I have tried digital pin 3 (interrupt 1) and edited the ReceiveDemo_Simple accordingly - to no avail.

I am not an electrical engineer, but I have read these receiver modules are almost useless (now that I am researching) and have read countless stories of strange issues and downright unreliable operation. One person in particular mentioned issues with the "gain transistor becoming saturated" and "unable to receive anything".. Perhaps I have the same issue here?

gfvalvo:
What has Google told you?

You assume I am one of them types who do not first check Google?

https://www.google.com/search?q=rf22&oq=rf22+&aqs=chrome..69i57j0l5.6720j0j4&sourceid=chrome&ie=UTF-8

Google just leads me back to the same useless info regarding the RC-Switch library. And the library does not really explain any of it.

I have actually spent the better part of last night and this morning searching for answers before bothering anyone.

It would be nice to find a post that says "The XXX chip found in common ebay-sourced PIR sensors for the GSM alarm systems typically use a protocol known as "X protocol" and "If you are using such sensors with the RadioHead library, you need to ensure you are using driver XX". Not that I am looking for the info to be spoon fed, but a little insight to know - at least - where to start LOOKING for the answers is all I need.

On another note... I have noticed something strange.... You all ready for this one?

The transmitters.. To test them, I have simply been turning them on and then back off again. When initially turned on, they broadcast an initial set of datagrams. Now, typically after doing this several times over the course of a few minutes, I stop receiving the datagrams on the Arduino end.

BUT.. If I leave the sensor ON, and just wave my hand (legitimately triggering the sensor) - so far things have not stopped working.

I have had TWO megas connected side-by-side with TWO receivers. One running RF Blink (and watching the data stream across a serial terminal) and another running the ReceiveDemo_simple - also with a serial terminal connected. Before - when I was power-cycling the sensors to trigger the signal and the receiving (rc-switch) would start to die - I could verify that the signals were still flying across the air (for lack of better vocabulary). So this certainly seems to be between the receiver module and rc-switch.

I have read these receiver modules are almost useless

That is not at all true. Those modules are fine, given their limitations, and I've been using them for years as well. They are insensitive and broad band, but you can pay more for ones that work better. But they do work, and are very reliable.

Until you know for certain what frequency and transmission protocol of your alarm system uses, it is impossible to debug. Post a link to the alarm system or the user manual.

If the operating frequency is 315 or 433 MHz, then one of those cheap receivers will get a signal that might or might not be correctly interpreted by any code you run. However, in that case you can follow the methods described in this blog article to learn more about the system.

The alarm system I have is this:

https://www.amazon.com/GULUBO-Wireless-Business-Security-Infrared/dp/B079HT7L91/ref=sr_1_3?ie=UTF8&qid=1529621817&sr=8-3&keywords=gsm+alarm&dpID=51d31MVK5XL&preST=_SY300_QL70_&dpSrc=srch

Yes, it is 433mhz. Currently, we are at several hours now and it is still receiving. Nothing has been changed other than the fact I am not power cycling the motion sensors every 10-15 seconds. Now that I have left them on, the receiver has maintained functionality since this morning. Very strange.

I notice one thing: when I turn a motion sensor OFF, it transmits some garbled crap for a few seconds (nothing that is detected by the rc-switch library as usable data, because I get no printed packets) - but random data nonetheless.

Honestly, I believe I may have found a bug with the rc-switch library here.

When I purposely power cycle one (any one) of these sensors on/off several times in a 20 second time period - it essentially crashes the rc-switch library. I think there is certainly something strange going on at the software level regarding that library.

Yeah - range sucks. But so far, it is working.

Basic advice to anyone who comes across this post with an issue same as I have had:

  1. Don't waste your time with Radiohead. Lack of documentation regarding this library makes using it for the given application too much of a challenge (at least at this time). RC Switch seems to function just fine with these devices using the ReceiveDemo_Simple the comes with the library.

  2. There seems to be an apparent bug between the china 433mhz wireless sensors and the rc-switch library. However - if you are not power-cycling the sensors on a regular basis - this should not affect you.

So, the motion sensors and door sensors are being detected, remotes work somewhat - range is not more than .5 meters.

I think it is time to find a better receiver.

The RC-Switch library is really pretty primitive and there are a large number of variants of the basic protocol. The library is not reliable if the timing is not correct.

I recently ran across yet another variation of the protocol, which was misidentified by the standard library.

Analyzing the signal using the technique described here allowed me to update the RC-Switch library and obtain extremely reliable communications.

Genuine superheterodyne versions of the receivers work better than the superregenerative versions.

deanrantala:

  1. Don't waste your time with Radiohead. Lack of documentation regarding this library makes using it for the given application too much of a challenge (at least at this time)

Personally, I wish all libraries were as well-documented as RadioHead. All the classes and methods are annotated via Doxygen: RadioHead: Class List
And, it's relatively easy to grab its example programs and modify them to your needs.

Now the caveat to the above, it's most likely not the right library for OP's application. It's geared towards transferring data (i.e. remote sensors, etc), not simple control / detection. So, I too would probably go a different route for this application.

One last comment - just in case anyone comes here from a Google search...

The reception quality of the receiver is easily improved to that of most chinese-made commercial 433mhz products by winding up some .6 mm (~22-24 ga) wire into a coil as shown here:

The reception went from horrible-to-barely okay to.. just as I would expect any 433mhz device to perform in an average home. Easily reaches over 30 meters now - and even penetrates multiple concrete walls.

All in all, hope the next person pulling their hair out finds this useful. My journey today took me from about to throw all the receivers out to considering buying another 5-pack for the next project.

Coiled antennas work, but a much, MUCH better antenna is a balanced dipole, as shown below. I easily get 300 meters range line of sight. Length is 33 cm from tip to tip. Connect one end to ANT and the other to GND (yes, the "other" antenna terminal).