[SX127x] Updated examples

This commit is contained in:
jgromes 2019-06-02 15:03:33 +02:00
parent 98f60dd092
commit 63ee5f0a07
7 changed files with 100 additions and 21 deletions

View file

@ -8,13 +8,23 @@
receiving a message. receiving a message.
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 lora = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -8,13 +8,23 @@
Instead, modify the other examples to use FSK Instead, modify the other examples to use FSK
modem and use the appropriate configuration modem and use the appropriate configuration
methods. methods.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/ */
// include the library // include the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 fsk = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -12,13 +12,23 @@
- preamble length - preamble length
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 lora = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -94,5 +104,10 @@ void loop() {
// packet was received, but is malformed // packet was received, but is malformed
Serial.println(F("CRC error!")); Serial.println(F("CRC error!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
} }
} }

View file

@ -13,13 +13,23 @@
- sync word - sync word
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 lora = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -136,6 +146,11 @@ void loop() {
// packet was received, but is malformed // packet was received, but is malformed
Serial.println(F("CRC error!")); 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, // we're ready to receive more packets,

View file

@ -12,20 +12,24 @@
- output power during transmission - output power during transmission
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 loraSX1278 = RadioShield.ModuleA; // 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 // or using RadioShield
// the connection yourself // https://github.com/jgromes/RadioShield
// NSS pin: 6 SX1268 loraSX1272 = RadioShield.ModuleB;
// DIO1 pin: 4
// DIO2 pin: 5
SX1272 loraSX1272 = new Module(6, 4, 5);
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);

View file

@ -8,13 +8,23 @@
- arbitrary binary data (byte array) - arbitrary binary data (byte array)
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 lora = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -73,6 +83,11 @@ void loop() {
// timeout occured while transmitting packet // timeout occured while transmitting packet
Serial.println(F(" timeout!")); Serial.println(F(" timeout!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
} }
// wait for a second before transmitting again // wait for a second before transmitting again

View file

@ -9,13 +9,23 @@
- arbitrary binary data (byte array) - arbitrary binary data (byte array)
Other modules from SX127x/RFM9x family can also be used. 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 the library
#include <RadioLib.h> #include <RadioLib.h>
// SX1278 module is in slot A on the shield // SX1278 has the following connections:
SX1278 lora = RadioShield.ModuleA; // 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() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -75,7 +85,7 @@ void setFlag(void) {
void loop() { void loop() {
// check if the previous transmission finished // check if the previous transmission finished
if(transmittedFlag) { if(transmittedFlag) {
Serial.println(F("[SX1278] Packet transmission finished!")); Serial.println(F("packet transmission finished!"));
// wait one second before next transmission // wait one second before next transmission
delay(1000); delay(1000);