From 63ee5f0a07a6543f6f03da6da846b2ea10ec4832 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 2 Jun 2019 15:03:33 +0200 Subject: [PATCH] [SX127x] Updated examples --- .../SX127x_Channel_Activity_Detection.ino | 14 +++++++++++-- .../SX127x_FSK_Modem/SX127x_FSK_Modem.ino | 14 +++++++++++-- .../SX127x/SX127x_Receive/SX127x_Receive.ino | 19 ++++++++++++++++-- .../SX127x_Receive_Interrupt.ino | 19 ++++++++++++++++-- .../SX127x_Settings/SX127x_Settings.ino | 20 +++++++++++-------- .../SX127x_Transmit/SX127x_Transmit.ino | 19 ++++++++++++++++-- .../SX127x_Transmit_Interrupt.ino | 16 ++++++++++++--- 7 files changed, 100 insertions(+), 21 deletions(-) diff --git a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino b/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino index 5bb9cf80..cf54ed75 100644 --- a/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino +++ b/examples/SX127x/SX127x_Channel_Activity_Detection/SX127x_Channel_Activity_Detection.ino @@ -8,13 +8,23 @@ receiving a message. Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 lora = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 lora = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 lora = RadioShield.ModuleA; void setup() { Serial.begin(9600); diff --git a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino index b2568aee..1c8cd1da 100644 --- a/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino +++ b/examples/SX127x/SX127x_FSK_Modem/SX127x_FSK_Modem.ino @@ -8,13 +8,23 @@ Instead, modify the other examples to use FSK modem and use the appropriate configuration methods. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 fsk = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 fsk = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 fsk = RadioShield.ModuleA; void setup() { Serial.begin(9600); diff --git a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino b/examples/SX127x/SX127x_Receive/SX127x_Receive.ino index 5bb86650..18e4ab48 100644 --- a/examples/SX127x/SX127x_Receive/SX127x_Receive.ino +++ b/examples/SX127x/SX127x_Receive/SX127x_Receive.ino @@ -12,13 +12,23 @@ - preamble length Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 lora = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 lora = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 lora = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -94,5 +104,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/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino b/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino index 6cea5147..c1cce7c4 100644 --- a/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino +++ b/examples/SX127x/SX127x_Receive_Interrupt/SX127x_Receive_Interrupt.ino @@ -13,13 +13,23 @@ - sync word Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 lora = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 lora = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 lora = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -136,6 +146,11 @@ 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); + } // we're ready to receive more packets, diff --git a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino index 3c48799a..e64256fc 100644 --- a/examples/SX127x/SX127x_Settings/SX127x_Settings.ino +++ b/examples/SX127x/SX127x_Settings/SX127x_Settings.ino @@ -12,20 +12,24 @@ - output power during transmission Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 loraSX1278 = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO1 pin: 2 +// DIO2 pin: 3 +// BUSY pin: 9 +SX1262 loraSX1278 = new Module(10, 2, 3, 9); -// if you're not using RadioShield, you can specify -// the connection yourself -// NSS pin: 6 -// DIO1 pin: 4 -// DIO2 pin: 5 -SX1272 loraSX1272 = new Module(6, 4, 5); +// or using RadioShield +// https://github.com/jgromes/RadioShield +SX1268 loraSX1272 = RadioShield.ModuleB; void setup() { Serial.begin(9600); diff --git a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino index 9e9d2457..2573a41d 100644 --- a/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino +++ b/examples/SX127x/SX127x_Transmit/SX127x_Transmit.ino @@ -8,13 +8,23 @@ - arbitrary binary data (byte array) Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 lora = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 lora = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 lora = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -73,6 +83,11 @@ void loop() { // timeout occured while transmitting packet Serial.println(F(" timeout!")); + } else { + // some other error occurred + Serial.print(F("failed, code ")); + Serial.println(state); + } // wait for a second before transmitting again diff --git a/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino index 0d60aea7..a0cc1f56 100644 --- a/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino +++ b/examples/SX127x/SX127x_Transmit_Interrupt/SX127x_Transmit_Interrupt.ino @@ -9,13 +9,23 @@ - arbitrary binary data (byte array) Other modules from SX127x/RFM9x family can also be used. + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library #include -// SX1278 module is in slot A on the shield -SX1278 lora = RadioShield.ModuleA; +// SX1278 has the following connections: +// NSS pin: 10 +// DIO0 pin: 2 +// DIO1 pin: 3 +SX1278 lora = new Module(10, 2, 3); + +// or using RadioShield +// https://github.com/jgromes/RadioShield +//SX1278 lora = RadioShield.ModuleA; void setup() { Serial.begin(9600); @@ -75,7 +85,7 @@ void setFlag(void) { void loop() { // check if the previous transmission finished if(transmittedFlag) { - Serial.println(F("[SX1278] Packet transmission finished!")); + Serial.println(F("packet transmission finished!")); // wait one second before next transmission delay(1000);