Hi, I'm interfacing with a DHT22 sensor utilizing the U8G2 library. The setup also includes a DS3231 RTC module. The problem I'm facing is there is a undesired random pattern that gets drawn every two seconds into the program. Below is an animated gif of the display in action. Please take a look at the minutes section "08". There is a random number generator at the top right corner which also ceases when the random lines appear at the bottom of the display.

The setup is driven by the following code:
#include <Arduino.h>
#include <U8g2lib.h>
#include "RTClib.h"
#include "DHT.h"
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
RTC_DS3231 rtc;
#define DHTPIN 9 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
char daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
float LocalH; //Stores humidity value
float LocalT; //Stores temperature value
long randNumber;
void setup() {
u8g2.begin();
dht.begin();
Serial.begin(9600); // initialize serial communication only for debugging purpose
}
void loop(void) {
u8g2.firstPage();
do {
// DATE AND TEMPERATURE
DateTime now = rtc.now();
u8g2.setFont(u8g2_font_logisoso16_tr);
u8g2.setCursor(0, 16);
u8g2.print(now.day(), DEC); u8g2.print(" "); u8g2.print(daysOfTheWeek[now.dayOfTheWeek()]); u8g2.print(" ");
//u8g2.setCursor(58, 16);
u8g2.setFont(u8g2_font_logisoso16_tr);
u8g2.print(LocalT, 0); u8g2.print(" "); u8g2.setFont(u8g2_font_logisoso16_tr);
LocalH = dht.readHumidity() * 1; // Sensor compensation
LocalT = dht.readTemperature() * 0.955; // Sensor compensation
// TIME
u8g2.setFont(u8g2_font_logisoso42_tn);
u8g2.setCursor(0, 64);
byte hourNow;
if (now.hour() > 12 )
{
hourNow = now.hour() - 12;
}
else
{
hourNow = now.hour();
}
if (hourNow < 10) { // Zero padding if value less than 10 ie."09" instead of "9"
u8g2.print("0"); u8g2.print(hourNow, DEC);
}
else {
u8g2.print(hourNow, DEC);
}
u8g2.print(":");
if (now.minute() < 10) { // Zero padding if value less than 10 ie."09" instead of "9"
u8g2.print("0"); u8g2.print(now.minute(), DEC);
}
else {
u8g2.print(now.minute(), DEC);
}
randNumber = random(1, 10);
u8g2.setFont(u8g2_font_logisoso16_tr);
u8g2.setCursor(118, 16);
u8g2.print(randNumber);
} while ( u8g2.nextPage() );
}
Is there any way to get rid of the random lines at the bottom and also avoid the display to freeze as reflected by the random counter?
Thanks.