Hi all.
I have written the sketch below for my Weather Station, Which incorporates a DHT22, a BMP180, a LCD i2c 20,4, and a RTC.
My problem is this, the LCD screen flashes about every second, as thought it was resetting every second, but this command is not in my sketch, the readings are accurate, can anyone advise me of what i need to add to the sketch, to stop this annoying flashing?
I have scoured the Internet for solutions, to no avail.
Here is my Sketch
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
RTC_DS1307 RTC;
#define DHTPIN 4 // Pin which is connected to the DHT sensor.
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
Adafruit_BMP085 bmp;
#define DS1307_ADDRESS 0x68
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
byte zero = 0x00;
float hum; //Stores humidity value
float temp; //Stores temperature value
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
void setup()
{
lcd.init();
lcd.backlight();
lcd.begin(20,4);
Wire.begin();
RTC.begin();
}
void loop()
{
hum = dht.readHumidity();
temp= dht.readTemperature();
// Read Temperature from DHT22.
lcd.begin(20,4);
lcd.setCursor(3,1);
lcd.print("Temp. : ");
lcd.print(temp);
lcd.print("");
lcd.print((char)223);
lcd.print("C");
// Read Humidity from DHT22.
lcd.setCursor(4,2);
lcd.print("Hum. : ");
lcd.print(hum);
lcd.print(" %");
//read pressure from BMP180
lcd.setCursor(2,3);
lcd.print("Press. : ");
lcd.print(bmp.readPressure()/200);
lcd.print(" hPa");
DateTime now = RTC.now();
lcd.setCursor(0,0);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.setCursor(11, 0);
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(' ');
lcd.setCursor(9,0);
lcd.print(":");
}