I would like to lcd 16.2 shows more than just temperature and humidity.
I would add buttonswitch when pressed for the first time to show you the exact time RTC following pressure on the switch to display the timer settings ¨T1 on 18.15 off 6.00 & T2 on 18.15 off 6.15¨.
When I press the third time to return to the display of temperature and humidity.
let say button swich is connected to digital pin 1
#define buttonpin1
but now I do not know how to proceed please help and explain the code
this is working code for now
#include "DHT.h"
#include <LiquidCrystal.h>
#include <Wire.h>
#include "RTClib.h"
// these arrays store timer data
// on hour, on minute, off hour, off minute
int t1[4]= {
18,15,6,00};
int t2[4]= {
18,15,6,10};
#define DHTPIN 7 // what pin we're connected to
#define tempcontpin 8 // temp output to control
#define humcontpin 9 // humidity output to control
#define timer1pin 6 // timer1 output to control lights
#define timer2pin 10 //timer2 output to control light-hood fan
#define DHTTYPE DHT22 // DHT 22 (AM2302)
RTC_DS1307 RTC; // define the Real Time Clock object
int maxT=0, minT=100;
int maxH=0, minH=100;
LiquidCrystal lcd(12,11,5,4,3,2);
DHT dht(DHTPIN, DHTTYPE);
//here is where the temp and hum setpoints are changed
int tempset=24, tempreset=22;
int humset=60, humreset=55;
int tmem=0, hmem=0;
void setup() {
Serial.begin(9600);
// connect to RTC
Wire.begin();
RTC.begin();
if (!RTC.isrunning()) {
Serial.println("RTC is not running");
}
Serial.println("DHTxx test!");
dht.begin();
lcd.begin(16, 2); // Set the display to 16 columns and 2 rows
lcd.clear();
//setup LEDs or output
pinMode(tempcontpin, OUTPUT);
pinMode(humcontpin, OUTPUT);
pinMode(timer1pin, OUTPUT);
pinMode(timer2pin, OUTPUT);
}
void loop() {
// 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();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
lcd.setCursor(0,0);
lcd.print("T");
lcd.print(t);
lcd.write(B11011111); // print degree symbol
lcd.print("C ");
lcd.setCursor(0,1);
lcd.print("H");
lcd.print(h);
lcd.print("%");
if (t>maxT) {maxT=t;} //check for max temp
if (t<minT) {minT=t;} //check for min temp
lcd.setCursor(9,0);
lcd.print("Max");
lcd.print(maxT);
lcd.write(B11011111);
lcd.print("C");
if (h>maxH) {maxH=h;} //check for max hum
if (h<minH) {minH=h;} //check for min hum
lcd.setCursor(9,1);
lcd.print("Max");
lcd.print(maxH);
lcd.print("%");
}
DateTime now = RTC.now();
//Serial.print(now.unixtime()); // seconds since 1/1/1970
//Serial.print(", ");
Serial.print('"');
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
Serial.print('"');
Serial.println();
// check for timer1 on/off
{
if (now.hour()==t1[0] && now.minute()==t1[1])
{
digitalWrite (6, HIGH);
}
if (now.hour()==t1[2] && now.minute()==t1[3])
{
digitalWrite (6, LOW);
}
}
// check for timer2 on/off
{
if ((now.hour()==t2[0] && now.minute()==t2[1]))
{
digitalWrite (10, HIGH);
}
if (now.hour()==t2[2] && now.minute()==t2[3])
{
digitalWrite (10, LOW);
}
}
//Here is the section for control with hysterisis
if (tempreset<=t && t<=tempset && tmem==1) {
digitalWrite (8, HIGH);
}
if (t>=tempset) {
tmem=1,
digitalWrite (8, HIGH);
}
if (t<=tempreset) {
tmem==0,
digitalWrite (8,LOW);
}
if (humreset<=h && h<=humset && hmem==1) {
digitalWrite (9, HIGH);
}
if (h>humset) {
hmem==1,
digitalWrite (9, HIGH);
}
if (h<humreset) {
hmem==0;
digitalWrite (9, LOW);
}
}