hi i have a problem with characters on my lcd being left behind when the day of the week changes.
my lcd is a 20x4 and it is laid out like this:
06/05/2017 Monday
04:13:40AM
Humidity: 51.70%
Temperature: 78.08°F
so every week after Wednesday it will look like this
Thursdayy, Fridayayy and so on.
I don't know a lot of programing so any help is appreciated.
for the clock i am using this library GitHub - jarzebski/Arduino-DS3231: DS3231 Real-Time-Clock
#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3231.h>
#include "DHT.h"
#define DHTPIN 5 // what digital pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
const int chipSelect = 4;
DHT dht(DHTPIN, DHTTYPE);
DS3231 clock;
RTCDateTime dt;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
byte ozel[8] = {
B01000,
B10100,
B01000,
B00111,
B00100,
B00111,
B00100,
B00100,
};
void setup() {
dht.begin();
Wire.begin();
lcd.begin(20, 4);
lcd.backlight();
lcd.createChar(1, ozel);
clock.begin();
if (!SD.begin(chipSelect)) {
return;
}
}
void loop()
{
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
return;
}
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
dt = clock.getDateTime();
lcd.setCursor(0, 0);
lcd.print(clock.dateFormat("m/d/Y l", dt));
lcd.setCursor(0, 1);
lcd.print(clock.dateFormat("h:i:sA", dt));
lcd.setCursor(0, 2);
lcd.print(F("Humidity: "));
lcd.print(h);
lcd.print(F("%"));
lcd.setCursor(0, 3);
lcd.print(F("Temperature: "));
lcd.print(f);
lcd.write(1);
if (dataFile) {
dataFile.print(clock.dateFormat("m/d/Y l h:i:sA", dt));
dataFile.print(" ");
dataFile.print(F("Humidity: "));
dataFile.print(h);
dataFile.print(F("%"));
dataFile.print(" ");
dataFile.print(F("Temperature: "));
dataFile.print(f);
dataFile.print(F("°F"));
dataFile.println();
delay(15);
dataFile.close();
}
}