// Begin serial communication
Serial.begin(38400);
// Begin LoRa radio and set NSS, reset, IRQ, txen, and rxen pin with connected arduino pins
Serial.println("Begin LoRa radio");
if defined(SX126X)
// Begin LoRa radio for SX126x and LLCC68
int8_t nssPin = 15, resetPin = 16, busyPin = A0, irqPin = -1, txenPin = 0, rxenPin = 2;
if (!LoRa.begin(nssPin, resetPin, busyPin, irqPin, txenPin, rxenPin)){
Serial.println("Something wrong, can't begin LoRa radio");
while(1);
}
// Configure TCXO used in RF module
Serial.println("Set RF module to use TCXO as clock reference");
LoRa.setDio3TcxoCtrl(SX126X_DIO3_OUTPUT_1_8, SX126X_TCXO_DELAY_10);
elif defined(SX127X)
// Begin LoRa radio for SX126x and LLCC68
int8_t nssPin = 10, resetPin = 9, irqPin = 2, txenPin = 8, rxenPin = 7;
if (!LoRa.begin(nssPin, resetPin, irqPin, txenPin, rxenPin)){
Serial.println("Something wrong, can't begin LoRa radio");
while(1);
}
endif
// Set frequency to 915 Mhz
Serial.println("Set frequency to 915 Mhz");
LoRa.setFrequency(915000000);
// Set RX gain. RX gain option are power saving gain or boosted gain
Serial.println("Set RX gain to power saving gain");
LoRa.setRxGain(LORA_RX_GAIN_POWER_SAVING); // Power saving gain
// Configure packet parameter including header type, preamble length, payload length, and CRC type
Serial.println("Set packet parameters:\n\tExplicit header type\n\tPreamble length = 12\n\tPayload Length = 15\n\tCRC on");
uint8_t headerType = LORA_HEADER_EXPLICIT; // Explicit header mode
uint16_t preambleLength = 12; // Set preamble length to 12
uint8_t payloadLength = 15; // Initialize payloadLength to 15
bool crcType = true; // Set CRC enable
LoRa.setLoRaPacket(headerType, preambleLength, payloadLength, crcType);
// Set syncronize word for public network (0x3444)
Serial.println("Set syncronize word to 0x3444");
LoRa.setSyncWord(0x3444);
Serial.println("\n-- LORA RECEIVER --\n");
}
void loop() {
// Transmit message and counter
// write() method must be placed between beginPacket() and endPacket()
LoRa.beginPacket();
LoRa.write(message, nBytes);
LoRa.write(counter);
LoRa.endPacket();
// Print message and counter in serial
Serial.print(message);
Serial.print(" ");
Serial.println(counter++);
// Wait until modulation process for transmitting packet finish
LoRa.wait();
hi, i'm having this as output when testing sending data with e22-900m-30s module with wemos d1 mini:
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
Exception (4): epc1=0x402010a0 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: cont sp: 3ffffe40 end: 3fffffd0 offset: 0160 3fffffa0: 00000002 feefeffe feefeffe feefeffe
3fffffb0: 3fffdad0 00000000 3ffee784 40203054
3fffffc0: feefeffe feefeffe 3fffdab0 40100fb1
<<<stack<<<
code:
`#include
include
define SX126X
//#define SX127X
if defined(SX126X)
SX126x LoRa;
elif defined(SX127X)
SX127x LoRa;
endif
// Message to transmit char message[] = "HeLoRa World!"; uint8_t nBytes = sizeof(message); uint8_t counter = 0;
void setup() {
// Begin serial communication Serial.begin(38400);
// Begin LoRa radio and set NSS, reset, IRQ, txen, and rxen pin with connected arduino pins Serial.println("Begin LoRa radio");
if defined(SX126X)
// Begin LoRa radio for SX126x and LLCC68 int8_t nssPin = 15, resetPin = 16, busyPin = A0, irqPin = -1, txenPin = 0, rxenPin = 2; if (!LoRa.begin(nssPin, resetPin, busyPin, irqPin, txenPin, rxenPin)){ Serial.println("Something wrong, can't begin LoRa radio"); while(1); } // Configure TCXO used in RF module Serial.println("Set RF module to use TCXO as clock reference"); LoRa.setDio3TcxoCtrl(SX126X_DIO3_OUTPUT_1_8, SX126X_TCXO_DELAY_10);
elif defined(SX127X)
// Begin LoRa radio for SX126x and LLCC68 int8_t nssPin = 10, resetPin = 9, irqPin = 2, txenPin = 8, rxenPin = 7; if (!LoRa.begin(nssPin, resetPin, irqPin, txenPin, rxenPin)){ Serial.println("Something wrong, can't begin LoRa radio"); while(1); }
endif
// Set frequency to 915 Mhz Serial.println("Set frequency to 915 Mhz"); LoRa.setFrequency(915000000);
// Set RX gain. RX gain option are power saving gain or boosted gain Serial.println("Set RX gain to power saving gain"); LoRa.setRxGain(LORA_RX_GAIN_POWER_SAVING); // Power saving gain
// Configure modulation parameter including spreading factor (SF), bandwidth (BW), and coding rate (CR) Serial.println("Set modulation parameters:\n\tSpreading factor = 7\n\tBandwidth = 125 kHz\n\tCoding rate = 4/5"); uint8_t sf = 7; // Spreading factor: 7 uint32_t bw = 125000; // Bandwidth: 125 kHz uint8_t cr = 5; // Coding rate: 4/5 LoRa.setLoRaModulation(sf, bw, cr);
// Configure packet parameter including header type, preamble length, payload length, and CRC type Serial.println("Set packet parameters:\n\tExplicit header type\n\tPreamble length = 12\n\tPayload Length = 15\n\tCRC on"); uint8_t headerType = LORA_HEADER_EXPLICIT; // Explicit header mode uint16_t preambleLength = 12; // Set preamble length to 12 uint8_t payloadLength = 15; // Initialize payloadLength to 15 bool crcType = true; // Set CRC enable LoRa.setLoRaPacket(headerType, preambleLength, payloadLength, crcType);
// Set syncronize word for public network (0x3444) Serial.println("Set syncronize word to 0x3444"); LoRa.setSyncWord(0x3444);
Serial.println("\n-- LORA RECEIVER --\n");
}
void loop() {
// Transmit message and counter // write() method must be placed between beginPacket() and endPacket() LoRa.beginPacket(); LoRa.write(message, nBytes); LoRa.write(counter); LoRa.endPacket();
// Print message and counter in serial Serial.print(message); Serial.print(" "); Serial.println(counter++);
// Wait until modulation process for transmitting packet finish LoRa.wait();
// Print transmit time Serial.print("Transmit time: "); Serial.print(LoRa.transmitTime()); Serial.println(" ms"); Serial.println();
// Don't load RF module with continous transmit delay(5000);
}`