first commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
//New receiving method. This method checks the Rx Fifo for any data it contains.
|
||||
//It allows you to do several things in a loop.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
void setup(){
|
||||
|
||||
Serial.begin(9600);
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Rx Mode");
|
||||
}
|
||||
|
||||
byte buffer[61] = {0};
|
||||
|
||||
void loop(){
|
||||
|
||||
//Checks whether something has been received.
|
||||
//When something is received we give some time to receive the message in full.(time in millis)
|
||||
if (ELECHOUSE_cc1101.CheckRxFifo(100)){
|
||||
|
||||
//CRC Check. If "setCrc(false)" crc returns always OK!
|
||||
if (ELECHOUSE_cc1101.CheckCRC()){
|
||||
|
||||
//Rssi Level in dBm
|
||||
Serial.print("Rssi: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getRssi());
|
||||
|
||||
//Link Quality Indicator
|
||||
Serial.print("LQI: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getLqi());
|
||||
|
||||
//Get received Data and calculate length
|
||||
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
|
||||
buffer[len] = '\0';
|
||||
|
||||
//Print received in char format.
|
||||
Serial.println((char *) buffer);
|
||||
|
||||
//Print received in bytes format.
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.print(buffer[i]);
|
||||
Serial.print(",");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//New receiving method. This method checks the Rx Fifo for any data it contains.
|
||||
//It allows you to do several things in a loop.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
void setup(){
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
|
||||
Serial.println("Rx Mode");
|
||||
}
|
||||
byte buffer[61] = {0};
|
||||
|
||||
void loop(){
|
||||
|
||||
//Checks whether something has been received.
|
||||
//When something is received we give some time to receive the message in full.(time in millis)
|
||||
if (ELECHOUSE_cc1101.CheckRxFifo(100)){
|
||||
|
||||
if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK!
|
||||
Serial.print("Rssi: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getRssi());
|
||||
Serial.print("LQI: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getLqi());
|
||||
|
||||
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *) buffer);
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.print(buffer[i]);
|
||||
Serial.print(",");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
//New transmission method.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};
|
||||
char *transmitt_char = "Hello World";
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//3 different methods to send data without gdo
|
||||
//When sending, we give a little time to completely transmit the message (time in millis).
|
||||
//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.
|
||||
|
||||
//Transmitt "Hello World" from byte format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_char, 100);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format directly.
|
||||
ELECHOUSE_cc1101.SendData("Hello World", 100);
|
||||
delay(2000);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//New transmission method.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};
|
||||
char *transmitt_char = "Hello World";
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
// 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!
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//3 different methods to send data without gdo
|
||||
//When sending, we give a little time to completely transmit the message (time in millis).
|
||||
//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.
|
||||
|
||||
//Transmitt "Hello World" from byte format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_char, 100);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format directly.
|
||||
ELECHOUSE_cc1101.SendData("Hello World", 100);
|
||||
delay(2000);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//New transmission method.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
const int n = 61;
|
||||
byte buffer[n] = "";
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//When sending, we give a little time to completely transmit the message (time in millis).
|
||||
//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.
|
||||
|
||||
if (Serial.available()) {
|
||||
int len = Serial.readBytesUntil('\n', buffer, n);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *)buffer);
|
||||
ELECHOUSE_cc1101.SendData(buffer, len, 100);
|
||||
Serial.print("Buffer: ");
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.println(buffer[i]);
|
||||
}
|
||||
Serial.print("len: ");
|
||||
Serial.println(len);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//New transmission method.
|
||||
//In addition, the gdo0 and gdo2 pin are not required.
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
//by Little_S@tan
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
const int n = 61;
|
||||
byte buffer[n] = "";
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
// 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!
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//When sending, we give a little time to completely transmit the message (time in millis).
|
||||
//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.
|
||||
|
||||
if (Serial.available()) {
|
||||
int len = Serial.readBytesUntil('\n', buffer, n);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *)buffer);
|
||||
ELECHOUSE_cc1101.SendData(buffer, len, 100);
|
||||
Serial.print("Buffer: ");
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.println(buffer[i]);
|
||||
}
|
||||
Serial.print("len: ");
|
||||
Serial.println(len);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
void setup(){
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Rx Mode");
|
||||
}
|
||||
|
||||
byte buffer[61] = {0};
|
||||
|
||||
void loop(){
|
||||
|
||||
//Checks whether something has been received.
|
||||
if (ELECHOUSE_cc1101.CheckReceiveFlag()){
|
||||
|
||||
//CRC Check. If "setCrc(false)" crc returns always OK!
|
||||
if (ELECHOUSE_cc1101.CheckCRC()){
|
||||
|
||||
//Rssi Level in dBm
|
||||
Serial.print("Rssi: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getRssi());
|
||||
|
||||
//Link Quality Indicator
|
||||
Serial.print("LQI: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getLqi());
|
||||
|
||||
//Get received Data and calculate length
|
||||
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
|
||||
buffer[len] = '\0';
|
||||
|
||||
//Print received in char format.
|
||||
Serial.println((char *) buffer);
|
||||
|
||||
//Print received in bytes format.
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.print(buffer[i]);
|
||||
Serial.print(",");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
void setup(){
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
|
||||
Serial.println("Rx Mode");
|
||||
}
|
||||
byte buffer[61] = {0};
|
||||
|
||||
void loop(){
|
||||
|
||||
if (ELECHOUSE_cc1101.CheckReceiveFlag()){
|
||||
|
||||
if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK!
|
||||
Serial.print("Rssi: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getRssi());
|
||||
Serial.print("LQI: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getLqi());
|
||||
|
||||
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *) buffer);
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.print(buffer[i]);
|
||||
Serial.print(",");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};
|
||||
char *transmitt_char = "Hello World";
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//3 different methods to send data
|
||||
|
||||
//Transmitt "Hello World" from byte format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_byte, 11);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_char);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format directly.
|
||||
ELECHOUSE_cc1101.SendData("Hello World");
|
||||
delay(2000);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};
|
||||
char *transmitt_char = "Hello World";
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
// 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!
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
//3 different methods to send data
|
||||
|
||||
//Transmitt "Hello World" from byte format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_byte, 11);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format.
|
||||
ELECHOUSE_cc1101.SendData(transmitt_char);
|
||||
delay(2000);
|
||||
|
||||
//Transmitt "Hello World" from char format directly.
|
||||
ELECHOUSE_cc1101.SendData("Hello World");
|
||||
delay(2000);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
const int n = 61;
|
||||
byte buffer[n] = "";
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
|
||||
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
|
||||
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
|
||||
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.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
|
||||
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!
|
||||
ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
|
||||
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
|
||||
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
|
||||
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
|
||||
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.
|
||||
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved
|
||||
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
|
||||
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
|
||||
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.
|
||||
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
|
||||
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
|
||||
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
|
||||
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (Serial.available()) {
|
||||
int len = Serial.readBytesUntil('\n', buffer, n);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *)buffer);
|
||||
ELECHOUSE_cc1101.SendData(buffer, len);
|
||||
Serial.print("Buffer: ");
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.println(buffer[i]);
|
||||
}
|
||||
Serial.print("len: ");
|
||||
Serial.println(len);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// These examples are from the Electronics Cookbook by Simon Monk
|
||||
//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
// mod by Little_S@tan
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
|
||||
int gdo0;
|
||||
|
||||
const int n = 61;
|
||||
byte buffer[n] = "";
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.
|
||||
#else
|
||||
gdo0 = 6; // for Arduino! GDO0 on pin 6.
|
||||
#endif
|
||||
|
||||
Serial.begin(9600);
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
|
||||
ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.
|
||||
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.
|
||||
ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
|
||||
// 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!
|
||||
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
|
||||
Serial.println("Tx Mode");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (Serial.available()) {
|
||||
int len = Serial.readBytesUntil('\n', buffer, n);
|
||||
buffer[len] = '\0';
|
||||
Serial.println((char *)buffer);
|
||||
ELECHOUSE_cc1101.SendData(buffer, len);
|
||||
Serial.print("Buffer: ");
|
||||
for (int i = 0; i<len; i++){
|
||||
Serial.println(buffer[i]);
|
||||
}
|
||||
Serial.print("len: ");
|
||||
Serial.println(len);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Basic ESPiLight receive raw (pulse train) signal example
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
int RECEIVER_PIN; // any intterupt able pin
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
|
||||
|
||||
// callback function. It is called on successfully received and parsed rc signal
|
||||
void rfRawCallback(const uint16_t* codes, size_t length) {
|
||||
// print pulse lengths
|
||||
Serial.print("RAW signal: ");
|
||||
for (unsigned int i = 0; i < length; i++) {
|
||||
Serial.print(codes[i]);
|
||||
Serial.print(' ');
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// format of pilight USB Nano
|
||||
String data = rf.pulseTrainToString(codes, length);
|
||||
Serial.print("string format: ");
|
||||
Serial.print(data);
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// set callback funktion for raw messages
|
||||
rf.setPulseTrainCallBack(rfRawCallback);
|
||||
// inittilize receiver
|
||||
rf.initReceiver(RECEIVER_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// process input queue and may fire calllback
|
||||
rf.loop();
|
||||
delay(10);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Basic ESPilight receive example
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
int RECEIVER_PIN; // any intterupt able pin
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
|
||||
|
||||
// callback function. It is called on successfully received and parsed rc signal
|
||||
void rfCallback(const String &protocol, const String &message, int status,
|
||||
size_t repeats, const String &deviceID) {
|
||||
Serial.print("RF signal arrived [");
|
||||
Serial.print(protocol); // protocoll used to parse
|
||||
Serial.print("][");
|
||||
Serial.print(deviceID); // value of id key in json message
|
||||
Serial.print("] (");
|
||||
Serial.print(status); // status of message, depending on repeat, either:
|
||||
// FIRST - first message of this protocoll within the
|
||||
// last 0.5 s
|
||||
// INVALID - message repeat is not equal to the
|
||||
// previous message
|
||||
// VALID - message is equal to the previous message
|
||||
// KNOWN - repeat of a already valid message
|
||||
Serial.print(") ");
|
||||
Serial.print(message); // message in json format
|
||||
Serial.println();
|
||||
|
||||
// check if message is valid and process it
|
||||
if (status == VALID) {
|
||||
Serial.print("Valid message: [");
|
||||
Serial.print(protocol);
|
||||
Serial.print("] ");
|
||||
Serial.print(message);
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// set callback funktion
|
||||
rf.setCallback(rfCallback);
|
||||
// inittilize receiver
|
||||
rf.initReceiver(RECEIVER_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// process input queue and may fire calllback
|
||||
rf.loop();
|
||||
delay(10);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Basic ESPiLight transmit RAW signal example
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.
|
||||
#else
|
||||
TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.SetTx(); // cc1101 set Transmit on
|
||||
|
||||
ESPiLight rf(TRANSMITTER_PIN);
|
||||
|
||||
int length = 0;
|
||||
uint16_t codes[MAXPULSESTREAMLENGTH];
|
||||
|
||||
// get pulse train from string (format see: pilight USB Nano)
|
||||
length = rf.stringToPulseTrain(
|
||||
"c:102020202020202020220202020020202200202200202020202020220020202203;p:"
|
||||
"279,2511,1395,9486@",
|
||||
codes, MAXPULSESTREAMLENGTH);
|
||||
|
||||
// transmit the pulse train
|
||||
rf.sendPulseTrain(codes, length);
|
||||
}
|
||||
|
||||
// Toggle state of elro 800 switch evrey 2 s
|
||||
void loop() {
|
||||
// stop
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
Basic ESPiLight transmit example
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.
|
||||
#else
|
||||
TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.SetTx(); // cc1101 set Transmit on
|
||||
}
|
||||
|
||||
// Toggle state of elro 800 switch evrey 2 s
|
||||
void loop() {
|
||||
ESPiLight rf(TRANSMITTER_PIN);
|
||||
rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"on\":1}");
|
||||
delay(2000);
|
||||
rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"off\":1}");
|
||||
delay(2000);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Basic ESPiLight pilight_debug example
|
||||
|
||||
This example mimic the output of the piligh_debug tool.
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
#define PULSE_DIV 34
|
||||
|
||||
int RECEIVER_PIN; // any intterupt able pin
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
|
||||
|
||||
unsigned int normalize(unsigned int i, unsigned int pulselen) {
|
||||
double x;
|
||||
x = (double)i / pulselen;
|
||||
|
||||
return (unsigned int)(round(x));
|
||||
}
|
||||
|
||||
// callback function. It is called on successfully received and parsed rc signal
|
||||
void rfRawCallback(const uint16_t* pulses, size_t length) {
|
||||
uint16_t pulse;
|
||||
uint16_t pulselen = pulses[length - 1] / PULSE_DIV;
|
||||
if (pulselen > 25) {
|
||||
for (unsigned int i = 3; i < length; i++) {
|
||||
if ((pulses[i] / pulselen) >= 2) {
|
||||
pulse = pulses[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (normalize(pulse, pulselen) > 0 && length > 25) {
|
||||
/* Print everything */
|
||||
Serial.println("--[RESULTS]--");
|
||||
Serial.println();
|
||||
Serial.print("time:\t\t");
|
||||
Serial.print(millis());
|
||||
Serial.println(" ms");
|
||||
Serial.println("hardware:\tESPiLight");
|
||||
Serial.print("pulse:\t\t");
|
||||
Serial.println(normalize(pulse, pulselen));
|
||||
Serial.print("rawlen:\t\t");
|
||||
Serial.println(length);
|
||||
Serial.printf("pulselen:\t");
|
||||
Serial.println(pulselen);
|
||||
Serial.println();
|
||||
Serial.println("Raw code:");
|
||||
for (unsigned int i = 0; i < length; i++) {
|
||||
Serial.print(pulses[i]);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// set callback funktion for raw messages
|
||||
rf.setPulseTrainCallBack(rfRawCallback);
|
||||
// inittilize receiver
|
||||
rf.initReceiver(RECEIVER_PIN);
|
||||
|
||||
Serial.println(
|
||||
"Press and hold one of the buttons on your remote or wait until");
|
||||
Serial.println("another device such as a weather station has sent new codes");
|
||||
Serial.println(
|
||||
"The debugger will automatically reset itself after one second of");
|
||||
Serial.println(
|
||||
"failed leads. It will keep running until you explicitly stop it.");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// process input queue and may fire calllback
|
||||
rf.loop();
|
||||
delay(10);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Basic ESPiLight pilight_raw example
|
||||
|
||||
This example mimic the output of the piligh_raw tool.
|
||||
|
||||
https://github.com/puuu/espilight
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <ESPiLight.h>
|
||||
|
||||
int RECEIVER_PIN; // any intterupt able pin
|
||||
int TRANSMITTER_PIN;
|
||||
|
||||
ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter
|
||||
|
||||
// callback function. It is called on successfully received and parsed rc signal
|
||||
void rfRawCallback(const uint16_t* pulses, size_t length) {
|
||||
Serial.print("ESPiLight:");
|
||||
for (unsigned int i = 0; i < length; i++) {
|
||||
Serial.print(" ");
|
||||
Serial.print(pulses[i]);
|
||||
if (pulses[i] > 5100) {
|
||||
Serial.printf(" -# ");
|
||||
Serial.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// set callback funktion for raw messages
|
||||
rf.setPulseTrainCallBack(rfRawCallback);
|
||||
// inittilize receiver
|
||||
rf.initReceiver(RECEIVER_PIN);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// process input queue and may fire calllback
|
||||
rf.loop();
|
||||
delay(10);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Demo for RF remote switch receiver.
|
||||
* This example is for the new KaKu / Home Easy type of remotes!
|
||||
*
|
||||
* For details, see NewRemoteReceiver.h!
|
||||
*
|
||||
* With this sketch you can control a LED connected to digital pin 4,
|
||||
* after the sketch learned the code. After start, the LED starts to blink,
|
||||
* until a valid code has been received. The led stops blinking. Now you
|
||||
* can control the LED with the remote.
|
||||
*
|
||||
* Note: only unit-switches are supported in this sketch, no group or dim.
|
||||
*
|
||||
* Arduino only!
|
||||
*
|
||||
* https://github.com/1technophile/NewRemoteSwitch
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
* ----------------------------------------------------------
|
||||
* Mod by Little Satan. Have Fun!
|
||||
* ----------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
|
||||
|
||||
int pin = 0; // int for Receive pin.
|
||||
int led = 4; // pin for Led.
|
||||
|
||||
boolean codeLearned = false;
|
||||
unsigned long learnedAddress;
|
||||
byte learnedUnit;
|
||||
|
||||
void setup() {
|
||||
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// LED-pin as output
|
||||
pinMode(led, OUTPUT);
|
||||
|
||||
// Init a new receiver on interrupt pin 0, minimal 2 identical repeats, and callback set to processCode.
|
||||
NewRemoteReceiver::init(pin, 2, processCode);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Blink led until a code has been learned
|
||||
if (!codeLearned) {
|
||||
digitalWrite(13, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(13, LOW);
|
||||
delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
// Callback function is called only when a valid code is received.
|
||||
void processCode(NewRemoteCode receivedCode) {
|
||||
// A code has been received.
|
||||
// Do we already know the code?
|
||||
if (!codeLearned) {
|
||||
// No! Let's learn the received code.
|
||||
learnedAddress = receivedCode.address;
|
||||
learnedUnit = receivedCode.unit;
|
||||
codeLearned = true;
|
||||
} else {
|
||||
// Yes!
|
||||
// Is the received code identical to the learned code?
|
||||
if (receivedCode.address == learnedAddress && receivedCode.unit == learnedUnit) {
|
||||
// Yes!
|
||||
// Switch the LED off if the received code was "off".
|
||||
// Anything else (on, dim, on_with_dim) will switch the LED on.
|
||||
if (receivedCode.switchType == NewRemoteCode::off) {
|
||||
digitalWrite(13, LOW);
|
||||
} else {
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Demo for RF remote switch receiver.
|
||||
* For details, see NewRemoteReceiver.h!
|
||||
*
|
||||
* Connect the transmitter to digital pin 6.
|
||||
*
|
||||
* This sketch demonstrates the use of the NewRemoteTransmitter class.
|
||||
*
|
||||
* When run, this sketch switches some pre-defined devices on and off in a loop.
|
||||
*
|
||||
* NOTE: the actual receivers have the address and group numbers in this example
|
||||
* are only for demonstration! If you want to duplicate an existing remote, please
|
||||
* try the "retransmitter"-example instead.
|
||||
*
|
||||
* To use this actual example, you'd need to "learn" the used code in the receivers
|
||||
* This sketch is unsuited for that.
|
||||
*
|
||||
*
|
||||
* https://github.com/1technophile/NewRemoteSwitch
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
* ----------------------------------------------------------
|
||||
* Mod by Little Satan. Have Fun!
|
||||
* ----------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <NewRemoteTransmitter.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.SetTx(); // cc1101 set Transmit on
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Create a transmitter on address 123, using digital pin 6 to transmit,
|
||||
// with a period duration of 260ms (default), repeating the transmitted
|
||||
// code 2^3=8 times.
|
||||
NewRemoteTransmitter transmitter(123, pin, 260, 3);
|
||||
|
||||
// Switch unit 2 off
|
||||
transmitter.sendUnit(2, false);
|
||||
|
||||
// Switch all devices in the group off
|
||||
transmitter.sendGroup(false);
|
||||
|
||||
// Set unit 1 to dim-level 3 (range 0-15)
|
||||
transmitter.sendDim(1, 3);
|
||||
|
||||
// Wait 5 seconds
|
||||
delay(5000);
|
||||
|
||||
|
||||
// Switch unit 2 on
|
||||
transmitter.sendUnit(2, true);
|
||||
|
||||
// Switch all devices in the group on
|
||||
transmitter.sendGroup(true);
|
||||
|
||||
// Set unit 1 to dim-level 15, full brightness.
|
||||
transmitter.sendDim(1, 15);
|
||||
|
||||
// Wait 5 seconds
|
||||
delay(5000);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Demo for RF remote switch receiver.
|
||||
* For details, see NewRemoteReceiver.h!
|
||||
*
|
||||
*
|
||||
* When run, this sketch waits for a valid code from a new-style the receiver,
|
||||
* decodes it, and retransmits it after 1 seconds.
|
||||
*
|
||||
*
|
||||
* https://github.com/1technophile/NewRemoteSwitch
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
* ----------------------------------------------------------
|
||||
* Written by Roman.(Arduino Forum) THX!
|
||||
* Mod by Little Satan. Have Fun!
|
||||
* ----------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
#include <NewRemoteTransmitter.h>
|
||||
|
||||
int pinTx; // int for Receive pin.
|
||||
int pinRx; // int for Receive pin.
|
||||
int Interr = 2; // Interrupt Numer
|
||||
int Anz = 3; // number of retransmissions
|
||||
int Tw = 0; // Wait Miliseconds before sending
|
||||
|
||||
int debug = 1; // Debugmode ein (1)/aus(0)
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
// See example ShowReceivedCode for info on this
|
||||
NewRemoteReceiver::init(pinRx, Interr, ReTrans);
|
||||
if (debug == 1) {Serial.println("Receiver initialized... ");}}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void ReTrans(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType){ // Disable the receiver; otherwise it might pick up the retransmit as well.
|
||||
|
||||
if (debug == 1) {
|
||||
// Print the received code.
|
||||
Serial.print("Receiver: ");
|
||||
Serial.print("Code: ");
|
||||
Serial.print(address);
|
||||
Serial.print(" unit: ");
|
||||
Serial.print(unit);
|
||||
Serial.print(" switchType: ");
|
||||
Serial.print(switchType);
|
||||
Serial.print(" Period: ");
|
||||
Serial.print(period);
|
||||
Serial.print(" groupBit: ");
|
||||
Serial.println(groupBit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (debug == 1) {Serial.print("Send: Receiver disable... ");}
|
||||
NewRemoteReceiver::disable();
|
||||
|
||||
// Need interrupts for delay()
|
||||
interrupts();
|
||||
|
||||
if (debug == 1) {Serial.print("Wait... ");}
|
||||
|
||||
// Wait 1 seconds before sending.
|
||||
delay(Tw);
|
||||
|
||||
|
||||
|
||||
ELECHOUSE_cc1101.SetTx(); // set Transmit on
|
||||
// Create a new transmitter with the received address and period, use digital pin as output pin
|
||||
NewRemoteTransmitter transmitter(address, pinTx, period, Anz);
|
||||
if (debug == 1) {Serial.print("Send: Addr " + String(address) + " unit " + String(unit)+" "+ String(switchType)+", period: "+String(period)+" " );}
|
||||
|
||||
// On/Off signal received
|
||||
bool isOn = switchType == NewRemoteCode::on;
|
||||
|
||||
if (groupBit) {
|
||||
// Send to the group
|
||||
transmitter.sendGroup(isOn);
|
||||
}
|
||||
else {
|
||||
// Send to a single unit
|
||||
transmitter.sendUnit(unit, isOn);
|
||||
}
|
||||
|
||||
if (debug == 1) {Serial.println("Receiver enable!");}
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
NewRemoteReceiver::enable();
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Demo for RF remote switch receiver.
|
||||
* For details, see NewRemoteReceiver.h!
|
||||
*
|
||||
*
|
||||
* When run, this sketch waits for a valid code from a new-style the receiver,
|
||||
* decodes it, and retransmits it after 5 seconds.
|
||||
*
|
||||
* Notes: Arduino only!!!
|
||||
*
|
||||
* https://github.com/1technophile/NewRemoteSwitch
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
* ----------------------------------------------------------
|
||||
* Mod by Little Satan. Have Fun!
|
||||
* ----------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
#include <NewRemoteTransmitter.h>
|
||||
|
||||
void setup() {
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// See example ShowReceivedCode for info on this
|
||||
NewRemoteReceiver::init(0, 2, retransmitter);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void retransmitter(NewRemoteCode receivedCode) {
|
||||
// Disable the receiver; otherwise it might pick up the retransmit as well.
|
||||
NewRemoteReceiver::disable();
|
||||
|
||||
// Need interrupts for delay()
|
||||
interrupts();
|
||||
|
||||
// Wait 5 seconds before sending.
|
||||
delay(5000);
|
||||
|
||||
// Create a new transmitter with the received address and period, use digital pin as output pin
|
||||
|
||||
ELECHOUSE_cc1101.SetTx(); // set Transmit on
|
||||
NewRemoteTransmitter transmitter(receivedCode.address, 6, receivedCode.period);
|
||||
|
||||
if (receivedCode.switchType == NewRemoteCode::dim ||
|
||||
(receivedCode.switchType == NewRemoteCode::on && receivedCode.dimLevelPresent)) {
|
||||
// Dimmer signal received
|
||||
|
||||
if (receivedCode.groupBit) {
|
||||
transmitter.sendGroupDim(receivedCode.dimLevel);
|
||||
}
|
||||
else {
|
||||
transmitter.sendDim(receivedCode.unit, receivedCode.dimLevel);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// On/Off signal received
|
||||
bool isOn = receivedCode.switchType == NewRemoteCode::on;
|
||||
|
||||
if (receivedCode.groupBit) {
|
||||
// Send to the group
|
||||
transmitter.sendGroup(isOn);
|
||||
}
|
||||
else {
|
||||
// Send to a single unit
|
||||
transmitter.sendUnit(receivedCode.unit, isOn);
|
||||
}
|
||||
}
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
NewRemoteReceiver::enable();
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Demo for RF remote switch receiver.
|
||||
* For details, see RemoteReceiver.h!
|
||||
*
|
||||
* This sketch shows the received signals on the serial port.
|
||||
* Connect the receiver to digital pin 2 on arduino and digital pin 1 on ESP8266.
|
||||
*
|
||||
*
|
||||
*Detected codes example:
|
||||
code: 8233372 Period: 273
|
||||
unit: 1
|
||||
groupBit: 0
|
||||
switchType: 0
|
||||
*
|
||||
* https://github.com/1technophile/NewRemoteSwitch
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
* ----------------------------------------------------------
|
||||
* Mod by Little Satan. Have Fun!
|
||||
* ----------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <NewRemoteReceiver.h>
|
||||
|
||||
int pin; // int for Receive pin.
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
NewRemoteReceiver::init(pin, 2, showCode);
|
||||
Serial.println("Receiver initialized");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
|
||||
// Callback function is called only when a valid code is received.
|
||||
void showCode(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType) {
|
||||
|
||||
// Print the received code.
|
||||
Serial.print("Code: ");
|
||||
Serial.print(address);
|
||||
Serial.print(" Period: ");
|
||||
Serial.println(period);
|
||||
Serial.print(" unit: ");
|
||||
Serial.println(unit);
|
||||
Serial.print(" groupBit: ");
|
||||
Serial.println(groupBit);
|
||||
Serial.print(" switchType: ");
|
||||
Serial.println(switchType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Example for analyzing and proposing unknown new protocols
|
||||
|
||||
Requires modified rc-switch branch "protocollessreceiver"
|
||||
with ReceivedInverted() function exposed.
|
||||
|
||||
https://github.com/Martin-Laclaustra/rc-switch/tree/protocollessreceiver
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
|
||||
----------------------------------------------------------
|
||||
CC1101 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(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
mySwitch.enableReceive(pin); // Receiver on
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (mySwitch.available()) {
|
||||
|
||||
int value = mySwitch.getReceivedValue();
|
||||
|
||||
if (value == 0) {
|
||||
Serial.print("Unknown encoding");
|
||||
} else {
|
||||
|
||||
int databuffer[64]; // get a copy of the received timings before they are overwritten
|
||||
int numberoftimings = 2 * mySwitch.getReceivedBitlength() + 2;
|
||||
if(numberoftimings > 64) numberoftimings = 64;
|
||||
for (int i = 0; i < numberoftimings; i++) {
|
||||
databuffer[i] = mySwitch.getReceivedRawdata()[i];
|
||||
}
|
||||
|
||||
Serial.print("Received ");
|
||||
Serial.print( mySwitch.getReceivedValue() );
|
||||
Serial.print(" / ");
|
||||
Serial.print( mySwitch.getReceivedBitlength() );
|
||||
Serial.print("bit ");
|
||||
Serial.print("Protocol: ");
|
||||
Serial.println( mySwitch.getReceivedProtocol() );
|
||||
|
||||
unsigned int databitsoffset = abs( (int)mySwitch.getReceivedLevelInFirstTiming() - (int)mySwitch.getReceivedInverted());
|
||||
//Serial.println( mySwitch.getReceivedLevelInFirstTiming() );
|
||||
//Serial.println( mySwitch.getReceivedInverted() );
|
||||
//Serial.println( databitsoffset );
|
||||
unsigned long dataduration = 0;
|
||||
for (unsigned int i = 1 + databitsoffset; i < numberoftimings - 1 + databitsoffset; i++) {
|
||||
dataduration += databuffer[i];
|
||||
}
|
||||
Serial.print("data bits of pulse train duration: ");
|
||||
Serial.println( dataduration );
|
||||
unsigned int averagebitduration = (int)(0.5 + ((double)dataduration)/mySwitch.getReceivedBitlength());
|
||||
unsigned int protocolratio = (unsigned int)(0.5 + ((double)(averagebitduration - mySwitch.getReceivedDelay())) / (double)mySwitch.getReceivedDelay());
|
||||
Serial.print("proposed protocol: { ");
|
||||
Serial.print(mySwitch.getReceivedDelay());
|
||||
Serial.print(", { ");
|
||||
Serial.print( (databitsoffset==0) ?
|
||||
(int) (0.5 + (double)databuffer[2*mySwitch.getReceivedBitlength()+1]/(double)mySwitch.getReceivedDelay())
|
||||
:
|
||||
(int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay())
|
||||
);
|
||||
Serial.print(", ");
|
||||
Serial.print( (databitsoffset==0) ?
|
||||
(int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay())
|
||||
:
|
||||
(int) (0.5 + (double)databuffer[1]/(double)mySwitch.getReceivedDelay())
|
||||
);
|
||||
Serial.print(" }, { ");
|
||||
Serial.print("1");
|
||||
Serial.print(", ");
|
||||
Serial.print(protocolratio);
|
||||
Serial.print(" }, { ");
|
||||
Serial.print(protocolratio);
|
||||
Serial.print(", ");
|
||||
Serial.print("1");
|
||||
Serial.print(" }, ");
|
||||
Serial.print((mySwitch.getReceivedInverted()) ? "true" : "false" );
|
||||
Serial.println(" }");
|
||||
|
||||
// raw signal
|
||||
Serial.println("====");
|
||||
Serial.print("first level ");
|
||||
Serial.println((mySwitch.getReceivedLevelInFirstTiming() == 0) ? "down" : "up" );
|
||||
for (int i = 0; i < 2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset; i++) {
|
||||
Serial.print(databuffer[i]);
|
||||
Serial.print(" ");
|
||||
if((i - databitsoffset) % 16 == 0) Serial.println("");
|
||||
}
|
||||
if ((2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset - 1) % 16 != 0) Serial.println("");
|
||||
if (databitsoffset != 1) Serial.println(databuffer[2*mySwitch.getReceivedBitlength()+1]);
|
||||
// plot signal in spreadsheet
|
||||
Serial.println("====");
|
||||
|
||||
}
|
||||
|
||||
mySwitch.resetAvailable();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
mySwitch.enableReceive(pin); // Receiver on interrupt 0 => that is pin #2
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (mySwitch.available()) {
|
||||
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
|
||||
mySwitch.resetAvailable();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Simple example for receiving
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
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(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
|
||||
mySwitch.enableReceive(pin); // Receiver on
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
if (mySwitch.available()){
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Simple example for receiving with Rssi output.
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
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(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
mySwitch.enableReceive(pin); // Receiver on
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
if (mySwitch.available()){
|
||||
|
||||
Serial.print("Received ");
|
||||
Serial.print( mySwitch.getReceivedValue() );
|
||||
Serial.print(" / ");
|
||||
Serial.print( mySwitch.getReceivedBitlength() );
|
||||
Serial.print("bit ");
|
||||
Serial.print("Protocol: ");
|
||||
Serial.println( mySwitch.getReceivedProtocol() );
|
||||
|
||||
Serial.print("RSSI: ");
|
||||
Serial.println(ELECHOUSE_cc1101.getRssi());
|
||||
|
||||
mySwitch.resetAvailable();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 125 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Simple example for Receiving and Transmit decimal code for cc1101
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pinRx; // int for Receive pin.
|
||||
int pinTx; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
int buttonPin; // for button pin.
|
||||
int buttonState = 0; // button state
|
||||
int ccSetRx = 0; // reset state for Receive
|
||||
int long value = 5393; // int to save value
|
||||
int bits = 24; // int to save bit number
|
||||
int prot = 1; // int to save Protocol number
|
||||
int puls = 320; // int to save pulse length
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
buttonPin = 34; // set button on GPIO pin 34.
|
||||
#elif ESP8266
|
||||
pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
buttonPin = 16; // set button on pin 16 = D0.
|
||||
#else
|
||||
pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
buttonPin = 4; // set button on pin D4.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
pinMode(buttonPin, INPUT); // set pin4 as input
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
buttonState = digitalRead(buttonPin); // read digital pin and save the state to int
|
||||
|
||||
|
||||
if (buttonState == HIGH) { // the button is pressed. Set transmit on.
|
||||
|
||||
ccSetRx = 0; // set resetstate to 0 for next reinit to Recive
|
||||
ELECHOUSE_cc1101.SetTx(); // set Transmit on
|
||||
mySwitch.disableReceive(); // Receiver off
|
||||
mySwitch.enableTransmit(pinTx); // Transmit on
|
||||
|
||||
mySwitch.setRepeatTransmit(3); // transmission repetitions.
|
||||
mySwitch.setProtocol(prot); // send Received Protocol
|
||||
mySwitch.setPulseLength(puls);// send Received Delay
|
||||
mySwitch.send(value, bits); // send Received value/bits
|
||||
|
||||
Serial.print("Transmit ");
|
||||
Serial.print( value );
|
||||
Serial.print(" / ");
|
||||
Serial.print( bits );
|
||||
Serial.print("bit ");
|
||||
Serial.print("Protocol: ");
|
||||
Serial.print( prot );
|
||||
Serial.print(" Delay: ");
|
||||
Serial.println( puls );
|
||||
}
|
||||
|
||||
|
||||
if (buttonState == LOW && ccSetRx == 0){ //the button is not pressed. set cc1101 to Receive.
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
mySwitch.disableTransmit(); // set Transmit off
|
||||
mySwitch.enableReceive(pinRx); // Receiver on
|
||||
ccSetRx = 1;
|
||||
}
|
||||
|
||||
if (buttonState == LOW && ccSetRx == 1) { //the button is not pressed and set receive is finish. Receive values.
|
||||
|
||||
|
||||
|
||||
if (mySwitch.available()){
|
||||
|
||||
Serial.print("Received ");
|
||||
Serial.print( mySwitch.getReceivedValue() );
|
||||
Serial.print(" / ");
|
||||
Serial.print( mySwitch.getReceivedBitlength() );
|
||||
Serial.print("bit ");
|
||||
Serial.print("Protocol: ");
|
||||
Serial.print( mySwitch.getReceivedProtocol() );
|
||||
Serial.print(" Delay: ");
|
||||
Serial.println( mySwitch.getReceivedDelay() );
|
||||
|
||||
value = mySwitch.getReceivedValue(); // save received Value
|
||||
bits = mySwitch.getReceivedBitlength(); // save received Bitlength
|
||||
prot = mySwitch.getReceivedProtocol(); // save received Protocol
|
||||
puls = mySwitch.getReceivedDelay(); // save received pulse length
|
||||
|
||||
mySwitch.resetAvailable();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Simple example for repeating decimal code for cc1101
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pinRx; // int for Receive pin.
|
||||
int pinTx; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
int number = 15; // set number of transmission repetitions.
|
||||
int TIME = 3000; // set delay befor repeat. For direct repetition after receive set 0.
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
#else
|
||||
pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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(pinRx); // Receiver on
|
||||
|
||||
}
|
||||
void loop() {
|
||||
|
||||
if (mySwitch.available()){
|
||||
|
||||
Serial.print("Received ");
|
||||
Serial.print( mySwitch.getReceivedValue() );
|
||||
Serial.print(" / ");
|
||||
Serial.print( mySwitch.getReceivedBitlength() );
|
||||
Serial.print("bit ");
|
||||
Serial.print("Protocol: ");
|
||||
Serial.print( mySwitch.getReceivedProtocol() );
|
||||
Serial.print(" Delay: ");
|
||||
Serial.println( mySwitch.getReceivedDelay() );
|
||||
|
||||
delay(TIME);
|
||||
mySwitch.disableReceive(); // Receiver off
|
||||
mySwitch.enableTransmit(pinTx); // Transmit on
|
||||
ELECHOUSE_cc1101.SetTx(); // set Transmit on
|
||||
|
||||
Serial.println("Transmit");
|
||||
|
||||
mySwitch.setRepeatTransmit(number); // transmission repetitions.
|
||||
mySwitch.setProtocol(mySwitch.getReceivedProtocol()); // send Received Protocol
|
||||
mySwitch.setPulseLength(mySwitch.getReceivedDelay()); // send Received Delay
|
||||
mySwitch.send(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength()); // send Received value/bits
|
||||
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
mySwitch.disableTransmit(); // set Transmit off
|
||||
mySwitch.enableReceive(pinRx); // Receiver on
|
||||
|
||||
Serial.println("Receive");
|
||||
|
||||
mySwitch.resetAvailable();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Example for different sending methods
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
// Transmitter on
|
||||
mySwitch.enableTransmit(pin);
|
||||
|
||||
// cc1101 set Transmit on
|
||||
ELECHOUSE_cc1101.SetTx();
|
||||
|
||||
// Optional set protocol (default is 1, will work for most outlets)
|
||||
// mySwitch.setProtocol(2);
|
||||
|
||||
// Optional set pulse length.
|
||||
// mySwitch.setPulseLength(320);
|
||||
|
||||
// Optional set number of transmission repetitions.
|
||||
// mySwitch.setRepeatTransmit(15);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
/* See Example: TypeA_WithDIPSwitches */
|
||||
mySwitch.switchOn("11111", "00010");
|
||||
delay(1000);
|
||||
mySwitch.switchOff("11111", "00010");
|
||||
delay(1000);
|
||||
|
||||
/* Same switch as above, but using decimal code */
|
||||
mySwitch.send(5393, 24);
|
||||
delay(1000);
|
||||
mySwitch.send(5396, 24);
|
||||
delay(1000);
|
||||
|
||||
/* Same switch as above, but using binary code */
|
||||
mySwitch.send("000000000001010100010001");
|
||||
delay(1000);
|
||||
mySwitch.send("000000000001010100010100");
|
||||
delay(1000);
|
||||
|
||||
/* Same switch as above, but tri-state code */
|
||||
mySwitch.sendTriState("00000FFF0F0F");
|
||||
delay(1000);
|
||||
mySwitch.sendTriState("00000FFF0FF0");
|
||||
delay(1000);
|
||||
|
||||
delay(20000);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Example for outlets which are configured with a 10 pole DIP switch.
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
// Transmitter on
|
||||
mySwitch.enableTransmit(pin);
|
||||
|
||||
// cc1101 set Transmit on
|
||||
ELECHOUSE_cc1101.SetTx();
|
||||
|
||||
|
||||
// Optional set pulse length.
|
||||
// mySwitch.setPulseLength(320);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Switch on:
|
||||
// The first parameter represents the setting of the first 5 DIP switches.
|
||||
// In this example it's ON-ON-OFF-OFF-ON.
|
||||
//
|
||||
// The second parameter represents the setting of the last 5 DIP switches.
|
||||
// In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF.
|
||||
mySwitch.switchOn("11001", "01010");
|
||||
|
||||
// Wait a second
|
||||
delay(1000);
|
||||
|
||||
// Switch off
|
||||
mySwitch.switchOff("11001", "01010");
|
||||
|
||||
// Wait another second
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Example for outlets which are configured with two rotary/sliding switches.
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
// Transmitter on
|
||||
mySwitch.enableTransmit(pin);
|
||||
|
||||
// cc1101 set Transmit on
|
||||
ELECHOUSE_cc1101.SetTx();
|
||||
|
||||
// Optional set pulse length.
|
||||
// mySwitch.setPulseLength(320);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Switch on:
|
||||
// The first parameter represents the setting of the first rotary switch.
|
||||
// In this example it's switched to "1" or "A" or "I".
|
||||
//
|
||||
// The second parameter represents the setting of the second rotary switch.
|
||||
// In this example it's switched to "4" or "D" or "IV".
|
||||
mySwitch.switchOn(1, 4);
|
||||
|
||||
// Wait a second
|
||||
delay(1000);
|
||||
|
||||
// Switch off
|
||||
mySwitch.switchOff(1, 4);
|
||||
|
||||
// Wait another second
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Example for Intertechno outlets
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
// Transmitter on
|
||||
mySwitch.enableTransmit(pin);
|
||||
|
||||
// cc1101 set Transmit on
|
||||
ELECHOUSE_cc1101.SetTx();
|
||||
|
||||
// Optional set pulse length.
|
||||
// mySwitch.setPulseLength(320);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Switch on:
|
||||
// The first parameter represents the familycode (a, b, c, ... f)
|
||||
// The second parameter represents the group number
|
||||
// The third parameter represents the device number
|
||||
//
|
||||
// In this example it's family 'b', group #3, device #2
|
||||
mySwitch.switchOn('b', 3, 2);
|
||||
|
||||
// Wait a second
|
||||
delay(1000);
|
||||
|
||||
// Switch off
|
||||
mySwitch.switchOff('b', 3, 2);
|
||||
|
||||
// Wait another second
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Example for REV outlets (e.g. 8342L)
|
||||
|
||||
https://github.com/sui77/rc-switch/
|
||||
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
|
||||
Need help? http://forum.ardumote.com
|
||||
----------------------------------------------------------
|
||||
Mod by Little Satan. Have Fun!
|
||||
----------------------------------------------------------
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <RCSwitch.h>
|
||||
|
||||
int pin; // int for Transmit pin.
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
// Transmitter on
|
||||
mySwitch.enableTransmit(pin);
|
||||
|
||||
// cc1101 set Transmit on
|
||||
ELECHOUSE_cc1101.SetTx();
|
||||
|
||||
// set pulse length.
|
||||
mySwitch.setPulseLength(360);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Switch on:
|
||||
// The first parameter represents the channel (a, b, c, d)
|
||||
// The second parameter represents the device number
|
||||
//
|
||||
// In this example it's family 'd', device #2
|
||||
mySwitch.switchOn('d', 2);
|
||||
|
||||
// Wait a second
|
||||
delay(1000);
|
||||
|
||||
// Switch off
|
||||
mySwitch.switchOff('d', 2);
|
||||
|
||||
// Wait another second
|
||||
delay(1000);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This sketch simply repeats data received from remote weather sensors made by Cresta.
|
||||
*
|
||||
* Setup:
|
||||
* - connect digital output of a 433MHz receiver to digital pin 2 of Arduino.
|
||||
* - connect transmitter input of a 433MHz transmitter to digital pin 11
|
||||
* - An LED on pin 13 will tell you if and when a signal has been received and transmitted.
|
||||
*
|
||||
* Library:
|
||||
* https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <SensorReceiver.h>
|
||||
#include <SensorTransmitter.h>
|
||||
|
||||
int LED_PIN;
|
||||
int pinRx; // int for Receive pin.
|
||||
int pinTx; // int for Transmit pin.
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.
|
||||
LED_PIN = 32; // set led on GPIO pin 32.
|
||||
#elif ESP8266
|
||||
pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.
|
||||
LED_PIN = 16; // set led on pin 16 = D0.
|
||||
#else
|
||||
pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.
|
||||
LED_PIN = 4; // set led on pin D4.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.
|
||||
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
|
||||
// Since we're not instantiating SensorTransmitter, but only use the static methods of SensorTransmitter,
|
||||
// the pin mode must be set manually.
|
||||
pinMode(pinTx, OUTPUT);
|
||||
|
||||
// When no signal has been received, the LED is lit.
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
|
||||
// Init the receiver on interrupt pin 0 (digital pin 2).
|
||||
// Set the callback to function "retransmit", which is called
|
||||
// whenever valid sensor data has been received.
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
SensorReceiver::init(pinRx, retransmit);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
|
||||
void retransmit(byte *data) {
|
||||
// Data received
|
||||
|
||||
// Wait a second after a receiving. There's little point for decoding and sending the same signal multiple times.
|
||||
SensorReceiver::disable();
|
||||
interrupts(); // delay() requires that interrupts are enabled
|
||||
delay(1000);
|
||||
|
||||
// Flash LED when transmitting.
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
|
||||
// Transmit signal. Note: this is a static method, no object required!
|
||||
ELECHOUSE_cc1101.SetTx(); // set Transmit on
|
||||
SensorTransmitter::sendPackage(pinTx, data);
|
||||
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
|
||||
noInterrupts();
|
||||
ELECHOUSE_cc1101.SetRx(); // set Receive on
|
||||
SensorReceiver::enable();
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This sketch receives and decodes data from a 433MHz thermo/hygro weather sensor.
|
||||
* The received data (temperature, humidity, channel) is echo
|
||||
*
|
||||
* Setup:
|
||||
* - Connect digital output of a 433MHz receiver to digital pin 2 of Arduino
|
||||
* - Enable the serial monitor at 115200 baud.
|
||||
*
|
||||
* Need library:
|
||||
* https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
*
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <SensorReceiver.h>
|
||||
|
||||
int pin;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 4; // for esp32! Receiver on GPIO pin 4.
|
||||
#elif ESP8266
|
||||
pin = 4; // for esp8266! Receiver on pin 4 = D2.
|
||||
#else
|
||||
pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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
|
||||
|
||||
// Init the receiver on interrupt pin 0 (digital pin 2).
|
||||
// Set the callback to function "showTempHumi", which is called
|
||||
// whenever valid sensor data has been received.
|
||||
SensorReceiver::init(pin, showTempHumi);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Empty! However, you can do other stuff here if you like.
|
||||
}
|
||||
|
||||
void showTempHumi(byte *data) {
|
||||
// is data a ThermoHygro-device?
|
||||
if ((data[3] & 0x1f) == 0x1e) {
|
||||
// Yes!
|
||||
|
||||
byte channel, randomId;
|
||||
int temp;
|
||||
byte humidity;
|
||||
|
||||
// Decode the data
|
||||
SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);
|
||||
|
||||
// Print temperature. Note: temp is 10x the actual temperature!
|
||||
Serial.print("Temperature: ");
|
||||
Serial.print(temp / 10); // units
|
||||
Serial.print('.');
|
||||
Serial.print(temp % 10); // decimal
|
||||
|
||||
// Print humidity
|
||||
Serial.print(" deg, Humidity: ");
|
||||
Serial.print(humidity);
|
||||
Serial.print("% REL");
|
||||
|
||||
// Print channel
|
||||
Serial.print(", Channel: ");
|
||||
Serial.println(channel, DEC);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This sketch sends (bogus) thermo / hygro data to a remote weather sensors made by Cresta.
|
||||
*
|
||||
* Setup:
|
||||
* - connect transmitter input of a 433MHz transmitter to digital pin 11
|
||||
* - On the weather station, activate the "scan" function for channel 1.
|
||||
*
|
||||
* Library:
|
||||
* https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor
|
||||
* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
|
||||
*
|
||||
*/
|
||||
#include <ELECHOUSE_CC1101_SRC_DRV.h>
|
||||
#include <SensorTransmitter.h>
|
||||
|
||||
int pin;
|
||||
|
||||
void setup() {
|
||||
|
||||
#ifdef ESP32
|
||||
pin = 2; // for esp32! Transmit on GPIO pin 2.
|
||||
#elif ESP8266
|
||||
pin = 5; // for esp8266! Transmit on pin 5 = D1
|
||||
#else
|
||||
pin = 6; // for Arduino! Transmit on pin 6.
|
||||
#endif
|
||||
|
||||
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
|
||||
Serial.println("Connection OK");
|
||||
}else{
|
||||
Serial.println("Connection Error");
|
||||
}
|
||||
|
||||
//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!
|
||||
ELECHOUSE_cc1101.setMHZ(433.92); // 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.SetTx(); // Transmitt on
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Initializes a ThermoHygroTransmitter on pin 11, with "random" ID 0, on channel 1.
|
||||
ThermoHygroTransmitter transmitter(pin, 0, 1);
|
||||
|
||||
// Displays temperatures from -10 degrees Celsius to +20,
|
||||
// and humidity from 10% REL to 40% REL, with increments of 2
|
||||
for (int i = -10; i<=20; i+=2) {
|
||||
// Temperatures are passed at 10 times the real value,
|
||||
// to avoid using floating point math.
|
||||
transmitter.sendTempHumi(i * 10, i + 20);
|
||||
|
||||
// Wait two seconds before sending next.
|
||||
delay(2000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user