I get an error in this code.
dht DHT;
#define DHT11_PIN 4 // use pin 2 on UNO to sample data from DHT module
const int relay1 = 2; //Digital pin that the Relay is connected
const int relay2 = 5; //Digital pin that the Relay is connected
const int OnHour1 = 10;
const int OnMin1 = 23;
const int OffHour1 = 10;
const int OffMin1 = 24;
void setup()
{
Serial.begin(9600);
Serial.println("DHT TEST PROGRAM ");
Serial.print("DHT LIBRARY VERSION: ");
Serial.println(DHT_LIB_VERSION);
Serial.println();
Serial.println("Humidity % \tTemperature (C) \tTime \tDate");
lcd.begin(20, 4); // defines it is a 20 character four line display
rtc.begin(); // Start the RTC library code
}
void loop()
{
// READ DATA
DateTime now = rtc.now();
int chk = DHT.read11(DHT11_PIN);
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print("\t");
Serial.print(DHT.temperature, 1);
Serial.print(",\t");
Serial.print("\t");
Serial.print("\t");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.println(now.year(), DEC);
lcd.setCursor(0, 0); // start postion of Humidity text on LCD
lcd.print(DHT.humidity, 0); // 0 creates whole number, 1 two decimal
lcd.print("% Humidity ");
lcd.setCursor(14, 0); // start postion of temperature text on LCD
lcd.print(DHT.temperature * 1.8 + 32, 0); //Farhenheit conversion
lcd.setCursor(17, 0);
//lcd.print(”F“);
//lcd.print(DHT.temperature, 0);
//lcd.print(" C");
lcd.setCursor(6, 1); // start postion of time text on LCD
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print('.');
lcd.print(now.second(), DEC);
lcd.setCursor(0, 2); // start postion of time text on LCD
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print('.');
lcd.print(now.second(), DEC);
// You can display in lcd by changing Serial to lcd I have only used time above not date
//lcd.print(now.year(), DEC);
//lcd.print('/');
//lcd.print(now.month(), DEC);
//lcd.print('/');
//lcd.print(now.day(), DEC);
//lcd.print(' ');
//lcd.print(now.hour(), DEC);
//lcd.print(':');
//lcd.print(now.minute(), DEC);
//lcd.print(':');
//lcd.print(now.second(), DEC);
//lcd.println();
delay(1000); // screen - sample & LCD refresh time 1 second although DHT say min 2 seconds but works ok.
if (now.hour == OnHour1 && now.minute == OnMin1) {
digitalWrite (relay1, LOW);
}
else if (now.hour == OffHour1 && now.minute == OffMin1) {
digitalWrite (relay1, HIGH);
}
//
// END OF FILE
The error message
C:\Users\Documents\Arduino\rtc-lcd-dht\rtc-lcd-dht.ino: In function 'void loop()':
rtc-lcd-dht:101: error: invalid use of member function (did you forget the '()' ?)
if (now.hour == OnHour1) && (now.minute == OnMin1) {
^
rtc-lcd-dht:101: error: expected identifier before '(' token
if (now.hour == OnHour1) && (now.minute == OnMin1) {
What is wrong??