NTC Time Library - UDP problem

Hello,

I want to write a library at the time from a Network Time Protocol (NTP) time servers get.

The first problem I have is the inizialieserung of the “EthernetUDP” object in my NTC_Time.h file.

#ifndef NTC_Time_h
#define NTC_Time_h

#include "Arduino.h"
#include <SPI.h>         
#include <Ethernet.h>
#include <EthernetUdp.h>

class NTC_Time{
  private:
    EthernetUDP Udp;

  public:
    NTC_Time(byte ipNTCServer[4], byte pTimeZone); //my constructor
};
#endif

If I leave the NTC_Time.cpp empty, I get no error.
If I write something in the NTC_Time.cpp I get the following error.

#include "NTC_Time.h"
#include "Arduino.h"

NTC_Time::NTC_Time(byte ipNTCServer[4], byte pTimeZone){   
}

In file included from NTC_Time.cpp:1:
NTC_Time.h:11: error: ‘EthernetUDP’ does not name a type

Do you have any idea what I could do to make it work?

The second problem is, I do not know how to pass IP addresses to a function / libraries.

Thanks!

PS: I am a newbie in things like libraries / classes.

Move these from the library code and include them in your sketch code.

#include <SPI.h>         
#include <Ethernet.h>
#include <EthernetUdp.h>

Have you gotten NTP to work ok in a sketch?

Thx it work :slight_smile:

Yes, I have this one:

If you are building a library, may I suggest adding this. http://arduino.cc/forum/index.php/topic,137789.msg1037288.html#msg1037288 It is a way to get the ip of a NTP server with dns from pool.ntp.org.

Thank you for the help.

Now I have everything. :)

I wish I did...