Problem using Time.h library

Hello,
I'm having problem using this library. Well, actually I cannot use it.
I downloaded it and put it inside /Arduino.app/path to includes/Time.

But... I'm not able to include it, as the compiler always gives me an error because it cannot find the library.i created the "Morse" test lib and works well, but no way to get this Time library working.

Any ideas? Is it still 1.0 compatible?

Thanks in advance :slight_smile:

I downloaded it and put it inside /Arduino.app/path to includes/Time.

On what OS? What is "path to includes"? What version of the IDE?

But... I'm not able to include it

Then, it isn't in the right place.

I'm using the last version of the IDE on Mac OSX 10.7.2

Here is the path to libraries:

/Applications/Arduino.app/Contents/Resources/Java/libraries

There are all the other libraries inside this directory... :cold_sweat:

I'm using the last version of the IDE

I'm 99+% sure that the Help + About Arduino panel does NOT say "last" on it.

There are all the other libraries inside this directory

I guess we'll just have to take your word for this, and that this means that you put the Time folder here, and that the Time folder contains Time.h and Time.cpp, among other things.

Therefore, we can only conclude that the Arduino IDE was designed to thwart just you. Too bad.

IDE version is 1.0

Here is ls of Time directory:

DateStrings.cpp	Readme.txt	Time.cpp	Time.h		keywords.txt

moreover, the ls of the libraries folder (parent folder):

EEPROM		GPS		SD		SoftwareSerial	Wire
Ethernet	LiquidCrystal	SPI		Stepper
Firmata		Morse		Servo		Time

OK. It looks like you (now) have the Time library installed correctly.

Did you stop and restart the IDE, after installing the library, before trying to import it?

Oh thanks!
Didn't know that! Perfectly working now :smiley: :smiley: :smiley:

Didn't know that!

It's not clear in the install instructions that it is necessary to restart the IDE. It is, though, because one of the things that the IDE does on startup is populate all the drop-down lists. The list of libraries to import is determined at startup, not when the list is requested. If you change the list of libraries after the IDE is started, it doesn't know that.

Thanks Paul,
very clear explanation even for my poor english :stuck_out_tongue:

Well, anyway is happening a strange thing:

#include <Time.h>

void setup()
{
  Serial.begin(9600);
  Serial.print(year());
  
}

void loop()
{
}

It appears that my computer is stuck at 1970 1st January , as this is the output of my code.
Hour, Minute, Day etc... functions always return '0'...

You need to set the time, somewhere. The Arduino doesn't have a clock. It only knows how long it has been running.

I took a look at the readme ad I saw that!

That could be a problem, because I need a time()-like function that returns exactly the seconds between the 1st J. 1970 and "now". And it has to be synced with the same time() output of any other device.

Any suggestion?

There is a Processing sketch that you can run, that the Arduino can communicate with to get the time on the PC, in seconds since 1/1/1970.

And it has to be synced with the same time() output of any other device.

Not even close to realistic, unless you get the time from that device.

Hello,
by PC you mean "Personal Computer"?

Anyway I'm thinking about getting current time from a site (actually I don't know where to get it at the moment) and save it in my device (in this case iPhone). Then I'm gonna make a request to my Arduino Ethernet Server, passing current time to it.
After that, the server will connect to the same site and will get current time too.

Those two "current" time will be luckily the same, or differs in one-two seconds. So they are actually the same time.

I only need that trick to make a sort of security check...

Sounds that reasonable? :slight_smile:

Anyway I'm thinking about getting current time from a site (actually I don't know where to get it at the moment) and save it in my device (in this case iPhone).

My iPhone know what time it is.

Then I'm gonna make a request to my Arduino Ethernet Server, passing current time to it.

If you have an Ethernet shield, there are plenty of ways of getting the time. This is the first time you've mentioned that fact.

After that, the server will connect to the same site and will get current time too.

What server? What site? Your iPhone?

I only need that trick to make a sort of security check...

Security based on time? Everybody knows what time it is. How will that provide security?

Well, let me try to explain what there is inside my messy mind :D:

I'm actually trying to open my gate by sending a "question" with my iPhone.

(question*) (check question)
iPhone request--------------->Arduino server--------------------->Allow/deny gate opening and send feedback message.

Now, the gate is not the garage's one, but only the gate to the garden, so every security systems are useless, but i'm interested in that.

Now, let me present you my "question pattern":

: UDIDlatitudelongitudesecrethash

Basically the server gets the UDID and position of the iPhone. If the UDID is authorized and the distance between iPhone and home is lesser than Radius, then we have a probably good request :stuck_out_tongue:

Now I need to create a variable secrethash, based on time(). Just to make possibles hacking more difficult.

Stupid idea? Hope nope...