Error: cannot convert 'String' to 'const char*' for argument '1' to 'char* strst

Hi all,

I am working on a section of code that if the incoming LoRa packet includes your ID it will delete your ID!

Error:
cannot convert ‘String’ to ‘const char*’ for argument ‘1’ to ‘char* strstr(const char*, const char*)’

Code

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

/*DEFINE THE PINS USED BY LORA TRANSCEIVER MODULE*/
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

/*SET THE CHANNEL AND FREQUENCY OF LORA TRANSCEIVER*/
#define BAND 915E6 //915MHz, E6 channel

/*DEFINE THE PINS USED BY THE OLED SCREEN*/
#define OLED_SDA 4
#define OLED_SCL 15
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); //WHAT DOES THIS DO?

int myID = +6488436924;

int receivedMessage;

const byte numChars = 85;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

String loraData;

void setup() {

  /*INITIALIZE THE SERIAL MONITOR*/
  Serial.begin(115200); //set the baud rate to 115200

  /*RESET OLED DISPLAY VIA SOFTWARE*/
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  /*INIALIZE THE OLED DISPLAY*/
  Wire.begin(OLED_SDA, OLED_SCL);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 OLED
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  /*SETUP THE OLED SCREEN AND DISPLAY SOME TEXT*/
  display.clearDisplay(); //clear the OLED display
  display.setTextColor(WHITE); //Set the text colour to white
  display.setTextSize(1); //set the text size
  display.setCursor(0, 0); //start at top left of OLED screen
  display.print("LORA TRANSCEIVER "); //display title "LORA TRANSCEIVER"
  display.display(); //WHAT DOES THIS DO?

  /*DEFINE SOME PINS FOR OLED AND LORA MODULE*/
  SPI.begin(SCK, MISO, MOSI, SS);  //SPI LoRa pins
  LoRa.setPins(SS, RST, DIO0);   //setup LoRa transceiver module

  /*START-UP LORA MODULE?*/
  if (!LoRa.begin(BAND)) { //if LoRa does to begin 915E6?
    Serial.println("Starting LoRa failed!"); //Serial.print
    while (1);
  }

  /*SET THE LORA MODULES SPREADING FACTOR, SYNC WORD*/
  LoRa.setSpreadingFactor(12); //LoRa spreading factor can range from 7 to 12 (Minimize bandwidth and maximize spreading factor to boost link budget. Maximize coding rate to boost reliability)
  LoRa.setSyncWord(0x87); // ranges from 0-0xFF, default 0x34, see API docs

  /*TELL USER THAT LORA SETUP WAS SUCCESSFUL VIA OLED SCREEN*/
  display.setCursor(0, 10); //OLED screen second line far left
  display.print("LoRa Initializing OK!"); //display on OLED screen
  display.display(); //WHAT DOES THIS DO?
  delay(2000);
}

void loop() {

  display.clearDisplay(); //clear OLED screen
  display.setCursor(0, 0); //start at top left of screen
  display.println("LORA TRANSCEIVER"); //display text "LORA TRANSCEIVER"
  display.display();

  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    //read packet
    while (LoRa.available()) {
      loraData = LoRa.readString();
    }

    //print RSSI of packet
    int rssi = LoRa.packetRssi();

    Serial.println ("Message Received:");
    //Serial.println (LoRaData);
    /*If New LoRa Data Has Been Received Send this Data to the phone and Store the Lat and Long Data in Variables*/
    if (strstr(loraData, myID)) { //if data received includes my ID
      strcpy(receivedMessage, (char *)(strstr(loraData, myID) + 11)); //make variable lat1 = the received data excluding the word "lat"
      Serial.print (loraData);
    }

    // Dsiplay information
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("MESSAGE RECEIVED");
    display.setCursor(0, 20);
    display.print(loraData);
    display.setCursor(0, 55);
    display.print("RSSI:");
    display.setCursor(30, 55);
    display.print(rssi);
    display.display();
    delay (5000);
  }

  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;

  while (Serial.available() > 85) {
    Serial.println ("Error: Message Over 85 Characters ");
  }

  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    LoRa.beginPacket(); //begin the LoRa packet
    LoRa.print(receivedChars); //include the variiable "counter"
    LoRa.endPacket(); //end and send the LoRa packet

    newData = false;

    Serial.println ("Message Sent:");
    Serial.println (receivedChars);

    display.clearDisplay(); //clear OLED screen
    display.setCursor(0, 0); //start at top left of screen
    display.println("MESSAGE SENT"); //display text "LORA SENDER"
    display.setCursor(0, 20); //second line far left of OLED screen
    display.setTextSize(1); //set the OLED screen text size
    display.print(receivedChars); //display text "LoRa packet sent." on OLED screen
    display.display();
    delay (5000);
  }
}

How might I be able to fix this?

Thanks,

Zeb

If you would have taken the time to just google for "cannot convert 'String' to 'const char*' for argument '1' to 'char* strst", you would have gotten your answer.

Pieter

Thank you, sorry I will research before posting in the future!

Thanks again,

Zeb

Have you checked whether the number below fits into an "int"?

int myID = +6488436924;

Hi jremington,

You're right it can't even fit in a "long" variable!

I will have a look at potential solutions for this!

Thanks,

Zeb

....I guess I could divide the number by 1000 to store it and times it by 1000 when I want to use it!

Thanks,

Zeb

You could use uint64_t.

Thanks PieterP!

I am trying to use the String to Int function
https://www.arduino.cc/en/Tutorial.StringToIntExample

    /*If New LoRa Data Has Been Received Send this Data to the phone and Store the Lat and Long Data in Variables*/
    if (strstr(loraData.toInt(), myID)) { //if data received includes my ID
      strcpy(storeReceivedMessage, (char *)(strstr(loraData.toInt(), myID) + 11));
      Serial.print (storeReceivedMessage);
    }

But I am getting this error:
invalid conversion from 'long int' to 'const char*' [-fpermissive]

I can't exactly understand this as there are no "const" chars in my program that I can see!

Any help with this problem would be wonderful!

Thanks,

Zeb

…Here is all my code!

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

/*DEFINE THE PINS USED BY LORA TRANSCEIVER MODULE*/
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

/*SET THE CHANNEL AND FREQUENCY OF LORA TRANSCEIVER*/
#define BAND 915E6 //915MHz, E6 channel

/*DEFINE THE PINS USED BY THE OLED SCREEN*/
#define OLED_SDA 4
#define OLED_SCL 15
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); //WHAT DOES THIS DO?

int myID = 6488436924/1000;

int receivedLoraMessage;

int storeReceivedMessage;

const byte numChars = 85;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

String loraData;

void setup() {

  /*INITIALIZE THE SERIAL MONITOR*/
  Serial.begin(115200); //set the baud rate to 115200

  /*RESET OLED DISPLAY VIA SOFTWARE*/
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  /*INIALIZE THE OLED DISPLAY*/
  Wire.begin(OLED_SDA, OLED_SCL);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 OLED
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  /*SETUP THE OLED SCREEN AND DISPLAY SOME TEXT*/
  display.clearDisplay(); //clear the OLED display
  display.setTextColor(WHITE); //Set the text colour to white
  display.setTextSize(1); //set the text size
  display.setCursor(0, 0); //start at top left of OLED screen
  display.print("LORA TRANSCEIVER "); //display title "LORA TRANSCEIVER"
  display.display(); //WHAT DOES THIS DO?

  /*DEFINE SOME PINS FOR OLED AND LORA MODULE*/
  SPI.begin(SCK, MISO, MOSI, SS);  //SPI LoRa pins
  LoRa.setPins(SS, RST, DIO0);   //setup LoRa transceiver module

  /*START-UP LORA MODULE?*/
  if (!LoRa.begin(BAND)) { //if LoRa does to begin 915E6?
    Serial.println("Starting LoRa failed!"); //Serial.print
    while (1);
  }

  /*SET THE LORA MODULES SPREADING FACTOR, SYNC WORD*/
  LoRa.setSpreadingFactor(12); //LoRa spreading factor can range from 7 to 12 (Minimize bandwidth and maximize spreading factor to boost link budget. Maximize coding rate to boost reliability)
  LoRa.setSyncWord(0x87); // ranges from 0-0xFF, default 0x34, see API docs

  /*TELL USER THAT LORA SETUP WAS SUCCESSFUL VIA OLED SCREEN*/
  display.setCursor(0, 10); //OLED screen second line far left
  display.print("LoRa Initializing OK!"); //display on OLED screen
  display.display(); //WHAT DOES THIS DO?
  delay(2000);
}

void loop() {

  display.clearDisplay(); //clear OLED screen
  display.setCursor(0, 0); //start at top left of screen
  display.println("LORA TRANSCEIVER"); //display text "LORA TRANSCEIVER"
  display.display();

  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    //read packet
    while (LoRa.available()) {
      loraData = LoRa.readString();
    }

    //print RSSI of packet
    int rssi = LoRa.packetRssi();

    Serial.println ("Message Received:");

    /*If New LoRa Data Has Been Received Send this Data to the phone and Store the Lat and Long Data in Variables*/
    if (strstr(loraData.toInt(), myID)) { //if data received includes my ID
      strcpy(storeReceivedMessage, (char *)(strstr(loraData.toInt(), myID) + 11));
      Serial.print (storeReceivedMessage);
    }

    // Dsiplay information
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("MESSAGE RECEIVED");
    display.setCursor(0, 20);
    display.print(loraData);
    display.setCursor(0, 55);
    display.print("RSSI:");
    display.setCursor(30, 55);
    display.print(rssi);
    display.display();
    delay (5000);
  }

  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;

  while (Serial.available() > 85) {
    Serial.println ("Error: Message Over 85 Characters ");
  }

  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    LoRa.beginPacket(); //begin the LoRa packet
    LoRa.print(receivedChars); //include the variiable "counter"
    LoRa.endPacket(); //end and send the LoRa packet

    newData = false;

    Serial.println ("Message Sent:");
    Serial.println (receivedChars);

    display.clearDisplay(); //clear OLED screen
    display.setCursor(0, 0); //start at top left of screen
    display.println("MESSAGE SENT"); //display text "LORA SENDER"
    display.setCursor(0, 20); //second line far left of OLED screen
    display.setTextSize(1); //set the OLED screen text size
    display.print(receivedChars); //display text "LoRa packet sent." on OLED screen
    display.display();
    delay (5000);
  }
}
invalid conversion from 'long int' to 'const char*' [-fpermissive]

Which line does this error relate to ?
The full error message might be helpful. Please post it

Hi UKHeliBob,

I am really sorry for not posting that essential information!

The error relates to this line:

      strcpy(storeReceivedMessage, (char *)(strstr(loraData.toInt(), myID) + 11));

This appears to be the full error but I can post a screenshot in case I am missing something!
invalid conversion from 'long int' to 'const char*' [-fpermissive]

Thanks,

Zeb

The main thing I don't get about the error is why does it const char? I can't see that in the program!

      strcpy(storeReceivedMessage, (char *)(strstr(loraData.toInt(), myID) + 11));

strcpy() takes 2 arguments, both of which are pointers to strings
storeReceivedMessage is declared as an int

strstr() takes 2 arguments, both of which are pointers to strings
loraData.toInt() looks like it is an int and myID is declared as an int

Do you see any possible problems ?

Below, a C-string (zero terminated character array) is declared and initialized, which corresponds to your original attempt to store myID in an int variable:

char myID[] = "6488436924";

It is a good idea to spend some time learning about the differences between the various types of variables that are common used in the programming language.

Hi jremington,

Thank you that excellent! I will spend some time learning about variables!

Unfortunately it has not fixed the error though! (It is a lot better practice though!)

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

/*DEFINE THE PINS USED BY LORA TRANSCEIVER MODULE*/
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

/*SET THE CHANNEL AND FREQUENCY OF LORA TRANSCEIVER*/
#define BAND 915E6 //915MHz, E6 channel

/*DEFINE THE PINS USED BY THE OLED SCREEN*/
#define OLED_SDA 4
#define OLED_SCL 15
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); //WHAT DOES THIS DO?

char myID[] = "6488436924";

int receivedLoraMessage;

int storeReceivedMessage;

const byte numChars = 85;
char receivedChars[numChars];   // an array to store the received data

boolean newData = false;

String loraData;

void setup() {

  /*INITIALIZE THE SERIAL MONITOR*/
  Serial.begin(115200); //set the baud rate to 115200

  /*RESET OLED DISPLAY VIA SOFTWARE*/
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  /*INIALIZE THE OLED DISPLAY*/
  Wire.begin(OLED_SDA, OLED_SCL);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 OLED
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  /*SETUP THE OLED SCREEN AND DISPLAY SOME TEXT*/
  display.clearDisplay(); //clear the OLED display
  display.setTextColor(WHITE); //Set the text colour to white
  display.setTextSize(1); //set the text size
  display.setCursor(0, 0); //start at top left of OLED screen
  display.print("LORA TRANSCEIVER "); //display title "LORA TRANSCEIVER"
  display.display(); //WHAT DOES THIS DO?

  /*DEFINE SOME PINS FOR OLED AND LORA MODULE*/
  SPI.begin(SCK, MISO, MOSI, SS);  //SPI LoRa pins
  LoRa.setPins(SS, RST, DIO0);   //setup LoRa transceiver module

  /*START-UP LORA MODULE?*/
  if (!LoRa.begin(BAND)) { //if LoRa does to begin 915E6?
    Serial.println("Starting LoRa failed!"); //Serial.print
    while (1);
  }

  /*SET THE LORA MODULES SPREADING FACTOR, SYNC WORD*/
  LoRa.setSpreadingFactor(12); //LoRa spreading factor can range from 7 to 12 (Minimize bandwidth and maximize spreading factor to boost link budget. Maximize coding rate to boost reliability)
  LoRa.setSyncWord(0x87); // ranges from 0-0xFF, default 0x34, see API docs

  /*TELL USER THAT LORA SETUP WAS SUCCESSFUL VIA OLED SCREEN*/
  display.setCursor(0, 10); //OLED screen second line far left
  display.print("LoRa Initializing OK!"); //display on OLED screen
  display.display(); //WHAT DOES THIS DO?
  delay(2000);
}

void loop() {

  display.clearDisplay(); //clear OLED screen
  display.setCursor(0, 0); //start at top left of screen
  display.println("LORA TRANSCEIVER"); //display text "LORA TRANSCEIVER"
  display.display();

  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    //read packet
    while (LoRa.available()) {
      loraData = LoRa.readString();
    }

    //print RSSI of packet
    int rssi = LoRa.packetRssi();

    Serial.println ("Message Received:");

    /*If New LoRa Data Has Been Received Send this Data to the phone and Store the Lat and Long Data in Variables*/
    if (strstr(loraData.toInt(), myID)) { //if data received includes my ID
      strcpy(storeReceivedMessage, (char *)(strstr(loraData.toInt(), myID) + 11));
      Serial.print (storeReceivedMessage);
    }

    // Dsiplay information
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("MESSAGE RECEIVED");
    display.setCursor(0, 20);
    display.print(loraData);
    display.setCursor(0, 55);
    display.print("RSSI:");
    display.setCursor(30, 55);
    display.print(rssi);
    display.display();
    delay (5000);
  }

  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;

  while (Serial.available() > 85) {
    Serial.println ("Error: Message Over 85 Characters ");
  }

  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    LoRa.beginPacket(); //begin the LoRa packet
    LoRa.print(receivedChars); //include the variiable "counter"
    LoRa.endPacket(); //end and send the LoRa packet

    newData = false;

    Serial.println ("Message Sent:");
    Serial.println (receivedChars);

    display.clearDisplay(); //clear OLED screen
    display.setCursor(0, 0); //start at top left of screen
    display.println("MESSAGE SENT"); //display text "LORA SENDER"
    display.setCursor(0, 20); //second line far left of OLED screen
    display.setTextSize(1); //set the OLED screen text size
    display.print(receivedChars); //display text "LoRa packet sent." on OLED screen
    display.display();
    delay (5000);
  }
}

Do you have any other ideas on what the problem might be?

Thanks for your help,

Zeb

...Oops just seen UKHeliBob's message!

Hi UKHeliBob,

Does that mean that variables "storeReceivedMessage" and "loraData" need to be declared as strings?
https://www.arduino.cc/reference/en/language/variables/data-types/char/

Thanks,

Zeb

Now would be a good time for you to state exactly what it is you are trying to do.

I'll bet that this will require you to understand the functions that you are calling; what they are supposed to do; and what the overall task requires.

Hi jremington,

Thanks for your advice it is now working!

Code:

//Libraries for LoRa
#include <SPI.h>
#include <LoRa.h>

//Libraries for OLED Display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

/*DEFINE THE PINS USED BY LORA TRANSCEIVER MODULE*/
#define SCK 5
#define MISO 19
#define MOSI 27
#define SS 18
#define RST 14
#define DIO0 26

/*SET THE CHANNEL AND FREQUENCY OF LORA TRANSCEIVER*/
#define BAND 915E6 //915MHz, E6 channel

/*DEFINE THE PINS USED BY THE OLED SCREEN*/
#define OLED_SDA 4
#define OLED_SCL 15
#define OLED_RST 16
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RST); //WHAT DOES THIS DO?

char myID[] = "6488436924";

const byte numChars = 85;

char receivedChars[numChars];   // an array to store the received data from the Serial Monitor

char loraDataChar[numChars]; //An Array to copy the loraData String contents to

String loraData; //Received LoRa data goes in this String

boolean newData = false;

void setup() {

  /*INITIALIZE THE SERIAL MONITOR*/
  Serial.begin(115200); //set the baud rate to 115200

  /*RESET OLED DISPLAY VIA SOFTWARE*/
  pinMode(OLED_RST, OUTPUT);
  digitalWrite(OLED_RST, LOW);
  delay(20);
  digitalWrite(OLED_RST, HIGH);

  /*INIALIZE THE OLED DISPLAY*/
  Wire.begin(OLED_SDA, OLED_SCL);
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) { // Address 0x3C for 128x32 OLED
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  /*SETUP THE OLED SCREEN AND DISPLAY SOME TEXT*/
  display.clearDisplay(); //clear the OLED display
  display.setTextColor(WHITE); //Set the text colour to white
  display.setTextSize(1); //set the text size
  display.setCursor(0, 0); //start at top left of OLED screen
  display.print("LORA TRANSCEIVER "); //display title "LORA TRANSCEIVER"
  display.display(); //WHAT DOES THIS DO?

  /*DEFINE SOME PINS FOR OLED AND LORA MODULE*/
  SPI.begin(SCK, MISO, MOSI, SS);  //SPI LoRa pins
  LoRa.setPins(SS, RST, DIO0);   //setup LoRa transceiver module

  /*START-UP LORA MODULE?*/
  if (!LoRa.begin(BAND)) { //if LoRa does to begin 915E6?
    Serial.println("Starting LoRa failed!"); //Serial.print
    while (1);
  }

  /*SET THE LORA MODULES SPREADING FACTOR, SYNC WORD*/
  LoRa.setSpreadingFactor(12); //LoRa spreading factor can range from 7 to 12 (Minimize bandwidth and maximize spreading factor to boost link budget. Maximize coding rate to boost reliability)
  LoRa.setSyncWord(0x87); // ranges from 0-0xFF, default 0x34, see API docs

  /*TELL USER THAT LORA SETUP WAS SUCCESSFUL VIA OLED SCREEN*/
  display.setCursor(0, 10); //OLED screen second line far left
  display.print("LoRa Initializing OK!"); //display on OLED screen
  display.display(); //WHAT DOES THIS DO?
  delay(2000);
}

void loop() {

  display.clearDisplay(); //clear OLED screen
  display.setCursor(0, 0); //start at top left of screen
  display.println("LORA TRANSCEIVER"); //display text "LORA TRANSCEIVER"
  display.display();

  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    //read packet
    while (LoRa.available()) {
      loraData = LoRa.readString();
    }

    //print RSSI of packet
    int rssi = LoRa.packetRssi();

    Serial.println ("Message Received:");

    loraData.toCharArray(loraDataChar, numChars);

    /*If New LoRa Data Has Been Received Send this Data to the phone and Store the Lat and Long Data in Variables*/
    if (strstr(loraDataChar, myID)) { //if data received includes my ID
      strcpy(loraDataChar, (char *)(strstr(loraDataChar, myID) + strlen(myID)+1));
      Serial.print (loraDataChar);
    }
    else {
      Serial.print (loraDataChar);
    }

    // Dsiplay information
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("MESSAGE RECEIVED");
    display.setCursor(0, 20);
    display.print(loraData);
    display.setCursor(0, 55);
    display.print("RSSI:");
    display.setCursor(30, 55);
    display.print(rssi);
    display.display();
    delay (5000);
  }

  recvWithEndMarker();
  showNewData();
}

void recvWithEndMarker() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;

  while (Serial.available() > 85) {
    Serial.println ("Error: Message Over 85 Characters ");
  }

  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
      receivedChars[ndx] = '\0'; // terminate the string
      ndx = 0;
      newData = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    LoRa.beginPacket(); //begin the LoRa packet
    LoRa.print(receivedChars); //include the variiable "counter"
    LoRa.endPacket(); //end and send the LoRa packet

    newData = false;

    Serial.println ("Message Sent:");
    Serial.println (receivedChars);

    display.clearDisplay(); //clear OLED screen
    display.setCursor(0, 0); //start at top left of screen
    display.println("MESSAGE SENT"); //display text "LORA SENDER"
    display.setCursor(0, 20); //second line far left of OLED screen
    display.setTextSize(1); //set the OLED screen text size
    display.print(receivedChars); //display text "LoRa packet sent." on OLED screen
    display.display();
    delay (5000);
  }
}

Would it be possible for someone to look over my code and advise me if there is anything I could do better or more efficiently?

I will do code commenting soon!

Thanks very much to all who have helped!

Thanks again,

Zeb

Please note that I will add a section to the program that if the ID included in the message is not yours it will not display the message to you!

And of course if the ID included is yours only you can see it, and if no ID is included everybody will see it!

Thanks,

Zeb