Time and the "now()" function

Im trying to inject the current date into the serial output that my barograph is sending.
It outputs pascals, but I would like to build a filter to only log infrasound events of interest.
To make sense of the data I need to include an accurate time-stamp.

Using Time.h I have been able to inject milis() into the file but that does not solve the problem.
If I could get now() to work in my code that would be OK as once I got the data out of the morrass of Arduino I could mash it around to reveal a proper iso date time (yyyymmdd_hhmmss.ssssssss) or a Julian date (astronomical).

I am able to get year() to work (sort of) but it outputs 1970. So I must be missing a command to poll the PC and get the PC time and dump that into a varriable. That or GPS time would be fine.


time_t t=now()+1446316592;//amazingly this works but it is only a cosmetic fudge
Serial.print (t);
Serial.print(",");
//Serial.print(year());//this 'works' but outputs 1970 indicating that the time/date functions are not reading system time / date.
Serial.print(" ");
Serial.print (micros());//this is a great little way to do interval timing but its not what I need
// read the pressure. Parameter is 0, 1, 2, or 3 for oversampling, see Bosch BMP180 datasheet.
status = bmp180.startPressure(3);
if (status != 0) {
delay(status);
status = bmp180.getPressure(pressure,temp);
if (status != 0) {
// We will submit intergers rather than floats because
// sprintf doesn't support floats without using tricks.
// It is easy to divide by 10000 on the receivers side
// to get back floats.
pressure = 10000 * pressure;
sprintf(buf, ",%lu \n", (unsigned long)pressure);
Serial.write(buf);

REBOOT
BMP180 init success v1
t18455;1446316592, 13428,9108736
1446316592, 41748,9108224
1446316592, 70084,9108151
1446316592, 98420,9108443
1446316592, 126748,9108224
1446316592, 155120,9107053
1446316592, 183492,9106907
1446316592, 211868,9107382
1446316592, 240256,9106979
1446316592, 268632,9107162
1446316592, 297016,9107016
1446316592, 325388,9106650

If you don't call setTime and set the time, it will assume that you are starting out at unix time 0, Midnight Jan 1, 1970. There is no system time on the Arduino. If you want time to stick between power cycles then you need to add an RTC chip to your project.

sunwukong:
So I must be missing a command to poll the PC and get the PC time and dump that into a varriable. That or GPS time would be fine.

Again, there's no such command to tell the PC to give you the time unless you've written a program for the PC to receive some command from Ardunio and send it back the time.

Do you have a GPS attached to Arduino? You can get the time from that.

I am able to get year() to work (sort of) but it outputs 1970. So I must be missing a command to poll the PC and get the PC time and dump that into a varriable. That or GPS time would be fine.

A $1000 PC, a $100 GPS or a $2 RTC. Hmmm...