diff --git a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino index 80962365..8c851088 100644 --- a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino +++ b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino @@ -1,15 +1,30 @@ /* RadioLib CC1101 Receive Example - This example receives packets using CC1101 FSK radio - module. + This example receives packets using CC1101 FSK radio module. + To successfully receive data, the following settings have to be the same + on both transmitter and receiver: + - carrier frequency + - bit rate + - frequency deviation + - sync word + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -67,5 +82,10 @@ void loop() { // packet was received, but is malformed Serial.println(F("CRC error!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } } diff --git a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino index 066b6908..1f1aa5bf 100644 --- a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino +++ b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino @@ -6,13 +6,23 @@ destination node. After setting node address, this node will automatically filter out any packets that do not contain either node address or broadcast addresses. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -102,5 +112,10 @@ void loop() { // packet was received, but is malformed Serial.println(F("CRC error!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } } diff --git a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino index f5573df4..9fcae3fe 100644 --- a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino +++ b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino @@ -4,13 +4,30 @@ This example listens for FSK transmissions and tries to receive them. Once a packet is received, an interrupt is triggered. + + To successfully receive data, the following settings have to be the same + on both transmitter and receiver: + - carrier frequency + - bit rate + - frequency deviation + - sync word + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 module is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -113,6 +130,16 @@ void loop() { // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); Serial.println(cc.getLQI()); + + } else if (state == ERR_CRC_MISMATCH) { + // packet was received, but is malformed + Serial.println(F("CRC error!")); + + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } // we're ready to receive more packets, diff --git a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino index e8789d1a..6140a851 100644 --- a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino +++ b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino @@ -10,20 +10,23 @@ - allowed frequency deviation - output power during transmission - sync word + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 module is in slot A on the shield -CC1101 cc1 = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc1 = new Module(10, 2, 3); -// if you're not using RadioShield, you can specify -// the connection yourself -// NSS pin: 6 -// DIO0 pin: 4 -// DIO1 pin: 5 -CC1101 cc2 = new Module(6, 4, 5); +// or using RadioShield +// https://github.com/jgromes/RadioShield +CC1101 cc2 = RadioShield.ModuleB; void setup() { Serial.begin(9600); diff --git a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino index 28786d7b..f9272993 100644 --- a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino +++ b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino @@ -2,13 +2,27 @@ RadioLib CC1101 Transmit Example This example transmits packets using CC1101 FSK radio module. + Each packet contains up to 64 bytes of data, in the form of: + - Arduino String + - null-terminated char array (C-string) + - arbitrary binary data (byte array) + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -50,6 +64,11 @@ void loop() { // the supplied packet was longer than 255 bytes Serial.println(F(" too long!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } // wait for a second before transmitting again diff --git a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino index 7a0235fd..b9e8a966 100644 --- a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino +++ b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino @@ -6,13 +6,23 @@ destination node. After setting node address, this node will automatically filter out any packets that do not contain either node address or broadcast addresses. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -86,6 +96,11 @@ void loop() { // the supplied packet was longer than 255 bytes Serial.println(F(" too long!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } // wait for a second before transmitting again diff --git a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino index cb0914f3..9a909d72 100644 --- a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino +++ b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino @@ -1,19 +1,29 @@ /* RadioLib CC1101 Transmit with Interrupts Example - This example transmits FSK packets with one second delays - between them. Each packet contains up to 64 bytes - of data, in the form of: + This example transmits packets using CC1101 FSK radio module. + Once a packet is transmitted, an interrupt is triggered. + Each packet contains up to 64 bytes of data, in the form of: - Arduino String - null-terminated char array (C-string) - arbitrary binary data (byte array) + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// CC1101 module is in slot A on the shield -CC1101 cc = RadioShield.ModuleA; +// CC1101 has the following connections: +// NSS pin: 10 +// GDO0 pin: 2 +// GDO2 pin: 3 +CC1101 cc = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//CC1101 cc = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -34,7 +44,7 @@ void setup() { while (true); } - // set the function that will be called + // set the function that will be called // when packet transmission is finished cc.setGdo0Action(setFlag); @@ -51,10 +61,11 @@ void setup() { 0x78, 0xAB, 0xCD, 0xEF}; state = cc.transmit(byteArr, 8); */ - + if (state != ERR_NONE) { Serial.print(F("failed, code ")); Serial.println(state); + while (true); } } @@ -69,7 +80,7 @@ void setFlag(void) { void loop() { // check if the previous transmission finished if(transmittedFlag) { - Serial.println(F("[CC1101] Packet transmission finished!")); + Serial.println(F("packet transmission finished!")); // wait one second before next transmission delay(1000); @@ -80,14 +91,14 @@ void loop() { // you can transmit C-string or Arduino string up to // 64 characters long int state = cc.startTransmit("Hello World!"); - + // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; int state = cc.transmit(byteArr, 8); */ - + if (state != ERR_NONE) { Serial.print(F("failed, code ")); Serial.println(state);