diff --git a/ELECHOUSE_CC1101_SRC_DRV.cpp b/ELECHOUSE_CC1101_SRC_DRV.cpp index c173d50..5ab8491 100644 --- a/ELECHOUSE_CC1101_SRC_DRV.cpp +++ b/ELECHOUSE_CC1101_SRC_DRV.cpp @@ -54,6 +54,7 @@ byte pc0WDATA; byte pc0PktForm; byte pc0CRC_EN; byte pc0LenConf; +byte trxstate; byte clb1[2]= {24,28}; byte clb2[2]= {31,38}; byte clb3[2]= {65,76}; @@ -141,7 +142,6 @@ void ELECHOUSE_CC1101::Init(void) { setSpi(); SpiStart(); //spi initialization - GDO_Set(); //GDO set digitalWrite(SS_PIN, HIGH); digitalWrite(SCK_PIN, HIGH); digitalWrite(MOSI_PIN, LOW); @@ -305,6 +305,7 @@ void ELECHOUSE_CC1101::setSpiPin(byte sck, byte miso, byte mosi, byte ss){ void ELECHOUSE_CC1101::setGDO(byte gdo0, byte gdo2){ GDO0 = gdo0; GDO2 = gdo2; +GDO_Set(); } /**************************************************************** *FUNCTION NAME:CCMode @@ -526,7 +527,7 @@ clb4[1]=e; } } /**************************************************************** -*FUNCTION NAME:Set Sync_Worf +*FUNCTION NAME:Set Sync_Word *FUNCTION :Sync Word *INPUT :none *OUTPUT :none @@ -949,6 +950,7 @@ void ELECHOUSE_CC1101::SetTx(void) { SpiStrobe(CC1101_SIDLE); SpiStrobe(CC1101_STX); //start send + trxstate=1; } /**************************************************************** *FUNCTION NAME:SetRx @@ -959,6 +961,7 @@ void ELECHOUSE_CC1101::SetTx(void) void ELECHOUSE_CC1101::SetRx(void) { SpiStrobe(CC1101_SRX); //start receive + trxstate=2; } /**************************************************************** *FUNCTION NAME:SetTx @@ -971,6 +974,7 @@ void ELECHOUSE_CC1101::SetTx(float mhz) setMHZ(mhz); SpiStrobe(CC1101_SIDLE); SpiStrobe(CC1101_STX); //start send + trxstate=1; } /**************************************************************** *FUNCTION NAME:SetRx @@ -982,6 +986,7 @@ void ELECHOUSE_CC1101::SetRx(float mhz) { setMHZ(mhz); SpiStrobe(CC1101_SRX); //start receive + trxstate=2; } /**************************************************************** *FUNCTION NAME:RSSI Level @@ -1047,6 +1052,36 @@ void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size) while (!digitalRead(GDO0)); // Wait for GDO0 to be set -> sync transmitted while (digitalRead(GDO0)); // Wait for GDO0 to be cleared -> end of packet SpiStrobe(CC1101_SFTX); //flush TXfifo + trxstate=1; +} +/**************************************************************** +*FUNCTION NAME:Char direct SendData +*FUNCTION :use CC1101 send data without GDO +*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61 +*OUTPUT :none +****************************************************************/ +void ELECHOUSE_CC1101::SendData(char *txchar,int t) +{ +int len = strlen(txchar); +byte chartobyte[len]; +for (int i = 0; i + +void setup(){ + + Serial.begin(9600); + 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.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 + +void setup(){ + + Serial.begin(9600); + 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 + +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); + 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.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); +} diff --git a/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.ino b/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.ino new file mode 100644 index 0000000..51982da --- /dev/null +++ b/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.ino @@ -0,0 +1,41 @@ +//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 + +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); + 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); +} diff --git a/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino b/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino new file mode 100644 index 0000000..a9a632b --- /dev/null +++ b/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino @@ -0,0 +1,60 @@ +//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 + +const int n = 61; +byte buffer[n] = ""; + +void setup() { + + Serial.begin(9600); + 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.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 + +const int n = 61; +byte buffer[n] = ""; + +void setup() { + + Serial.begin(9600); + 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 + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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.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. + + ELECHOUSE_cc1101.SetRx(); // set Receive on. + + 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 + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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. + ELECHOUSE_cc1101.SetRx(); // set Receive on. + 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 + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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.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); + +} diff --git a/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino b/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino new file mode 100644 index 0000000..838c756 --- /dev/null +++ b/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino @@ -0,0 +1,48 @@ +// These examples are from the Electronics Cookbook by Simon Monk +//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib +// mod by Little_S@tan +#include + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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); +} diff --git a/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino b/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino new file mode 100644 index 0000000..de55f39 --- /dev/null +++ b/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino @@ -0,0 +1,67 @@ +// These examples are from the Electronics Cookbook by Simon Monk +//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib +// mod by Little_S@tan + +#include + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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.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 + +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); + ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! + ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). 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 sentence=Driver for cc1101.