[SX127x] Fixed typos in examples
This commit is contained in:
parent
0bafe185a9
commit
1bc2633048
7 changed files with 71 additions and 67 deletions
|
@ -48,11 +48,11 @@ void loop() {
|
||||||
|
|
||||||
if (state == PREAMBLE_DETECTED) {
|
if (state == PREAMBLE_DETECTED) {
|
||||||
// LoRa preamble was detected
|
// LoRa preamble was detected
|
||||||
Serial.println(" detected preamble!");
|
Serial.println(F(" detected preamble!"));
|
||||||
|
|
||||||
} else if (state == CHANNEL_FREE) {
|
} else if (state == CHANNEL_FREE) {
|
||||||
// no preamble was detected, channel is free
|
// no preamble was detected, channel is free
|
||||||
Serial.println(" channel is free!");
|
Serial.println(F(" channel is free!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ void setup() {
|
||||||
// current limit: 100 mA
|
// current limit: 100 mA
|
||||||
// data shaping: Gaussian, BT = 0.3
|
// data shaping: Gaussian, BT = 0.3
|
||||||
// sync word: 0x2D 0x01
|
// sync word: 0x2D 0x01
|
||||||
// OOK modulation: false
|
// OOK modulation: disabled
|
||||||
int state = fsk.beginFSK();
|
int state = fsk.beginFSK();
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
|
|
|
@ -65,26 +65,26 @@ void loop() {
|
||||||
Serial.println(F("success!"));
|
Serial.println(F("success!"));
|
||||||
|
|
||||||
// print the data of the packet
|
// print the data of the packet
|
||||||
Serial.print("[SX1278] Data:\t\t");
|
Serial.print(F("[SX1278] Data:\t\t"));
|
||||||
Serial.println(str);
|
Serial.println(str);
|
||||||
|
|
||||||
// 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("[SX1278] RSSI:\t\t");
|
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||||
Serial.print(lora.getRSSI());
|
Serial.print(lora.getRSSI());
|
||||||
Serial.println(" 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("[SX1278] SNR:\t\t");
|
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||||
Serial.print(lora.getSNR());
|
Serial.print(lora.getSNR());
|
||||||
Serial.println(" dBm");
|
Serial.println(F(" dBm"));
|
||||||
|
|
||||||
// print frequency error
|
// print frequency error
|
||||||
// of the last received packet
|
// of the last received packet
|
||||||
Serial.print("Frequency error:\t");
|
Serial.print(F("Frequency error:\t"));
|
||||||
Serial.print(lora.getFrequencyError());
|
Serial.print(lora.getFrequencyError());
|
||||||
Serial.println(" Hz");
|
Serial.println(F(" Hz"));
|
||||||
|
|
||||||
} else if (state == ERR_RX_TIMEOUT) {
|
} else if (state == ERR_RX_TIMEOUT) {
|
||||||
// timeout occurred while waiting for a packet
|
// timeout occurred while waiting for a packet
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
RadioLib SX127x Receive with Inerrupts Example
|
RadioLib SX127x Receive with Interrupts Example
|
||||||
|
|
||||||
This example listens for LoRa transmissions and tries to
|
This example listens for LoRa transmissions and tries to
|
||||||
receive them. Once a packet is received, an interrupt is
|
receive them. Once a packet is received, an interrupt is
|
||||||
|
@ -111,30 +111,30 @@ void loop() {
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// packet was successfully received
|
// packet was successfully received
|
||||||
Serial.println("[SX1278] Received packet!");
|
Serial.println(F("[SX1278] Received packet!"));
|
||||||
|
|
||||||
// print data of the packet
|
// print data of the packet
|
||||||
Serial.print("[SX1278] Data:\t\t");
|
Serial.print(F("[SX1278] Data:\t\t"));
|
||||||
Serial.println(str);
|
Serial.println(str);
|
||||||
|
|
||||||
// print RSSI (Received Signal Strength Indicator)
|
// print RSSI (Received Signal Strength Indicator)
|
||||||
Serial.print("[SX1278] RSSI:\t\t");
|
Serial.print(F("[SX1278] RSSI:\t\t"));
|
||||||
Serial.print(lora.getRSSI());
|
Serial.print(lora.getRSSI());
|
||||||
Serial.println(" dBm");
|
Serial.println(F(" dBm"));
|
||||||
|
|
||||||
// print SNR (Signal-to-Noise Ratio)
|
// print SNR (Signal-to-Noise Ratio)
|
||||||
Serial.print("[SX1278] SNR:\t\t");
|
Serial.print(F("[SX1278] SNR:\t\t"));
|
||||||
Serial.print(lora.getSNR());
|
Serial.print(lora.getSNR());
|
||||||
Serial.println(" dBm");
|
Serial.println(F(" dBm"));
|
||||||
|
|
||||||
// print frequency error
|
// print frequency error
|
||||||
Serial.print("[SX1278] Frequency error:\t");
|
Serial.print(F("[SX1278] Frequency error:\t"));
|
||||||
Serial.print(lora.getFrequencyError());
|
Serial.print(lora.getFrequencyError());
|
||||||
Serial.println(" Hz");
|
Serial.println(F(" Hz"));
|
||||||
|
|
||||||
} else if (state == ERR_CRC_MISMATCH) {
|
} else if (state == ERR_CRC_MISMATCH) {
|
||||||
// packet was received, but is malformed
|
// packet was received, but is malformed
|
||||||
Serial.println("CRC error!");
|
Serial.println(F("CRC error!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,12 @@
|
||||||
// SX1278 module is in slot A on the shield
|
// SX1278 module is in slot A on the shield
|
||||||
SX1278 loraSX1278 = RadioShield.ModuleA;
|
SX1278 loraSX1278 = RadioShield.ModuleA;
|
||||||
|
|
||||||
// SX1272 module is in slot B on the shield
|
// if you're not using RadioShield, you can specify
|
||||||
SX1272 loraSX1272 = RadioShield.ModuleB;
|
// the connection yourself
|
||||||
|
// NSS pin: 6
|
||||||
|
// DIO1 pin: 4
|
||||||
|
// DIO2 pin: 5
|
||||||
|
SX1272 loraSX1272 = new Module(6, 4, 5);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
|
@ -81,32 +85,32 @@ void setup() {
|
||||||
|
|
||||||
// set carrier frequency to 433.5 MHz
|
// set carrier frequency to 433.5 MHz
|
||||||
if (loraSX1278.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
if (loraSX1278.setFrequency(433.5) == ERR_INVALID_FREQUENCY) {
|
||||||
Serial.println("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 (loraSX1278.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
if (loraSX1278.setBandwidth(250.0) == ERR_INVALID_BANDWIDTH) {
|
||||||
Serial.println("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 (loraSX1278.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
if (loraSX1278.setSpreadingFactor(10) == ERR_INVALID_SPREADING_FACTOR) {
|
||||||
Serial.println("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 (loraSX1278.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
if (loraSX1278.setCodingRate(6) == ERR_INVALID_CODING_RATE) {
|
||||||
Serial.println("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 0x14
|
// set LoRa sync word to 0x14
|
||||||
// NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used
|
// NOTE: value 0x34 is reserved for LoRaWAN networks and should not be used
|
||||||
if (loraSX1278.setSyncWord(0x14) != ERR_NONE) {
|
if (loraSX1278.setSyncWord(0x14) != ERR_NONE) {
|
||||||
Serial.println("Unable to set sync word!");
|
Serial.println(F("Unable to set sync word!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,20 +118,20 @@ void setup() {
|
||||||
// NOTE: 20 dBm value allows high power operation, but transmission
|
// NOTE: 20 dBm value allows high power operation, but transmission
|
||||||
// duty cycle MUST NOT exceed 1%
|
// duty cycle MUST NOT exceed 1%
|
||||||
if (loraSX1278.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
if (loraSX1278.setOutputPower(10) == ERR_INVALID_OUTPUT_POWER) {
|
||||||
Serial.println("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 (loraSX1278.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
if (loraSX1278.setCurrentLimit(80) == ERR_INVALID_CURRENT_LIMIT) {
|
||||||
Serial.println("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 6 - 65535)
|
// set LoRa preamble length to 15 symbols (accepted range is 6 - 65535)
|
||||||
if (loraSX1278.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
if (loraSX1278.setPreambleLength(15) == ERR_INVALID_PREAMBLE_LENGTH) {
|
||||||
Serial.println("Selected preamble length is invalid for this module!");
|
Serial.println(F("Selected preamble length is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,11 +139,11 @@ void setup() {
|
||||||
// NOTE: set value to 0 to enable autmatic gain control
|
// NOTE: set value to 0 to enable autmatic gain control
|
||||||
// leave at 0 unless you know what you're doing
|
// leave at 0 unless you know what you're doing
|
||||||
if (loraSX1278.setGain(1) == ERR_INVALID_GAIN) {
|
if (loraSX1278.setGain(1) == ERR_INVALID_GAIN) {
|
||||||
Serial.println("Selected gain is invalid for this module!");
|
Serial.println(F("Selected gain is invalid for this module!"));
|
||||||
while (true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("All settings succesfully changed!");
|
Serial.println(F("All settings succesfully changed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
|
@ -58,20 +58,20 @@ void loop() {
|
||||||
|
|
||||||
if (state == ERR_NONE) {
|
if (state == ERR_NONE) {
|
||||||
// the packet was successfully transmitted
|
// the packet was successfully transmitted
|
||||||
Serial.println(" success!");
|
Serial.println(F(" success!"));
|
||||||
|
|
||||||
// print measured data rate
|
// print measured data rate
|
||||||
Serial.print("[SX1278] Datarate:\t");
|
Serial.print(F("[SX1278] Datarate:\t"));
|
||||||
Serial.print(lora.getDataRate());
|
Serial.print(lora.getDataRate());
|
||||||
Serial.println(" bps");
|
Serial.println(F(" bps"));
|
||||||
|
|
||||||
} else if (state == ERR_PACKET_TOO_LONG) {
|
} else if (state == ERR_PACKET_TOO_LONG) {
|
||||||
// the supplied packet was longer than 256 bytes
|
// the supplied packet was longer than 256 bytes
|
||||||
Serial.println(" too long!");
|
Serial.println(F(" too long!"));
|
||||||
|
|
||||||
} else if (state == ERR_TX_TIMEOUT) {
|
} else if (state == ERR_TX_TIMEOUT) {
|
||||||
// timeout occured while transmitting packet
|
// timeout occured while transmitting packet
|
||||||
Serial.println(" timeout!");
|
Serial.println(F(" timeout!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
RadioLib SX127x Transmit with Inerrupts Example
|
RadioLib SX127x Transmit with Interrupts Example
|
||||||
|
|
||||||
This example transmits LoRa packets with one second delays
|
This example transmits LoRa packets with one second delays
|
||||||
between them. Each packet contains up to 256 bytes
|
between them. Each packet contains up to 256 bytes
|
||||||
|
|
Loading…
Add table
Reference in a new issue