Recognized library include, compiler stops with not declared information

#define SSID "CHANGE_IT"

#define DEBUG true

#define LED_WLAN 13

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Time.h>

// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
SoftwareSerial esp8266(11, 12); // RX, TX

void setup() {
  lcd.begin(16, 2);
  lcd.print("TCP - CLOCK");

  if (!espConfig()) serialDebug();
  else digitalWrite(LED_WLAN, HIGH);

  lcd.setCursor(0, 1);
  lcd.print("WLAN CONNECTED");

  getTime("", "/utc/in+one+hours"); //Gets Time from Page and Sets it

void loop() {
  String shour, sminute, ssecond, sday, smonth;


  if (hour() <= 9) shour = "0" + String(hour()); else shour = String(hour()); // adjust for 0-9
  if (minute() <= 9) sminute = "0" + String(minute());  else sminute = String(minute());
  if (second() <= 9) ssecond = "0" + String(second());  else ssecond = String(second());

  if (day() <= 9) sday = "0" + String(day()); else sday = String(day()); // adjust for 0-9
  if (month() <= 9) smonth = "0" + String(month());  else smonth = String(month());

  String Time = " -- " + shour + ":" + sminute + ":" + ssecond + " --";
  String Date = "   " + sday + "-" + smonth + "-" + String(year()) + "   ";



  lcd.setCursor(0, 1);

Hi all,

I try to complie this code (there is some future code in the current .ino file).

The goal is, to use a Time.h library. This library looks like it is found by the IDE, because if I choose another name or similar, the compiler already stops at this include line (3rd include).

If the Time.h is correct, the compiler runs further and stops in the loop function at the first “if” line. The warning looks like the following:

exit status 1
'hour' was not declared in this scope

Does somebody knows, what the root cause of this error message could be?

Thank you very much!

If somebody needs more infomration, please ask. Hopefully my question is not too stupid, I’m a beginner in this kind of programming.

Which board are you compiling for ?

  if (!espConfig()) serialDebug();

This makes it look like it is an ESP8266 but that function does not exist

LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);

This looks like it cannot be an ESP8266

Change this line:

#include <Time.h>


#include <TimeLib.h>

After that, if you get a “No such file or directory” error when you compile the sketch, you need to install the Time library:

  • Sketch > Include Library > Manage Libraries
  • Wait for the download to finish.
  • In the “Filter your search…” box, type “time”.
  • Scroll down through the search results until you see “Time by Michael Margolis”. Click on it.
  • Click “Install”.
  • Wait for the installation to finish.
  • Click “Close”.

Thank you very much. After Installation (I allready tried this steps) AND changing from Time.h to TimeLib.h it works now.

Have a good start into New Year!

You're very welcome. I'm glad to hear it's working now. Happy New Year!