433MHz receive ok for a while, then

I'm send temperature, as an integer, to my receiver and print it to an 8x2 LCD When I boot or reset it works fine for a minute or two then the characters on the LCD go crazy and it doesn't recover.

If I comment-out the following code and replace the temperatures with static integers the display is fine.

Why does the act of receiving integers via rf cause this? Does anyone see something wrong with this code?

Thank you,
Dave

[code]
   Set buffer to size of expected message and get received packet
   validate code 1010 and decode received packet and assign to T1 or T2
  bit 11 is the F/C bit, bit 10 is the T1/T2 bit
  if (rf_driver.recv((uint8_t *) &iTr, &buflen)){
    //delay(2000);
    if (bitRead(iTr, 15) == 1 && bitRead(iTr, 14) == 0 && 
    bitRead(iTr, 13) == 1 && bitRead(iTr, 12) == 0)
    {
      //read the T1/T2 bit and save T1 and T2
      if (bitRead(iTr, 10)==true){ 
        iT1 = iTr;
      }
      else {                 
        iT2 = iTr;
      }
      
      //read and F/C bit
      if (bitRead(iT1, 11)==true)FCr = Faren; //only need to check iT1. iT2 is same.
      else FCr = Celsi;  //clear = Celsius
      
      iT1 = iT1 & 0b0000001111111111; //clear unnecessary bits
      iT2 = iT2 & 0b0000001111111111;
    } 
  }

[/code]

Please post ALL the code, both sending and receiving.

No problem, Thanks.

[code]
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
#include <LiquidCrystal.h>
LiquidCrystal lcd1(12, 10, 5, 4, 3, 2);  //RS, EN, DB4, DB5, DB6, DB7
LiquidCrystal lcd2(12, 9, 5, 4, 3, 2);  
int col,row, alrm1, alrm2, Butt1, Butt2, Bklt;
unsigned int iTr=0, disptmr1, disptmr2, bklttmr1, bklttmr2;
unsigned int iT1, iT2;   //these hold received temperatures
String sT1,sT2;
bool FCr, T1o2; //FCr hold bit for F or C. T1o2 is the bit that indicates T1 or T2 received
int butrd1,butrd2 ;
const char AON = 42; // = * asterix
const char AOFF = 254; // = space
const char ARR = 126; // = right arrow
const bool Faren=true;
const bool Celsi=false;
bool bSwchg;
const int buzzer = 8; //buzzer to arduino pin 2
int uplim=400, lowlim=0, Ta;
const int BKLON=10000, RFSHDSP=2000;
//BKLON is time backlight is on. RFSHDSP is timer to refresh the display
RH_ASK rf_driver;
unsigned int T1lld=50, T1uld=200, T2lld=50, T2uld=200; //ranges upper/lower limit
String sT1lld, sT1uld, sT2lld, sT2uld;
bool FCsw = true;  //true = Farenheit
int btmr1, btmr2;   //button speed timers
int kdly = 200; //key delay.alarm buttons delay.



void setup() {
  // Initialize ASK Object
  if(!rf_driver.init())
  {
    Serial.println("Unable to initialize rf_driver.");
  }
  // Setup Serial Monitor
  Serial.begin(9600);
  
  //pinMode(buzzer, OUTPUT); // Set buzzer - pin 2 as an output
  lcd1.begin(8,2);
  lcd2.begin(8,2);
  disptmr1 = millis();  //start display timer
  btmr1=millis(); //button timer
  pinMode(6, INPUT_PULLUP);  //button for backlight
  pinMode(7, OUTPUT );  // output to backlight
  pinMode(13, OUTPUT );  // output to backlight
  digitalWrite(7, HIGH);  //turn on back lights
  digitalWrite(13, HIGH);
  disptmr1 = millis();  //timer for display
  uint8_t buflen = sizeof(int);  
}

void loop() { 
  disptmr2 = millis();  //timer for display

   Set buffer to size of expected message and get received packet
   validate code 1010 and decode received packet and assign to T1 or T2
  bit 11 is the F/C bit, bit 10 is the T1/T2 bit
  if (rf_driver.recv((uint8_t *) &iTr, &buflen)){
    //delay(2000);
    if (bitRead(iTr, 15) == 1 && bitRead(iTr, 14) == 0 && 
    bitRead(iTr, 13) == 1 && bitRead(iTr, 12) == 0)
    {
      //read the T1/T2 bit and save T1 and T2
      if (bitRead(iTr, 10)==true){ 
        iT1 = iTr;
      }
      else {                 
        iT2 = iTr;
      }
      
      //read and F/C bit
      if (bitRead(iT1, 11)==true)FCr = Faren; //only need to check iT1. iT2 is same.
      else FCr = Celsi;  //clear = celsius
      
      iT1 = iT1 & 0b0000001111111111; //clear unesesary bits
      iT2 = iT2 & 0b0000001111111111;
    } 
  }

  //is time to update display?
  if (disptmr2 - disptmr1 > RFSHDSP){
    //Serial.println(FCsw);   
    updatedisp(); 
    limitdsp();
    disptmr1 = millis();
  }
}

//***************************************************
void updatedisp(){
  //now print to lcd  
//  sT1 = String(iT1);
//  sT2 = String(iT2);
  iT1=120;
  iT2=263;
  
  lcd1.setCursor(0,0);  //col,row
  lcd1.print("T1:");
//  if (sT1.length() == 2)  sT1 = sT1 + " ";
//  if (sT1.length() == 1)  sT1 = sT1 + "  ";
  lcd1.print(iT1);
    
  lcd2.setCursor(0,0);  //col,row
  lcd2.print("T2:");
//  if (sT2.length() == 2)  sT2 = sT2 + " ";
//  if (sT2.length() == 1)  sT2 = sT2 + "  ";
  lcd2.print(iT2);

  if (FCsw ==Faren) {
    lcd1.setCursor(7,0);//col,row
    lcd1.write('F');
    lcd2.setCursor(7,0);
    lcd2.write('F');
  }
  else if (FCsw ==Celsi) {
    lcd1.setCursor(7,0);
    lcd1.write('C');
    lcd2.setCursor(7,0);
    lcd2.write('C');
  }
}
//*******************************************************************
void limitdsp(){  
  //FCsw = true = farenheit   FCsw = false = centigrade
  //F/C switch is F but limit display is C,convert C to F
  //now print to display
  lcd1.setCursor(0,1);
  lcd1.print("      ");
  lcd2.setCursor(0,1);
  lcd2.print("      ");

  lcd1.setCursor(0,1);
  lcd1.print(T1lld);
  lcd1.print(ARR);
  lcd1.print(T1uld);

  lcd2.setCursor(0,1);    //col,row
  lcd2.print(T2lld);
  lcd2.print(ARR);
  lcd2.print(T2uld);
}
[/code]

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.