[SX126x] Added links to default config wiki page
This commit is contained in:
parent
b98f910367
commit
4a53a58258
7 changed files with 108 additions and 162 deletions
|
@ -8,6 +8,9 @@
|
||||||
|
|
||||||
Other modules from SX126x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -20,29 +23,18 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 lora = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
//SX1262 lora = RadioShield.ModuleA;
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize SX1262 with default settings
|
// initialize SX1262 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = lora.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +48,7 @@ void loop() {
|
||||||
Serial.print(F("[SX1262] Scanning channel for LoRa transmission ... "));
|
Serial.print(F("[SX1262] Scanning channel for LoRa transmission ... "));
|
||||||
|
|
||||||
// start scanning current channel
|
// start scanning current channel
|
||||||
int state = lora.scanChannel();
|
int state = radio.scanChannel();
|
||||||
|
|
||||||
if (state == LORA_DETECTED) {
|
if (state == LORA_DETECTED) {
|
||||||
// LoRa preamble was detected
|
// LoRa preamble was detected
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
modem and use the appropriate configuration
|
modem and use the appropriate configuration
|
||||||
methods.
|
methods.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---fsk-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -21,30 +24,18 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 fsk = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
//SX1262 fsk = RadioShield.ModuleA;
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize SX1262 FSK modem with default settings
|
// initialize SX1262 FSK modem with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.beginFSK();
|
||||||
// bit rate: 48.0 kbps
|
|
||||||
// frequency deviation: 50.0 kHz
|
|
||||||
// Rx bandwidth: 156.2 kHz
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60.0 mA
|
|
||||||
// preamble length: 16 bits
|
|
||||||
// data shaping: Gaussian, BT = 0.5
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// sync word: 0x2D 0x01
|
|
||||||
// CRC: enabled, CRC16 (CCIT)
|
|
||||||
int state = fsk.beginFSK();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,21 +46,21 @@ void setup() {
|
||||||
|
|
||||||
// if needed, you can switch between LoRa and FSK modes
|
// if needed, you can switch between LoRa and FSK modes
|
||||||
//
|
//
|
||||||
// lora.begin() start LoRa mode (and disable FSK)
|
// radio.begin() start LoRa mode (and disable FSK)
|
||||||
// lora.beginFSK() start FSK mode (and disable LoRa)
|
// radio.beginFSK() start FSK mode (and disable LoRa)
|
||||||
|
|
||||||
// the following settings can also
|
// the following settings can also
|
||||||
// be modified at run-time
|
// be modified at run-time
|
||||||
state = fsk.setFrequency(433.5);
|
state = radio.setFrequency(433.5);
|
||||||
state = fsk.setBitRate(100.0);
|
state = radio.setBitRate(100.0);
|
||||||
state = fsk.setFrequencyDeviation(10.0);
|
state = radio.setFrequencyDeviation(10.0);
|
||||||
state = fsk.setRxBandwidth(250.0);
|
state = radio.setRxBandwidth(250.0);
|
||||||
state = fsk.setOutputPower(10.0);
|
state = radio.setOutputPower(10.0);
|
||||||
state = fsk.setCurrentLimit(100.0);
|
state = radio.setCurrentLimit(100.0);
|
||||||
state = fsk.setDataShaping(1.0);
|
state = radio.setDataShaping(1.0);
|
||||||
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
uint8_t syncWord[] = {0x01, 0x23, 0x45, 0x67,
|
||||||
0x89, 0xAB, 0xCD, 0xEF};
|
0x89, 0xAB, 0xCD, 0xEF};
|
||||||
state = fsk.setSyncWord(syncWord, 8);
|
state = radio.setSyncWord(syncWord, 8);
|
||||||
if (state != ERR_NONE) {
|
if (state != ERR_NONE) {
|
||||||
Serial.print(F("Unable to set configuration, code "));
|
Serial.print(F("Unable to set configuration, code "));
|
||||||
Serial.println(state);
|
Serial.println(state);
|
||||||
|
@ -78,15 +69,15 @@ void setup() {
|
||||||
|
|
||||||
// FSK modem on SX126x can handle the sync word setting in bits, not just
|
// FSK modem on SX126x can handle the sync word setting in bits, not just
|
||||||
// whole bytes. The value used is left-justified.
|
// whole bytes. The value used is left-justified.
|
||||||
// This makes same result as fsk.setSyncWord(syncWord, 8):
|
// This makes same result as radio.setSyncWord(syncWord, 8):
|
||||||
state = fsk.setSyncBits(syncWord, 64);
|
state = radio.setSyncBits(syncWord, 64);
|
||||||
// This will use 0x012 as sync word (12 bits only):
|
// This will use 0x012 as sync word (12 bits only):
|
||||||
state = fsk.setSyncBits(syncWord, 12);
|
state = radio.setSyncBits(syncWord, 12);
|
||||||
|
|
||||||
// FSK modem allows advanced CRC configuration
|
// FSK modem allows advanced CRC configuration
|
||||||
// Default is CCIT CRC16 (2 bytes, initial 0x1D0F, polynomial 0x1021, inverted)
|
// Default is CCIT CRC16 (2 bytes, initial 0x1D0F, polynomial 0x1021, inverted)
|
||||||
// Set CRC to IBM CRC (2 bytes, initial 0xFFFF, polynomial 0x8005, non-inverted)
|
// Set CRC to IBM CRC (2 bytes, initial 0xFFFF, polynomial 0x8005, non-inverted)
|
||||||
state = fsk.setCRC(2, 0xFFFF, 0x8005, false);
|
state = radio.setCRC(2, 0xFFFF, 0x8005, false);
|
||||||
// set CRC length to 0 to disable CRC
|
// set CRC length to 0 to disable CRC
|
||||||
|
|
||||||
#warning "This sketch is just an API guide! Read the note at line 6."
|
#warning "This sketch is just an API guide! Read the note at line 6."
|
||||||
|
@ -97,11 +88,11 @@ void loop() {
|
||||||
// as the LoRa modem, even their interrupt-driven versions
|
// as the LoRa modem, even their interrupt-driven versions
|
||||||
|
|
||||||
// transmit FSK packet
|
// transmit FSK packet
|
||||||
int state = fsk.transmit("Hello World!");
|
int state = radio.transmit("Hello World!");
|
||||||
/*
|
/*
|
||||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||||
0x89, 0xAB, 0xCD, 0xEF};
|
0x89, 0xAB, 0xCD, 0xEF};
|
||||||
int state = lora.transmit(byteArr, 8);
|
int state = radio.transmit(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("[SX1262] Packet transmitted successfully!"));
|
Serial.println(F("[SX1262] Packet transmitted successfully!"));
|
||||||
|
@ -116,10 +107,10 @@ void loop() {
|
||||||
|
|
||||||
// receive FSK packet
|
// receive FSK packet
|
||||||
String str;
|
String str;
|
||||||
state = fsk.receive(str);
|
state = radio.receive(str);
|
||||||
/*
|
/*
|
||||||
byte byteArr[8];
|
byte byteArr[8];
|
||||||
int state = lora.receive(byteArr, 8);
|
int state = radio.receive(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("[SX1262] Received packet!"));
|
Serial.println(F("[SX1262] Received packet!"));
|
||||||
|
@ -139,13 +130,13 @@ void loop() {
|
||||||
// to transmit packet to a particular address,
|
// to transmit packet to a particular address,
|
||||||
// use the following methods:
|
// use the following methods:
|
||||||
//
|
//
|
||||||
// fsk.transmit("Hello World!", address);
|
// radio.transmit("Hello World!", address);
|
||||||
// fsk.startTransmit("Hello World!", address);
|
// radio.startTransmit("Hello World!", address);
|
||||||
|
|
||||||
// set node address to 0x02
|
// set node address to 0x02
|
||||||
state = fsk.setNodeAddress(0x02);
|
state = radio.setNodeAddress(0x02);
|
||||||
// set broadcast address to 0xFF
|
// set broadcast address to 0xFF
|
||||||
state = fsk.setBroadcastAddress(0xFF);
|
state = radio.setBroadcastAddress(0xFF);
|
||||||
if (state != ERR_NONE) {
|
if (state != ERR_NONE) {
|
||||||
Serial.println(F("[SX1262] Unable to set address filter, code "));
|
Serial.println(F("[SX1262] Unable to set address filter, code "));
|
||||||
Serial.println(state);
|
Serial.println(state);
|
||||||
|
@ -155,7 +146,7 @@ void loop() {
|
||||||
// NOTE: calling this method will also erase previously set
|
// NOTE: calling this method will also erase previously set
|
||||||
// node and broadcast address
|
// node and broadcast address
|
||||||
/*
|
/*
|
||||||
state = fsk.disableAddressFiltering();
|
state = radio.disableAddressFiltering();
|
||||||
if (state != ERR_NONE) {
|
if (state != ERR_NONE) {
|
||||||
Serial.println(F("Unable to remove address filter, code "));
|
Serial.println(F("Unable to remove address filter, code "));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
Other modules from SX126x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -25,29 +28,18 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 lora = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
//SX1262 lora = RadioShield.ModuleA;
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize SX1262 with default settings
|
// initialize SX1262 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = lora.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,12 +57,12 @@ void loop() {
|
||||||
// See example ReceiveInterrupt for details
|
// See example ReceiveInterrupt for details
|
||||||
// on non-blocking reception method.
|
// on non-blocking reception method.
|
||||||
String str;
|
String str;
|
||||||
int state = lora.receive(str);
|
int state = radio.receive(str);
|
||||||
|
|
||||||
// you can also receive data as byte array
|
// you can also receive data as byte array
|
||||||
/*
|
/*
|
||||||
byte byteArr[8];
|
byte byteArr[8];
|
||||||
int state = lora.receive(byteArr, 8);
|
int state = radio.receive(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
|
@ -84,13 +76,13 @@ void loop() {
|
||||||
// print the RSSI (Received Signal Strength Indicator)
|
// print the RSSI (Received Signal Strength Indicator)
|
||||||
// of the last received packet
|
// of the last received packet
|
||||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||||
Serial.print(lora.getRSSI());
|
Serial.print(radio.getRSSI());
|
||||||
Serial.println(F(" dBm"));
|
Serial.println(F(" dBm"));
|
||||||
|
|
||||||
// print the SNR (Signal-to-Noise Ratio)
|
// print the SNR (Signal-to-Noise Ratio)
|
||||||
// of the last received packet
|
// of the last received packet
|
||||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||||
Serial.print(lora.getSNR());
|
Serial.print(radio.getSNR());
|
||||||
Serial.println(F(" dB"));
|
Serial.println(F(" dB"));
|
||||||
|
|
||||||
} else if (state == ERR_RX_TIMEOUT) {
|
} else if (state == ERR_RX_TIMEOUT) {
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
- coding rate
|
- coding rate
|
||||||
- sync word
|
- sync word
|
||||||
|
|
||||||
Other modules from SX126x/RFM9x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
|
@ -26,29 +29,18 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 lora = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
//SX1262 lora = RadioShield.ModuleA;
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize SX1262 with default settings
|
// initialize SX1262 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = lora.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,11 +51,11 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when new packet is received
|
// when new packet is received
|
||||||
lora.setDio1Action(setFlag);
|
radio.setDio1Action(setFlag);
|
||||||
|
|
||||||
// start listening for LoRa packets
|
// start listening for LoRa packets
|
||||||
Serial.print(F("[SX1262] Starting to listen ... "));
|
Serial.print(F("[SX1262] Starting to listen ... "));
|
||||||
state = lora.startReceive();
|
state = radio.startReceive();
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,12 +67,12 @@ void setup() {
|
||||||
// if needed, 'listen' mode can be disabled by calling
|
// if needed, 'listen' mode can be disabled by calling
|
||||||
// any of the following methods:
|
// any of the following methods:
|
||||||
//
|
//
|
||||||
// lora.standby()
|
// radio.standby()
|
||||||
// lora.sleep()
|
// radio.sleep()
|
||||||
// lora.transmit();
|
// radio.transmit();
|
||||||
// lora.receive();
|
// radio.receive();
|
||||||
// lora.readData();
|
// radio.readData();
|
||||||
// lora.scanChannel();
|
// radio.scanChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag to indicate that a packet was received
|
// flag to indicate that a packet was received
|
||||||
|
@ -115,12 +107,12 @@ void loop() {
|
||||||
|
|
||||||
// you can read received data as an Arduino String
|
// you can read received data as an Arduino String
|
||||||
String str;
|
String str;
|
||||||
int state = lora.readData(str);
|
int state = radio.readData(str);
|
||||||
|
|
||||||
// you can also read received data as byte array
|
// you can also read received data as byte array
|
||||||
/*
|
/*
|
||||||
byte byteArr[8];
|
byte byteArr[8];
|
||||||
int state = lora.readData(byteArr, 8);
|
int state = radio.readData(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
|
@ -133,12 +125,12 @@ void loop() {
|
||||||
|
|
||||||
// print RSSI (Received Signal Strength Indicator)
|
// print RSSI (Received Signal Strength Indicator)
|
||||||
Serial.print(F("[SX1262] RSSI:\t\t"));
|
Serial.print(F("[SX1262] RSSI:\t\t"));
|
||||||
Serial.print(lora.getRSSI());
|
Serial.print(radio.getRSSI());
|
||||||
Serial.println(F(" dBm"));
|
Serial.println(F(" dBm"));
|
||||||
|
|
||||||
// print SNR (Signal-to-Noise Ratio)
|
// print SNR (Signal-to-Noise Ratio)
|
||||||
Serial.print(F("[SX1262] SNR:\t\t"));
|
Serial.print(F("[SX1262] SNR:\t\t"));
|
||||||
Serial.print(lora.getSNR());
|
Serial.print(radio.getSNR());
|
||||||
Serial.println(F(" dB"));
|
Serial.println(F(" dB"));
|
||||||
|
|
||||||
} else if (state == ERR_CRC_MISMATCH) {
|
} else if (state == ERR_CRC_MISMATCH) {
|
||||||
|
@ -153,7 +145,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// put module back to listen mode
|
// put module back to listen mode
|
||||||
lora.startReceive();
|
radio.startReceive();
|
||||||
|
|
||||||
// we're ready to receive more packets,
|
// we're ready to receive more packets,
|
||||||
// enable interrupt service routine
|
// enable interrupt service routine
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
Other modules from SX126x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -29,14 +32,14 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 loraSX1262 = new Module(10, 2, 3, 9);
|
SX1262 radio1 = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// SX12628 has different connections:
|
// SX12628 has different connections:
|
||||||
// NSS pin: 8
|
// NSS pin: 8
|
||||||
// DIO1 pin: 4
|
// DIO1 pin: 4
|
||||||
// NRST pin: 5
|
// NRST pin: 5
|
||||||
// BUSY pin: 6
|
// BUSY pin: 6
|
||||||
SX1268 loraSX1268 = new Module(8, 4, 5, 6);
|
SX1268 radio2 = new Module(8, 4, 5, 6);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
|
@ -47,18 +50,7 @@ void setup() {
|
||||||
|
|
||||||
// initialize SX1268 with default settings
|
// initialize SX1268 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio1.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = loraSX1262.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,8 +72,7 @@ void setup() {
|
||||||
// output power: 2 dBm
|
// output power: 2 dBm
|
||||||
// current limit: 50 mA
|
// current limit: 50 mA
|
||||||
// preamble length: 20 symbols
|
// preamble length: 20 symbols
|
||||||
// CRC: enabled
|
state = radio2.begin(915.0, 500.0, 6, 5, 0x34, 50, 20);
|
||||||
state = loraSX1268.begin(915.0, 500.0, 6, 5, 0x34, 50, 20);
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -94,56 +85,56 @@ void setup() {
|
||||||
// and check if the configuration was changed successfully
|
// and check if the configuration was changed successfully
|
||||||
|
|
||||||
// set carrier frequency to 433.5 MHz
|
// set carrier frequency to 433.5 MHz
|
||||||
if (loraSX1262.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||||
Serial.println(F("Selected frequency is invalid for this module!"));
|
Serial.println(F("Selected frequency is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set bandwidth to 250 kHz
|
// set bandwidth to 250 kHz
|
||||||
if (loraSX1262.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
if (radio1.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||||
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
Serial.println(F("Selected bandwidth is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set spreading factor to 10
|
// set spreading factor to 10
|
||||||
if (loraSX1262.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
if (radio1.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||||
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
Serial.println(F("Selected spreading factor is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set coding rate to 6
|
// set coding rate to 6
|
||||||
if (loraSX1262.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
if (radio1.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||||
Serial.println(F("Selected coding rate is invalid for this module!"));
|
Serial.println(F("Selected coding rate is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set LoRa sync word to 0xAB
|
// set LoRa sync word to 0xAB
|
||||||
if (loraSX1262.setSyncWord(0xAB) != ERR_NONE) {
|
if (radio1.setSyncWord(0xAB) != ERR_NONE) {
|
||||||
Serial.println(F("Unable to set sync word!"));
|
Serial.println(F("Unable to set sync word!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set output power to 10 dBm (accepted range is -17 - 22 dBm)
|
// set output power to 10 dBm (accepted range is -17 - 22 dBm)
|
||||||
if (loraSX1262.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
if (radio1.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||||
Serial.println(F("Selected output power is invalid for this module!"));
|
Serial.println(F("Selected output power is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
// set over current protection limit to 80 mA (accepted range is 45 - 240 mA)
|
||||||
// NOTE: set value to 0 to disable overcurrent protection
|
// NOTE: set value to 0 to disable overcurrent protection
|
||||||
if (loraSX1262.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
if (radio1.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||||
Serial.println(F("Selected current limit is invalid for this module!"));
|
Serial.println(F("Selected current limit is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set LoRa preamble length to 15 symbols (accepted range is 0 - 65535)
|
// set LoRa preamble length to 15 symbols (accepted range is 0 - 65535)
|
||||||
if (loraSX1262.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
if (radio1.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||||
Serial.println(F("Selected preamble length is invalid for this module!"));
|
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable CRC
|
// disable CRC
|
||||||
if (loraSX1262.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
if (radio1.setCRC(false) == ERR_INVALID_CRC_CONFIGURATION) {
|
||||||
Serial.println(F("Selected CRC is invalid for this module!"));
|
Serial.println(F("Selected CRC is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +142,7 @@ void setup() {
|
||||||
// Some SX126x modules have TCXO (temperature compensated crystal
|
// Some SX126x modules have TCXO (temperature compensated crystal
|
||||||
// oscillator). To configure TCXO reference voltage,
|
// oscillator). To configure TCXO reference voltage,
|
||||||
// the following method can be used.
|
// the following method can be used.
|
||||||
if (loraSX1262.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) {
|
if (radio1.setTCXO(2.4) == ERR_INVALID_TCXO_VOLTAGE) {
|
||||||
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
|
Serial.println(F("Selected TCXO voltage is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +151,7 @@ void setup() {
|
||||||
// this feature, the following method can be used.
|
// this feature, the following method can be used.
|
||||||
// NOTE: As long as DIO2 is configured to control RF switch,
|
// NOTE: As long as DIO2 is configured to control RF switch,
|
||||||
// it can't be used as interrupt pin!
|
// it can't be used as interrupt pin!
|
||||||
if (loraSX1262.setDio2AsRfSwitch() != ERR_NONE) {
|
if (radio1.setDio2AsRfSwitch() != ERR_NONE) {
|
||||||
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
Serial.println(F("Failed to set DIO2 as RF switch!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
Other modules from SX126x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -21,29 +24,18 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 lora = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
// or using RadioShield
|
// or using RadioShield
|
||||||
// https://github.com/jgromes/RadioShield
|
// https://github.com/jgromes/RadioShield
|
||||||
//SX1262 lora = RadioShield.ModuleA;
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
|
||||||
// initialize SX1262 with default settings
|
// initialize SX1262 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = lora.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +51,7 @@ void setup() {
|
||||||
// RX enable: 4
|
// RX enable: 4
|
||||||
// TX enable: 5
|
// TX enable: 5
|
||||||
/*
|
/*
|
||||||
lora.setRfSwitchPins(4, 5);
|
radio.setRfSwitchPins(4, 5);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,12 +63,12 @@ void loop() {
|
||||||
// NOTE: transmit() is a blocking method!
|
// NOTE: transmit() is a blocking method!
|
||||||
// See example SX126x_Transmit_Interrupt for details
|
// See example SX126x_Transmit_Interrupt for details
|
||||||
// on non-blocking transmission method.
|
// on non-blocking transmission method.
|
||||||
int state = lora.transmit("Hello World!");
|
int state = radio.transmit("Hello World!");
|
||||||
|
|
||||||
// you can also transmit byte array up to 256 bytes long
|
// you can also transmit byte array up to 256 bytes long
|
||||||
/*
|
/*
|
||||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
|
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
|
||||||
int state = lora.transmit(byteArr, 8);
|
int state = radio.transmit(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
|
@ -85,7 +77,7 @@ void loop() {
|
||||||
|
|
||||||
// print measured data rate
|
// print measured data rate
|
||||||
Serial.print(F("[SX1262] Datarate:\t"));
|
Serial.print(F("[SX1262] Datarate:\t"));
|
||||||
Serial.print(lora.getDataRate());
|
Serial.print(radio.getDataRate());
|
||||||
Serial.println(F(" bps"));
|
Serial.println(F(" bps"));
|
||||||
|
|
||||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
Other modules from SX126x family can also be used.
|
Other modules from SX126x family can also be used.
|
||||||
|
|
||||||
|
For default module settings, see the wiki page
|
||||||
|
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
|
||||||
|
|
||||||
For full API reference, see the GitHub Pages
|
For full API reference, see the GitHub Pages
|
||||||
https://jgromes.github.io/RadioLib/
|
https://jgromes.github.io/RadioLib/
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +25,11 @@
|
||||||
// DIO1 pin: 2
|
// DIO1 pin: 2
|
||||||
// NRST pin: 3
|
// NRST pin: 3
|
||||||
// BUSY pin: 9
|
// BUSY pin: 9
|
||||||
SX1262 lora = new Module(10, 2, 3, 9);
|
SX1262 radio = new Module(10, 2, 3, 9);
|
||||||
|
|
||||||
|
// or using RadioShield
|
||||||
|
// https://github.com/jgromes/RadioShield
|
||||||
|
//SX1262 radio = RadioShield.ModuleA;
|
||||||
|
|
||||||
// save transmission state between loops
|
// save transmission state between loops
|
||||||
int transmissionState = ERR_NONE;
|
int transmissionState = ERR_NONE;
|
||||||
|
@ -32,18 +39,7 @@ void setup() {
|
||||||
|
|
||||||
// initialize SX1262 with default settings
|
// initialize SX1262 with default settings
|
||||||
Serial.print(F("[SX1262] Initializing ... "));
|
Serial.print(F("[SX1262] Initializing ... "));
|
||||||
// carrier frequency: 434.0 MHz
|
int state = radio.begin();
|
||||||
// bandwidth: 125.0 kHz
|
|
||||||
// spreading factor: 9
|
|
||||||
// coding rate: 7
|
|
||||||
// sync word: 0x12 (private network)
|
|
||||||
// output power: 14 dBm
|
|
||||||
// current limit: 60 mA
|
|
||||||
// preamble length: 8 symbols
|
|
||||||
// TCXO voltage: 1.6 V (set to 0 to not use TCXO)
|
|
||||||
// regulator: DC-DC (set to true to use LDO)
|
|
||||||
// CRC: enabled
|
|
||||||
int state = lora.begin();
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,20 +50,20 @@ void setup() {
|
||||||
|
|
||||||
// set the function that will be called
|
// set the function that will be called
|
||||||
// when packet transmission is finished
|
// when packet transmission is finished
|
||||||
lora.setDio1Action(setFlag);
|
radio.setDio1Action(setFlag);
|
||||||
|
|
||||||
// start transmitting the first packet
|
// start transmitting the first packet
|
||||||
Serial.print(F("[SX1262] Sending first packet ... "));
|
Serial.print(F("[SX1262] Sending first packet ... "));
|
||||||
|
|
||||||
// you can transmit C-string or Arduino string up to
|
// you can transmit C-string or Arduino string up to
|
||||||
// 256 characters long
|
// 256 characters long
|
||||||
transmissionState = lora.startTransmit("Hello World!");
|
transmissionState = radio.startTransmit("Hello World!");
|
||||||
|
|
||||||
// you can also transmit byte array up to 256 bytes long
|
// you can also transmit byte array up to 256 bytes long
|
||||||
/*
|
/*
|
||||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||||
0x89, 0xAB, 0xCD, 0xEF};
|
0x89, 0xAB, 0xCD, 0xEF};
|
||||||
state = lora.startTransmit(byteArr, 8);
|
state = radio.startTransmit(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,13 +119,13 @@ void loop() {
|
||||||
|
|
||||||
// you can transmit C-string or Arduino string up to
|
// you can transmit C-string or Arduino string up to
|
||||||
// 256 characters long
|
// 256 characters long
|
||||||
transmissionState = lora.startTransmit("Hello World!");
|
transmissionState = radio.startTransmit("Hello World!");
|
||||||
|
|
||||||
// you can also transmit byte array up to 256 bytes long
|
// you can also transmit byte array up to 256 bytes long
|
||||||
/*
|
/*
|
||||||
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
byte byteArr[] = {0x01, 0x23, 0x45, 0x67,
|
||||||
0x89, 0xAB, 0xCD, 0xEF};
|
0x89, 0xAB, 0xCD, 0xEF};
|
||||||
int state = lora.startTransmit(byteArr, 8);
|
int state = radio.startTransmit(byteArr, 8);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// we're ready to send more packets,
|
// we're ready to send more packets,
|
||||||
|
|
Loading…
Add table
Reference in a new issue