Having trouble keeping incoming data on the right row on LCD

Hi. I am having trouble with incoming data moving onto different rows on a 20x4 lcd. I am using a uno clone with a DHT22 and a voltage sensor, on the transmitter. I am using the NRF24l01. The transmitter is in my shed connected to a solar panel battery, which is the voltage I am reading. I am hopefully quite close to finishing this project. I have included the sketches and a screen shot of the receiver serial print. Please would someone point me in the right direction to fix this sketch. Thank You. John

Receiver

#include <nRF24L01.h>
#include <RF24.h>
#include <SPI.h>
#include <DHT.h>

DHT dht(3, DHT22);
RF24 radio(8, 10); //  CN and CSN  pins of nrf
const uint64_t pipeOut = 0xE8E8F0F0E1LL;

int analogInput = A1;
int value = 0;

float hum;
float temp;
float vin = 0.0;
float vout = 0.0;
float R1 = 30000.0; //  
float R2 = 7500.0; // 

void setup(){
  
   Serial.begin(9600);
   dht.begin();

   pinMode(analogInput, INPUT);
  radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
}

void loop(){
  
  hum = dht.readHumidity();
  temp = dht.readTemperature();
//  vin =  vin = 0.0;
  
  radio.write(&hum, sizeof(hum));
  radio.write(&temp, sizeof(temp));
  radio.write(&vin, sizeof(vin)); 
  
  { // read the value at analog input
   value = analogRead(analogInput);
   vout = (value * 4.9) / 1024.0; // see text
   vin = vout / (R2/(R1+R2)); }
 


  
 Serial.print("Humidity ");
 Serial.print(hum, 1);
 Serial.print(" :   Temperature ");
 Serial.println(temp, 1);
 Serial.print(" : Battery ");
 Serial.print(vin, 2);
 Serial.println("V ");
 delay(500);


}

Transmitter

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

LiquidCrystal_I2C lcd(0x27, 20, 4); //  0x27, 20, 4

const uint64_t pipeIn = 0xE8E8F0F0E1LL; //0xE8E8F0F0E1LL
RF24 radio(8, 10);

float hum; //Humidity Value with Decimal Point
float temp; // Temperature Value with Decimal Point
float vin = 0.0;
float vout = 0.0;
float R1 = 30000.0; //  
float R2 = 7500.0; // 

int analogInput = A1;
int value = 0;
int led = 5; //To see if atmega328 is working properley




void setup()
{
  lcd.begin();
   Serial.begin(9600);
   pinMode(analogInput, INPUT); 
   pinMode(led, OUTPUT);
   radio.begin();
  radio.setDataRate(RF24_250KBPS);
  radio.openReadingPipe(1, pipeIn);
  radio.startListening();
}
void recvData()
{
 if ( radio.available() ) {
 
    digitalWrite(led, HIGH);   // turn the LED on
    delay(200);               // wait for a second
    digitalWrite(led, LOW);    // turn the LED off
    delay(1000);           // wait for a second 
}
 else {
   digitalWrite(led, HIGH);
       
  }
}
void loop()  
{
  
  recvData();

     // read the value at analog input
   value = analogRead(analogInput);
   vout = (value * 4.90) / 1024.0; // see text
   vin = vout / (R2/(R1+R2)); 
     
  radio.read(&hum, sizeof(hum));
  radio.read(&temp, sizeof(temp));
  radio.read(&vin, sizeof(vin)); 
   
  Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.print("  Temperature: ");
  Serial.print(temp);//decimal point
  Serial.print("  Battery: ");
  Serial.println(vin, 2);

   
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Humidity    : ");
  lcd.print(hum);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print("Temperature : ");
  lcd.print(temp);
  lcd.print("C  "); 
  lcd.setCursor(0, 2);
  lcd.print("Battery     : ");
  lcd.print(vin);
  lcd.print("V");
  
   delay(2500);
}

ShedReceiver.ino (1.88 KB)

ShedTransmitter.ino (1.11 KB)

Please attache the code using code tags, the symbol up to the left in this window. Then it is readable for a lot more helpers, those that does not have any IDE or disk space for downloading.

I do not have a way to view .ino files on my device so have not seen your code. LCDs do not do line wrap. You need to keep count of how many characters that you print so that you can use setCursor to control where the text goes.

LCD character addressing.

Hi. I have just read that and I thought that was the problem. Could you possibly point me in the right direction to keep the data on the right row. Thank you.

Somewhere You probably print too many characters on that row.
Make lcd.print for only one row and comment out the other ones. See if that works. Eventually cut down the number of spaces and see if that helps. And so on, row by row.

Hi. I have // all on the LCD but the serial monitor is still showing the data being mixed up. Thanks

John2689:
Hi. I have // all on the LCD but the serial monitor is still showing the data being mixed up. Thanks

Ah, I see what you are asking about now. We all thought you meant that the data was correct, but that is was being displayed in the wrong position on the LCD. Your actual problem is that the data you are receiving is not being saved in the correct variables.

Op's picture:

I notice you have a delay of 500mS in the transmitter, and 2500mS in the receiver, try setting both to the same value, or have the sender delay longer than the receiver, otherwise you are either going to overflow a receive buffer (if the RF24 uses one, I'm not that familiar with the library) or get out of synchronization since data is being sent 5 times faster than you are receiving it. Best thing would be to send all the data as a single struct instead of three separate floats, because the receiver has no way of knowing which float number corresponds to which variable.

Hi. Thanks for that. I have adjusted the delay times and now it is perfect. Thanks again.

@david_2018
Well done! The more eyes the more likely someone sees the fault.