rc-switch
rc-switch copied to clipboard
Universal receiver and sniffer and protocol generator
Update 2017/04/30:
Working on Raspberry Pi, ESP8266, and Arduino (tested).
Use:
git clone -b protocollessreceiver https://github.com/Martin-Laclaustra/rc-switch.git
Among the examples, the sketch "ProtocolAnalyzeDemo" ease the creation of new protocols.
This works for single-sync-gap protocols with uniform width bits (all bits have the same length).
======================= Dear Suat and collaborators, thank you for your work developing the library. I have seen the request for receiving codes for unknown protocols and I have explored some ideas in a fork. It works (~~except for the inverted protocols~~) and receives the information regardless that the protocol is unkown. It is currently the "protocollessreceiver" branch at my fork. I added lots of comments, and the commits are also quite explicit. The changes can be reviewed in chronological order across the commits history to get the idea. Detection is based on repetition of the duration of a longer gap, and then regularity of the length of the bits read between those gaps. I created a verbose sniffer that performs a complete description of the signal received and proposes a protocol that can be copied directly into the protocol list if the aim is to generate new signals. I tested this on Raspberry pi because I do not have Arduino. However you should not have problems porting it to Arduino for testing.
To test this in Raspberry pi, once the wiringpi library is installed:
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
write:
git clone -b verbosesnifferwithprotocollessreceiver --single-branch --recursive git://github.com/Martin-Laclaustra/433Utils.git
cd 433Utils/RPi_utils
edit RFSniffer.cpp to set your PIN in the line "int PIN = 2;"
make
sudo ./RFSniffer -v
I sent from another unit (as an example):
sudo ./codesend 12345 4
and got the following:
Received 12345
=============================================
=============================================
GENERAL
=======
Received 12345
Bitlength 24
Protocol 4
Delay(short pulse length in us) 458
(delay from rc-switch is calculated from the sync gap and requires previous knowledge of the protocol)
(The following assumes protocols that detect the low period of sync)
(The next information is probably wrong for inverted protocols)
Sync bit high-low durations (in us) 442 2352
RAW SIGNAL (us)
===============
2352
479 1174 468 1187 476 1184 470 1183 472 1182 475 1184 472 1188 463 1193
467 1192 463 1189 1223 428 1224 437 457 1206 452 1207 450 1206 447 1206
453 1201 455 1203 1208 459 1197 449 1206 451 441 1213 444 1209 1204 455
442
STATISTICS
==========
Data bit duration = 1656 and standard deviation (should be less than 10%) = 4.36
Do not use the rest of the information if big standard deviation
Long-to-short duration ratio for data bits (rounded) 3
Short duration (delay) recalculated from rounded ratio and average bit duration 414
Sync bit (in multiples of the previous short duration) 1 6
Proposed protocol for RCswitch
{ 414, { 1, 6 }, { 1, 3 }, { 3, 1 }, false }
Note: inverted protocol is not implemented
STATISTICS OF VARIATION BY LEVELS
=================================
(These are probably artifacts from detection delays or signal creation)
(might be completely ignored, but pay attention to them if big differences are present and emission does not work)
number of bits set (in 12345): 6
longup, longdown, shortup, shortdown
1210, 1194, 461, 446
this might be useful for tweaking emmitting algorithms
=============================================
=============================================
I hope that this can be useful to figure out new protocols (or to be used directly for detection). The library should work almost exactly like the original (except ~~for inverted protocols, and~~ might be too permissive in identifying the protocol), and returns all data and protocol, and protocol is set to 0 when no protocol roughly matches.