Unable to display data values received by a LORA transceiver in an I2C display.

Hi folks, I hope all of you are doing well with this hard times we are going through. Hopefully we'll get through this soon and back to our normal lives, many blessings!

My knowledge about arduino is somewhat low and if somebody could help, it is extremely appreciated. I hit a "dead end" with this and worked for about a month with no solution, despite of all the reading and other online help.

In a nutshell I am building two circuits: One (transceiver "B") that receives a signal to read Battery Voltage and RPM values of an engine that is working about 2KM away from transceiver "A". When transceiver "A" pulls a digital pin HIGH, it sends a "DATA REQUEST" signal to transceiver "B" and transceiver "B" sends the RPM and Battery voltage value back to Transceiver "A", then it is displayed in an I2C 4x20 display (at least, that is what my intention is :slight_smile: ).

I am using two 1w LoRa modules 433T30D from E-Byte on both ends working in normal "transparent" mode, and I know they are working fine, because if I open the serial monitor of Transceiver "A" I can see the RPM and Battery voltage data when I request data, the problems arrives when I try to display that "numerical" data into the corresponding line of the I2C display, the value shows as "ZERO" on both fields, RPM and Battery Voltage.

I am new to the the way members post code; if I make a mistake, please forgive me this time and I'll try doing it correctly next time. Below are the codes for both, transceiver "A" and "B" and thank you very much in advance for your guidance.

First off, read the meassage in the forum called 'How to use this forum - please read' for details on how to post code so forum users can read it properly.

Second;

I am using two 1w LoRa modules 433T30D from E-Byte on both ends working in normal "transparent" mode, and I know they are working fine, because if I open the serial monitor of Transceiver "A" I can see the RPM and Battery voltage data when I request data, the problems arrives when I try to display that "numerical" data into the corresponding line of the I2C display, the value shows as "ZERO" on both fields, RPM and Battery Voltage.

Perhaps turn the power down ?

LoRa at only 10mW is probably capable of covering your required distance and this power level is the legal limit for un-licensed use in a lot of places.

And ignoring the display, can you print the values you want to the Serial monitor correctly ?

Thank you for the reply an guidance, I'll read the "how to post code section".

Yes, I can turn the power down to that power, BUT the problem is that there are many obstacles in the way, so even 800mW will not make it work.

And yes forgetting about the display, the answer is "YES" you can see the RPM and Battery voltage data on the Serial Monitor, BUT NOT on the I2C display.

You can see on the I2C display the reply strings from tranceiver "B" like "Received Message" (on the code), but when it comes to numbers, they show as ZERO.

RPM: 0
Battery Voltage: 0.00V

Any thought?

                             ///LORA TRANSCEIVER "A"///

/////NOTE: BOTH LoRA TRANSCEIVERS SET TO TRANSPARENT MODE /////

#include <SoftwareSerial.h>
#include <Wire.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);    // I2C 4X20 DISPLAY

const int Request_Feedback_SW = 7;   // PIN #D7 OF NANO SET AS A TOGGLE SWITCH

boolean sw4g =true;                  // Request_Feedback gate


String Request_Feedback_ON = "FeedON";             
String Request_Feedback_OFF = "FeedOFF";
     
int R;
float V;

SoftwareSerial loraSerial(2, 3); //  LORA TX, RX TO AVOID INTERFERING WITH FTDI/USB COMM LINES



void setup() {  

pinMode (Request_Feedback_SW, INPUT_PULLUP);      
          

Serial.begin(9600);
loraSerial.begin(9600);

lcd.backlight();             
 
} 
  
 void loop() {      

                  //IF Request_Feedback is ON

 
if (sw4g){                       // Request_Feedback_ON gate    
if ( digitalRead(Request_Feedback_SW)==LOW){    
    
  Serial.print("Feedback Switch: ");         
  Serial.println("ON");
      
  loraSerial.print(Request_Feedback_ON);          
  Serial.println("Request Feedback ON");   
  

                           /// LCD "REQUEST DATA" ON///
  
  lcd.init();
  lcd.setCursor(0,0);
  lcd.print("SENT COMMAND:");
  lcd.setCursor(0,1);
  lcd.print("REQ.PARAMETERS ON");         
  
 sw4g = false; 
 
}
}
                                                                                         
                       //IF Request_Feedback is OFF//


if(!sw4g){                          //Same as " if(sw4g = false)"
if (digitalRead (Request_Feedback_SW) == HIGH){
  
  Serial.print("Feedback Switch: ");
  Serial.println("OFF");
  
  loraSerial.print(Request_Feedback_OFF);
  Serial.println("Request Feedback OFF");


                             /// LCD "REQUEST PARAMETERS" OFF ////////
  
  lcd.init();
  lcd.setCursor(0,0);
  lcd.print("SENT COMMAND:");
  lcd.setCursor(0,1);
  lcd.print("REQ.PARAMETERS OFF");
  
  sw4g = true;
} 
}
       
                             //////// REQUEST PARAMETERS "ON"//////////////
       
if(loraSerial.available() > 0){                   
      
    String input = loraSerial.readString();     
    Serial.println(input);   
  
  if (input == "feedbackON" ) { 
    
  R;
  V;
  lcd.init();
  lcd.setCursor(0,0);
  lcd.print("RECEIVED COMMAND:");
  lcd.setCursor(0,1);
  lcd.print("REQ. PARAMETERS ON");
  lcd.setCursor(0,2);               
  lcd.print("RPM:");               
  
  lcd.println(R);            
  lcd.setCursor(5,2);              
  lcd.print("  ");                  
  lcd.setCursor(0,3);               
  lcd.print("BATTERY VOLT:");       
  
  lcd.println(V);              
  lcd.setCursor(17,3);             
  lcd.print("V");                   
  lcd.setCursor(18,3);              
  lcd.print(" ");                   
  lcd.setCursor(19,3);              
  lcd.print(" ");                   
  
    }
        
                   //////// REQUEST PARAMETERS "OFF"/////////

 if (input == "feedbackOFF"){    
  lcd.init();
  lcd.setCursor(0,0);
  lcd.print("RECEIVED COMMAND:");
  lcd.setCursor(0,1);
  lcd.print("REQ.PARAMETERS OFF");
}    
}   
   

   delay(100);
}



***********************************************************************************



                         ///LORA TRANSCEIVER "B"///

/////NOTE: BOTH LoRA TRANSCEIVERS SET TO TRANSPARENT MODE /////


#include <SoftwareSerial.h>

const int RPM_Input =  8;  // PIN #D8 OF MINI-PRO SET AS RPM INPUT
const int BATT_VOLT =  A0; //PIN A0 OF MINI-PRO SET AS BATTERY VOLTAGE INPUT
const int M0 = 13;  // LORA M0 PIN SET TO LOW FOR TRANSPARENT DATA MODE
const int M1 = 12;  // LORA M1 PIN SET TO LOW FOR TRANSPARENT DATA MODE

               
int FEEDBACK_ST = LOW; 
int RPM_READ;
float V_BATT;
int R;
float V;
                                 
String FeedON;
String FeedOFF;

SoftwareSerial loraSerial(2, 3); // TX, RX LORA TX, RX TO AVOID INTERFERING WITH FTDI/USB COMM LINES

void setup() {
    
                         //Set M0 and M1 as OUTPUTS from Arduino///
  pinMode (M0, OUTPUT);
  pinMode (M1, OUTPUT);

                  //Set M0 and M1 to Mode TRANSPARENT MODE (NORMAL MODE)//
                  
  digitalWrite (M0, LOW);   // LORA RECEIVER SET TO NORMAL MODE(MODE 0)
  digitalWrite (M1, LOW);   //LORA RECEIVER SET TO NORMAL MODE(MODE 0)
  

  pinMode(RPM_Input, INPUT_PULLUP);
  pinMode (BATT_VOLT, INPUT);
  
  
  Serial.begin(9600);
  loraSerial.begin(9600); 



}



void loop() { 
  

  if(loraSerial.available() > 0){                          
    String input = loraSerial.readString();
    Serial.println(input); 
     

                                ///FEEDBACK TURNED ON FROM TRANSCEIVER "A"////
      
    if (input == "FeedON") {
      
      loraSerial.print("feedbackON");
      
      RPM_READ = pulseIn(RPM_Input, LOW);    ///READS ENGINE RPM    
      V_BATT = analogRead(BATT_VOLT);        ///READS BATTERY VOLTAGE
       
      R=RPM_READ;
      V=(V_BATT*0.00323);                    // BATTERY VOLTAGE MULTIPLYING FACTOR
      
      delay(500);
        
      Serial.print ("RPM: ");
      Serial.println(R);
      loraSerial.print("RPM: ");
      loraSerial.println(R); 
      Serial.print ("Battery Voltage: ");
      Serial.println(V);
      loraSerial.print("Battery Voltage: ");
      loraSerial.println(V);
      
      
    }
                             ///FEEDBACK TURNED OFF/////
      
    if (input == "FeedOFF") {
     
      loraSerial.print("feedbackOFF");
      
      
    }  
      
   }     
      
  delay(100);

}

Any thoughts?