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.