-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from cgmckeever/rf433
RF listener basic settings
- Loading branch information
Showing
11 changed files
with
605 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <RCSwitch.h> | ||
|
||
RCSwitch mySwitch = RCSwitch(); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
Serial.println("LISTEN..."); | ||
|
||
// Arduino Pin2 = 0 | ||
mySwitch.enableReceive(1); | ||
} | ||
|
||
void loop() { | ||
if (mySwitch.available()) { | ||
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), | ||
mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(), | ||
mySwitch.getReceivedProtocol()); | ||
mySwitch.resetAvailable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
static const char* bin2tristate(const char* bin); | ||
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength); | ||
|
||
void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { | ||
|
||
const char* b = dec2binWzerofill(decimal, length); | ||
Serial.print("Decimal: "); | ||
Serial.print(decimal); | ||
Serial.print(" ("); | ||
Serial.print( length ); | ||
Serial.print("Bit) Binary: "); | ||
Serial.print( b ); | ||
Serial.print(" Tri-State: "); | ||
Serial.print( bin2tristate( b) ); | ||
Serial.print(" PulseLength: "); | ||
Serial.print(delay); | ||
Serial.print(" microseconds"); | ||
Serial.print(" Protocol: "); | ||
Serial.println(protocol); | ||
|
||
Serial.print("Raw data: "); | ||
for (unsigned int i=0; i<= length*2; i++) { | ||
Serial.print(raw[i]); | ||
Serial.print(","); | ||
} | ||
Serial.println(); | ||
Serial.println(); | ||
} | ||
|
||
static const char* bin2tristate(const char* bin) { | ||
static char returnValue[50]; | ||
int pos = 0; | ||
int pos2 = 0; | ||
while (bin[pos]!='\0' && bin[pos+1]!='\0') { | ||
if (bin[pos]=='0' && bin[pos+1]=='0') { | ||
returnValue[pos2] = '0'; | ||
} else if (bin[pos]=='1' && bin[pos+1]=='1') { | ||
returnValue[pos2] = '1'; | ||
} else if (bin[pos]=='0' && bin[pos+1]=='1') { | ||
returnValue[pos2] = 'F'; | ||
} else { | ||
return "not applicable"; | ||
} | ||
pos = pos+2; | ||
pos2++; | ||
} | ||
returnValue[pos2] = '\0'; | ||
return returnValue; | ||
} | ||
|
||
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { | ||
static char bin[64]; | ||
unsigned int i=0; | ||
|
||
while (Dec > 0) { | ||
bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0'; | ||
Dec = Dec >> 1; | ||
} | ||
|
||
for (unsigned int j = 0; j< bitLength; j++) { | ||
if (j >= bitLength - i) { | ||
bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; | ||
} else { | ||
bin[j] = '0'; | ||
} | ||
} | ||
bin[bitLength] = '\0'; | ||
|
||
return bin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <RCSwitch.h> | ||
|
||
RCSwitch mySwitch = RCSwitch(); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
Serial.println("TRANSMIT..."); | ||
|
||
// Arduino Pin10 = 10 ... no idea | ||
mySwitch.enableTransmit(10); | ||
|
||
/* | ||
mySwitch.setPulseLength(454); | ||
mySwitch.send(19077140, 26); | ||
delay(15000); | ||
mySwitch.send(19073044, 26); | ||
delay(15000); | ||
mySwitch.send(19075092, 26); | ||
delay(15000); | ||
mySwitch.send(35850260, 26); | ||
delay(15000); | ||
mySwitch.send(35854356, 26); | ||
delay(15000); | ||
mySwitch.send(35852308, 26); | ||
delay(15000); | ||
*/ | ||
|
||
mySwitch.setPulseLength(302); | ||
|
||
// Button 1 | ||
mySwitch.send(10979556, 24); | ||
delay(5000); | ||
mySwitch.send(10979560, 24); | ||
|
||
// Button 2 | ||
mySwitch.send(10979554, 24); | ||
delay(5000); | ||
mySwitch.send(10979553, 24); | ||
|
||
// Button 3 | ||
mySwitch.send(10979557, 24); | ||
delay(5000); | ||
mySwitch.send(10979564, 24); | ||
|
||
|
||
} | ||
|
||
void loop() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Install Driver | ||
|
||
## Resources | ||
|
||
- https://www.rflink.nl/wires.php | ||
|
||
## Nano | ||
|
||
``` | ||
brew tap user/repo [email protected]:adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver | ||
brew cask install wch-ch34x-usb-serial-driver | ||
``` | ||
|
||
|
||
# Known Switches | ||
|
||
## 315 | ||
|
||
### xmas switch | ||
|
||
#### Button 1 | ||
Decimal: 10979556 (24Bit) Binary: 101001111000100011100100 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9396,904,308,304,904,904,316,292,912,300,912,908,304,904,312,900,308,908,304,300,912,296,916,296,916,904,304,308,904,300,912,300,912,908,304,908,304,904,308,300,912,300,912,908,304,300,912,300,912, | ||
|
||
Decimal: 10979554 (24Bit) Binary: 101001111000100011100010 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9396,904,308,304,908,904,312,292,916,300,912,900,312,904,308,904,304,904,308,300,916,300,912,296,916,904,308,300,912,300,912,300,912,904,308,904,308,908,304,296,916,300,912,296,912,908,308,296,916, | ||
|
||
|
||
#### Button 2 | ||
Decimal: 10979557 (24Bit) Binary: 101001111000100011100101 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9396,904,308,304,912,904,312,292,912,300,912,904,308,904,312,904,304,904,308,300,916,292,916,300,912,912,300,300,916,300,912,296,916,904,304,908,304,908,308,296,912,300,912,908,304,304,908,904,308, | ||
|
||
Decimal: 10979560 (24Bit) Binary: 101001111000100011101000 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9396,908,308,304,904,908,312,292,912,296,916,904,308,904,316,896,308,904,308,304,908,296,920,296,912,908,304,300,912,300,912,300,912,904,308,904,308,908,304,300,912,904,308,296,916,296,916,296,916, | ||
|
||
|
||
#### Button 3 | ||
Decimal: 10979553 (24Bit) Binary: 101001111000100011100001 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9392,908,308,300,912,904,308,296,912,300,916,904,304,904,308,904,308,904,308,300,912,300,912,300,912,904,304,304,908,300,916,296,912,908,304,908,304,908,304,300,912,300,916,296,912,300,912,904,308, | ||
|
||
Decimal: 10979564 (24Bit) Binary: 101001111000100011101100 Tri-State: not applicable PulseLength: 302 microseconds Protocol: 1 | ||
Raw data: 9396,904,312,300,912,908,308,292,916,296,916,900,308,904,312,904,308,900,308,300,916,292,916,300,912,904,308,296,916,296,916,296,916,904,312,900,304,904,308,300,916,900,308,904,308,300,912,296,916, | ||
|
||
## 433 | ||
|
||
### xmas switch | ||
|
||
#### On/Off | ||
Decimal: 5155 (16Bit) Binary: 0001010000100011 Tri-State: not applicable PulseLength: 506 microseconds Protocol: 1 | ||
Raw data: 15696,540,1532,476,1532,508,1528,1508,548,460,1524,1512,544,492,1544,492,1524,492,1536,496,1540,1504,528,508,1528,508,1524,488,1544,1516,528,1472,536, | ||
|
||
Decimal: 5132 (16Bit) Binary: 0001010000001100 Tri-State: 0FF00010 PulseLength: 508 microseconds Protocol: 1 | ||
Raw data: 15740,484,1572,488,1532,488,1560,1496,556,444,1560,1532,524,512,1524,460,1544,508,1548,460,1552,516,1536,496,1528,1512,528,1516,524,464,1548,492,1548, | ||
|
||
#### Function | ||
Decimal: 5185 (16Bit) Binary: 0001010001000001 Tri-State: 0FF0F00F PulseLength: 508 microseconds Protocol: 1 | ||
Raw data: 15748,484,1584,432,1604,432,1596,1472,564,460,1568,1484,568,432,1592,460,1556,460,1572,1480,572,444,1572,468,1564,476,1560,456,1592,460,1568,1488,548, | ||
|
||
Decimal: 5186 (16Bit) Binary: 0001010001000010 Tri-State: not applicable PulseLength: 508 microseconds Protocol: 1 | ||
Raw data: 15768,492,1540,468,1568,504,1528,1488,548,488,1548,1508,528,464,1572,496,1508,492,1560,1500,528,504,1528,488,1552,484,1548,504,1552,1472,556,492,1512, | ||
|
||
Decimal: 5187 (16Bit) Binary: 0001010001000011 Tri-State: 0FF0F001 PulseLength: 507 microseconds Protocol: 1 | ||
Raw data: 15736,520,1532,488,1536,496,1536,1504,532,476,1560,1536,520,484,1552,456,1548,500,1552,1496,532,496,1536,496,1556,456,1556,484,1568,1484,548,1476,528, | ||
|
||
Decimal: 5188 (16Bit) Binary: 0001010001000100 Tri-State: 0FF0F0F0 PulseLength: 507 microseconds Protocol: 1 | ||
Raw data: 15748,524,1532,480,1552,516,1520,1504,528,512,1544,1492,548,464,1548,496,1532,492,1560,1496,528,504,1528,484,1552,484,1544,1516,528,464,1584,468,1536, | ||
|
||
### ? | ||
|
||
Decimal: 19073044 (26Bit) Binary: 01001000110000100000010100 Tri-State: not applicable PulseLength: 452 microseconds Protocol: 1 | ||
Raw data: 14028,308,24,48,1404,724,48,452,552,216,16,132,1396,372,1392,592,24,644,508,384,1380,376,1400,372,1388,396,1368,396,1376,1268,504,392,1376,388,1372,396,1376,388,1376,392,1372,388,1380,1272,500,392,1376,1268,504,392,1372,392,1384, | ||
|
||
Decimal: 19075092 (26Bit) Binary: 01001000110001000000010100 Tri-State: not applicable PulseLength: 452 microseconds Protocol: 1 | ||
Raw data: 14008,384,1396,616,100,20,80,168,16,52,48,116,556,368,1404,364,1384,600,68,592,512,380,1384,376,1396,372,1392,1252,516,684,56,516,1368,376,1376,388,1376,392,1368,400,1372,392,1372,1272,496,404,1364,1276,512,388,1372,384,1388, | ||
|
||
Decimal: 19077140 (26Bit) Binary: 01001000110001100000010100 Tri-State: not applicable PulseLength: 452 microseconds Protocol: 1 | ||
Raw data: 14040,288,1680,40,180,40,88,16,268,16,80,48,216,32,576,36,1752,32,192,40,1484,152,120,40,56,44,288,48,104,56,228,104,540,64,64,24,104,64,1436,192,52,16,1508,100,124,40,72,28,1400,812,48,188,60, | ||
|
||
### ? | ||
|
||
Decimal: 35850260 (26Bit) Binary: 10001000110000100000010100 Tri-State: not applicable PulseLength: 452 microseconds Protocol: 1 | ||
Raw data: 14016,288,100,36,72,48,48,44,196,28,940,48,72,40,56,36,1504,48,108,28,96,20,1472,64,96,48,48,68,1428,192,40,24,112,28,68,44,80,16,120,40,56,56,84,40,76,40,80,52,536,96,140,44,1476, | ||
|
||
Decimal: 35854356 (26Bit) Binary: 10001000110001100000010100 Tri-State: not applicable PulseLength: 451 microseconds Protocol: 1 | ||
Raw data: 14000,284,92,96,96,160,120,96,844,52,168,32,92,16,1396,52,56,20,136,40,1464,68,128,16,80,64,1400,208,96,32,60,52,60,20,204,120,64,36,40,32,68,36,88,32,516,96,60,40,104,40,1420,228,20, | ||
|
||
Decimal: 35852308 (26Bit) Binary: 10001000110001000000010100 Tri-State: not applicable PulseLength: 451 microseconds Protocol: 1 | ||
Raw data: 14024,152,20,136,316,24,80,20,180,36,1064,20,1512,40,180,16,1740,24,1508,48,76,20,100,28,164,32,300,28,172,16,116,24,648,116,92,24,100,32,1388,108,80,48,84,16,1432,28,108,32,1608,32,140,24,124, | ||
|
||
### ? | ||
|
||
Decimal: 5393 (24Bit) Binary: 000000000001010100010001 Tri-State: 00000FFF0F0F PulseLength: 357 microseconds Protocol: 1 | ||
Raw data: 10976,768,664,320,1116,320,1108,324,1112,320,1108,320,1116,316,1112,320,1108,324,1108,320,1104,320,1108,1024,400,324,1108,1024,400,320,1108,1024,404,320,1104,324,1108,316,1104,1024,400,324,1104,316,1104,324,1104,1024,396, | ||
|
||
Decimal: 5396 (24Bit) Binary: 000000000001010100010100 Tri-State: 00000FFF0FF0 PulseLength: 357 microseconds Protocol: 1 | ||
Raw data: 10968,764,668,320,1108,328,1108,324,1108,324,1108,328,1108,316,1108,328,1104,320,1108,328,1100,320,1104,1036,396,324,1100,1032,400,324,1100,1032,396,328,1100,324,1100,328,1100,1028,396,320,1100,1028,400,320,1104,328,1096, | ||
|
||
|
||
### Outdoor Lights | ||
|
||
#### ON | ||
|
||
Decimal: 16776961 (24Bit) Binary: 111111111111111100000001 Tri-State: 11111111000F PulseLength: 390 microseconds Protocol: 1 | ||
Raw data: 12084,1192,412,1192,432,1184,408,1208,412,1184,440,1180,408,1188,432,1204,428,1184,404,1204,404,1208,404,1208,404,1208,404,1208,404,1208,404,1204,404,432,1212,408,1208,412,1208,436,1208,412,1212,412,1212,408,1212,1208,412, | ||
|
||
#### OFF | ||
|
||
Decimal: 16776963 (24Bit) Binary: 111111111111111100000011 Tri-State: 111111110001 PulseLength: 389 microseconds Protocol: 1 | ||
Raw data: 12076,1212,396,1224,396,1196,392,1220,416,1196,396,1196,400,1232,400,1208,404,1204,408,1204,404,1208,404,1204,404,1208,400,1208,404,1208,400,1208,404,432,1208,412,1208,412,1208,436,1184,436,1192,440,1188,1216,408,1188,404, | ||
|
||
|
||
#### 8 | ||
|
||
Decimal: 16776975 (24Bit) Binary: 111111111111111100001111 Tri-State: 111111110011 PulseLength: 389 microseconds Protocol: 1 | ||
Raw data: 12072,1220,424,1208,428,1216,404,1208,412,1212,436,1208,412,1208,412,1188,436,1212,408,1212,408,1212,432,1208,408,1208,424,1216,396,1220,416,1224,404,428,1212,408,1208,436,1212,408,1208,1236,408,1208,412,1216,416,1208,404, | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Driver | ||
|
||
- https://github.com/LSatan/SmartRC-CC1101-Driver-Lib | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Example for receiving | ||
https://github.com/sui77/rc-switch/ | ||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib | ||
If you want to visualize a telegram copy the raw data and | ||
paste it into http://test.sui.li/oszi/ | ||
---------------------------------------------------------- | ||
Mod by Little Satan. Have Fun! | ||
---------------------------------------------------------- | ||
*/ | ||
#include <ELECHOUSE_CC1101_SRC_DRV.h> | ||
#include <RCSwitch.h> | ||
|
||
int pin; // int for Receive pin. | ||
|
||
RCSwitch mySwitch = RCSwitch(); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
|
||
//pin = 27; | ||
pin = 0; // nano | ||
|
||
|
||
//CC1101 Settings: (Settings with "//" are optional!) | ||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! | ||
//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. | ||
//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! | ||
|
||
float freq = 433.92; | ||
//float freq = 315; | ||
ELECHOUSE_cc1101.setMHZ(freq); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. | ||
ELECHOUSE_cc1101.SetRx(); // set Receive on | ||
mySwitch.enableReceive(pin); // Receiver on interrupt 0 => that is pin #2 | ||
|
||
Serial.print("receiving: "); | ||
Serial.println(freq); | ||
} | ||
|
||
void loop() { | ||
if (mySwitch.available()) { | ||
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); | ||
mySwitch.resetAvailable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
static const char* bin2tristate(const char* bin); | ||
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength); | ||
|
||
void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { | ||
|
||
const char* b = dec2binWzerofill(decimal, length); | ||
Serial.print("Decimal: "); | ||
Serial.print(decimal); | ||
Serial.print(" ("); | ||
Serial.print( length ); | ||
Serial.print("Bit) Binary: "); | ||
Serial.print( b ); | ||
Serial.print(" Tri-State: "); | ||
Serial.print( bin2tristate( b) ); | ||
Serial.print(" PulseLength: "); | ||
Serial.print(delay); | ||
Serial.print(" microseconds"); | ||
Serial.print(" Protocol: "); | ||
Serial.println(protocol); | ||
|
||
Serial.print("Raw data: "); | ||
for (unsigned int i=0; i<= length*2; i++) { | ||
Serial.print(raw[i]); | ||
Serial.print(","); | ||
} | ||
Serial.println(); | ||
Serial.println(); | ||
} | ||
|
||
static const char* bin2tristate(const char* bin) { | ||
static char returnValue[50]; | ||
int pos = 0; | ||
int pos2 = 0; | ||
while (bin[pos]!='\0' && bin[pos+1]!='\0') { | ||
if (bin[pos]=='0' && bin[pos+1]=='0') { | ||
returnValue[pos2] = '0'; | ||
} else if (bin[pos]=='1' && bin[pos+1]=='1') { | ||
returnValue[pos2] = '1'; | ||
} else if (bin[pos]=='0' && bin[pos+1]=='1') { | ||
returnValue[pos2] = 'F'; | ||
} else { | ||
return "not applicable"; | ||
} | ||
pos = pos+2; | ||
pos2++; | ||
} | ||
returnValue[pos2] = '\0'; | ||
return returnValue; | ||
} | ||
|
||
static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { | ||
static char bin[64]; | ||
unsigned int i=0; | ||
|
||
while (Dec > 0) { | ||
bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0'; | ||
Dec = Dec >> 1; | ||
} | ||
|
||
for (unsigned int j = 0; j< bitLength; j++) { | ||
if (j >= bitLength - i) { | ||
bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; | ||
} else { | ||
bin[j] = '0'; | ||
} | ||
} | ||
bin[bitLength] = '\0'; | ||
|
||
return bin; | ||
} |
Oops, something went wrong.