Post topics, source code that relate to the Arduino Platform

User avatar
By sprinkfitter
#72884 I get this error when I try to compile a sketch for an esp8266 12e. This sketch complied with an Uno.
ISO C++ forbids comparison between pointer and integer [-fpermissive]

Code: Select allif ((now.hour() == OnHour1) && (now.minute() == OnMin1) && (now.day() == OnDay1) && (now.month() == OnMonth1)) {
    digitalWrite (relay1, LOW);
    lcd.setCursor(1, 2);
    lcd.print("ON");


This is the complete code
Code: Select allLiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address Ox3F (Check yours)
RTC_DS1307 rtc;    // Create a RealTimeClock object (I set the time in another sketch)
/*-----( Declare Variables )-----*/
dht DHT;
#define DHT11_PIN 4 // use pin 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 relay3 = 6; //Digital pin that the Relay is connected

const int OnMin1 = 46;
const int OnHour1[]= {17,18,19,20};//Array multi hour
const int OnDay1 = 16;
const int OnMonth1 = 12;
const int OnYear1 = 2017;
const int OffMin1 = 47;
const int OffHour1 = 17;
const int OffDay1 = 16;
const int OffMonth1 = 12;
const int OffYear1 = 2017;

const int OnMin2 = 42;
const int OnHour2 = 17;
const int OnDay2 = 16;
const int OnMonth2 = 12;
const int OnYear2 = 2017;
const int OffMin2 = 43;
const int OffHour2 = 17;
const int OffDay2 = 16;
const int OffMonth2 = 12;
const int OffYear2 = 2017;

const int OnMin3 = 17;
const int OnHour3 = 16;
const int OnDay3 = 16;
const int OnMonth3 = 17;
const int OnYear3 = 2017;
const int OffMin3 = 17;
const int OffHour3 = 16;
const int OffDay3 = 16;
const int OffMonth3 = 17;
const int OffYear3 = 2017;

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.setCursor(0, 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.print('.');
  lcd.print(now.year(), DEC);
  lcd.print('/');
  lcd.print(now.month(), DEC);
  lcd.print('/');
  lcd.print(now.day(), DEC);
  lcd.print(' ');
  lcd.setCursor(0, 3); // start postion of time text on LCD
  lcd.print("ZONE-1 " "ZONE-2 "  "ZONE-3");

  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) && (now.day() == OnDay1) && (now.month() == OnMonth1)) {
    digitalWrite (relay1, LOW);
    lcd.setCursor(1, 2);
    lcd.print("ON");

  }
  else if ((now.hour() == OffHour1) && (now.minute() == OffMin1) && (now.day() == OffDay1) && (now.month() == OffMonth1)) {
    digitalWrite (relay1, HIGH);
    lcd.setCursor(1, 2);
    lcd.print("OFF");

  }

  if ((now.hour() == OnHour2) && (now.minute() == OnMin2) && (now.day() == OnDay2) && (now.month() == OnMonth2)) {
    digitalWrite (relay2, LOW);
    lcd.setCursor(8, 2);
    lcd.print("ON");
  }
  else if ((now.hour() == OffHour2) && (now.minute() == OffMin2) && (now.day() == OffDay2) && (now.month() == OffMonth2)) {
    digitalWrite (relay2, HIGH);
    lcd.setCursor(8, 2);
    lcd.print("OFF");
  }

  if ((now.hour() == OnHour3) && (now.minute() == OnMin3) && (now.day() == OnDay3) && (now.month() == OnMonth3)) {
    digitalWrite (relay3, LOW);
    lcd.setCursor(15, 2);
    lcd.print("ON");
  }
  else if ((now.hour() == OffHour3) && (now.minute() == OffMin3) && (now.day() == OffDay3) && (now.month() == OffMonth3)) {
    digitalWrite (relay3, HIGH);
    lcd.setCursor(15, 2);
    lcd.print("OFF");
  }
}

//
// END OF FILE
User avatar
By allenck
#76241 In your code "now.hour() == OnHour1" OnHour1 is a pointer to an array. So, the statement would have to be something like "now.hour() == OnHour1[0]" to be valid.