Countdown to error message oddity

I am trying to receive notification on the display if the WiFi received data is considered old. Currently for testing, I'm using 10 seconds as the timeout period.

The problem is that the error message ("NO SIGNAL") happens every timeout period - currently 10 seconds until the next transmission from the remote end resets the message. I tried using different logic schemes, but it still happens. Moving what I felt might make a difference around didn't help either.

If I moved any timing code higher into the radio code (lack of a better term), it never ran whenever I had the transmitting end powered down.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 11
#define CSN_PIN 12
RF24 radio(CE_PIN, CSN_PIN);
LiquidCrystal_I2C lcd(0x27, 20, 4);
float data[3];
const byte address[6] ="00001";
int noSignal = 10000;
long previousMillis = 0;

void setup() {  
  radio.begin();
    radio.setPALevel(RF24_PA_MIN);
    radio.setDataRate(RF24_250KBPS);
    radio.openReadingPipe(1, address);
    radio.startListening();  
 lcd.init();
 for(int i=0; i<3;i++)
  {
    lcd.backlight();
    delay(45);
    lcd.noBacklight();
    delay(80);
  }
    lcd.backlight();
    lcd.clear();
}

void loop(){ 
  static int fiveDigit = 0;
  if (radio.available())
    {
float tempIn = data[0];
float tempOut = data[1];
float fiveDigit = data[2]; // used in detecting LOS from switchgear house
 radio.read(data, sizeof(data));  
  lcd.setCursor(0,0);
  lcd.print("Well Encl: ");
  lcd.print(tempIn, 1);
  lcd.print(" F ");
  lcd.setCursor(0, 1);
  lcd.print("Outside:   ");
  lcd.print(tempOut, 1);
  lcd.print(" F ");
  lcd.setCursor(0,3);
  lcd.print(fiveDigit, 0); 
  lcd.setCursor(0, 2);
  lcd.print("    Good Signal  "); 
    }  
  unsigned long millisNow = millis(); 
    if (millisNow - previousMillis  > noSignal && fiveDigit != 12345) 
      {      
   lcd.setCursor(0, 2);
   lcd.print("    NO SIGNAL    "); 
    previousMillis = millisNow;   
      } 
}

Just so you know, some of the code will change....the backlight flashing is simply to get my attention while sending changes to the Arduino. I'm not planning on showing the "12345" on the display either once things are running. Eventually this project will grow, but this has me stymied.

Thanks in advance hoping I described what's happening properly.

I think I see. I was trying to set fiveDigit to something besides 12345 so if it fails to read for a certain length of time it will give the error message, otherwise a good radio read will give what it is looking for (12345).

I forgot to say that the data is being transmitted every 2 seconds.

EDIT to say I remember the tutorials talking about the blocks and integers, etc, going away outside that block as you mentioned - I didn't think much about that until you mentioned it. If I move it to the same block as the radio code, nothing changes upon comm loss.

I appreciate your help...

You can see the comments where things were originally (I believe). I have made no changes outside this snippet of code.

void loop(){ 
  float tempIn = data[0];
  float tempOut = data[1];
  float fiveDigit = data[2];
  //static int fiveDigit = 0;
  if (radio.available())
    {
radio.read(data, sizeof(data));
  //float tempIn = data[0];
  //float tempOut = data[1];
  //float fiveDigit = data[2]; // used in detecting LOS
  lcd.setCursor(0,0);
  lcd.print("Well Encl: ");
  lcd.print(tempIn, 1);
  lcd.print(" F ");
  lcd.setCursor(0, 1);
  lcd.print("Outside:   ");
  lcd.print(tempOut, 1);
  lcd.print(" F ");
  lcd.setCursor(0,3);
  lcd.print(fiveDigit, 0); 
  lcd.setCursor(0, 2);
  lcd.print("    Good Signal  "); 
      
  unsigned long millisNow = millis(); 
    if (fiveDigit != 12345 && millisNow - previousMillis > noSignal)
      {      
   lcd.setCursor(0, 2);
   lcd.print("    NO SIGNAL    "); 
       previousMillis = millisNow; 
      } 
    }
}

Like this, the temperatures change as usual, but the 'NO SIGNAL' message doesn't show up after the noSignal timeout (or any time afterwards).

As far as I know, unless I give noSignal a value other than '12345' the sketch has no way to recognize it hasn't received a signal for a while. I plan to increase the timeout once things are finished.

That did it, thanks.

long previousMillis = 0;

timing variables should be declared as unsigned long