LORA TEL0122 on FireBeetle ESP8266 cannot init.

userHead OracleDude 2022-04-19 10:27:17 726 Views1 Replies

Trying to get three LORA messengers created for long range chat while hiking.  Of course because I have a deadline of Friday, I can't get the covers to initialize.  Errors out at each lora.set* command, plus lora.init().  (As they errored out, I commented the offending command, then ran it again.)  Wired up D2:RESET and D4:CS as shown in the wiki.  Since that is the default, I'm not providing pin numbers for lora.init(). 

 

I couldn't find any examples of bi-directional messaging, so I came up with my own.   I think I got the logic down, but please let me know if you see something incorrect.  

 

Also, can the DFRobot LORA devices accept AT commands and use the generic LORA library?  There are some functions in the generic library that I'd like to try but DFRobot_LoRa doesn't have anything similar.

 

First time posting, so if putting code inline isn't proper etiquette, I apologize.

 

#include <DFRobot_LoRa.h>

DFRobot_LoRa lora;


#define TX_POWER  15
#define RF_FREQ   902300000
#define RF_BAND   125
#define RF_CW     4/5
#define RF_SF     8
#define RF_CRC    1
#define BUF_LEN    64

 

uint8_t     len;
uint8_t     rxBuf[BUF_LEN];
uint8_t     txBuf[BUF_LEN];
uint8_t     tempBuf[BUF_LEN];
uint16_t    sendCounter = 0;
uint16_t    recvCounter = 0;

 

void setup() {
 Serial.begin(115200);
 Serial.println();

 pinMode(LED_BUILTIN, OUTPUT);

 // Set Frequency
 while(!lora.setFrequency(RF_FREQ))  //902.3 – 914.9 MHz in 200 kHz increments or 8 channels - 903.0 – 914.2 MHz in 1.6 MHz increments 
 {
   Serial.print("Error Setting Frequency to ");
   Serial.println(RF_FREQ);
   delay(5000);
 }
 Serial.print("Frequency set to ");
 Serial.println(RF_FREQ);   
 lora.setFrequency(RF_FREQ);
 
 // Set Transmit Power
 while(!lora.setTxPower(15))
 {
   Serial.print("Error Setting TX Power to ");
   Serial.println(TX_POWER);
   delay(5000);
 }
 Serial.print("TX Power set to ");
 Serial.println(TX_POWER);   
 lora.setTxPower(15);
 
// Set RF Parameters
 lora.setRFpara(RF_BAND, RF_CW, RF_SF, RF_CRC);
 while(!lora.setRFpara(RF_BAND, RF_CW, RF_SF, RF_CRC))
 {
   Serial.println("Error Setting RF Parameters:");
   Serial.print(RF_BAND);
   Serial.print("|");
   Serial.print(RF_CW);
   Serial.print("|");
   Serial.print(RF_SF);
   Serial.print("|");
   Serial.print(RF_CRC);
 }
 Serial.println("RF Parameters set to ");
 Serial.print("Bandwidth: ");
 Serial.println(RF_BAND);    
 Serial.print("Coding Rate: ");
 Serial.println(RF_CW);
 Serial.print("Spread Factor: ");
 Serial.println(RF_SF);
 Serial.print("CRC Checking: ");
 if (RF_CRC)
 {
   Serial.println("TRUE");
 }
 else
 {
   Serial.println("FALSE");
 }
 
 while(!lora.init()) {
   Serial.println("Starting LoRa failed!");
   delay(2000);
 }
 lora.setPayloadLength(BUF_LEN); 
 lora.rxInit();
}

void loop() {
 if(lora.waitIrq())    // wait for RXDONE interrupt
 {
   lora.clearIRQFlags();
   len = lora.receivePackage(rxBuf);  // receive data
   Serial.write(rxBuf, len);
   Serial.println();
   lora.rxInit();    // wait for packet

   // print RSSI of packet
   Serial.print("Inbound Signal Strength:");
   Serial.println(lora.readRSSI());
   Serial.print("Received Messages:");
   Serial.println(recvCounter++);
   static uint8_t i;
   i = ~i;
   digitalWrite(LED_BUILTIN, i);
   len = 0;
 }

 if (Serial.available())  // incoming string from console
 {
   len=Serial.readBytes(txBuf,BUF_LEN);
   if (!lora.sendPackage(txBuf,len))   // send it
   {
     Serial.print("Sent Messages:");
     Serial.println(sendCounter++);
     digitalWrite(LED_BUILTIN, HIGH);
     delay(500);
     digitalWrite(LED_BUILTIN, LOW);
     len = 0;
   }
   else
   {
     Serial.println("Error sending message");
     len = 0;
   }
 }
}

 

2022-06-17 11:51:24

Hello! Is your issue resolved?

userHeadPic Tonny12138