error printing to terminal

I am trying to test the time libraries in arduino by printing to the serial monitor. This is the code in my setup (attached below) and this is what is printing to the monitor (attached). Does anyone know what the problem could be?

Screen Shot 2017-10-13 at 5.27.49 PM.png

Screen Shot 2017-10-13 at 5.29.07 PM.png

One problem is that you didn't post your code.

here is all the code

testSolAlg.ino (58.8 KB)

I'm going to guess you're running out of stack.
What are you trying to run this on?

#include <Time.h>

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("test");
  time_t t = now();
  Serial.println("year: ");
  Serial.println(year(t));
  Serial.println("day: ");
  Serial.println(day(t));
  Serial.println("hour: ");
  Serial.println(hour(t));
  Serial.println("minute: ");
  Serial.println(minute(t));
}

void loop()
{
  // put your main code here, to run repeatedly:
}

Works fine for me. Later versions of the IDE may need TimeLib.h included

Do you have a memory problem and was that code intended to tun on an Arduino ?
Which Arduino board do you have ?

You may get better results if you actually set the time somewhere.

i think you are generating data faster than can be printed.

Your code runs for me with Serial.begin(115200), but with no delay it freezes.

void loop() 
{
  // put your main code here, to run repeatedly:
  delay(500);
  computeAng();  
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

does the arduino need to be connected to wifi in order for the time libraries to work?

ecorbae:
does the arduino need to be connected to wifi in order for the time libraries to work?

No

What are you trying to do ?

this is what I get at the terminal, using the time library from GitHub - PaulStoffregen/Time: Time library for Arduino

Did you set the date and time or did you expect the Time library magically to know what it is ?

Does the date and time change if you leave the program that you have not shared with us running ?

Have you tried any of the examples that come with the Time library ?

does time_t t=now() not do set the time?

ecorbae:
does time_t t=now() not do set the time?

It sets the variable t to the time returned by the Time library. How do you think the Time library knows the time if nothing has told it ?

If nothing has happened to set the time then the now() function returns the value that you have seen printed. Try printing it again a few seconds later. What do you see ?

Hi,
What version IDE are you using?

Have you looked in the IDE EXAMPLES section for examples that would have come with the library?

Thanks... Tom.. :slight_smile:

can you explain how you would set the time then? Also I'm using IDE 1.8.1. Thanks!

ecorbae:
can you explain how you would set the time then? Also I'm using IDE 1.8.1. Thanks!

setTime(hr,min,sec,day,month,yr);

See Arduino Playground - HomePage

I guess a better question to ask then is if there is a way using the time library to be able to access the current time and have this update automatically instead of inputting the time manually. I was originally doing this project on a pi and using a ctime library to update the hour minute year etc variables. is this possible for arduino? I attached how I was doing it for the pi if that helps at all.

Screen Shot 2017-10-21 at 3.57.27 PM.png

is if there is a way using the time library to be able to access the current time and have this update automatically instead of inputting the time manually

If you have a suitable application running on the PC and it can output the current time via a suitable interface, probably serial, then, yes, you can use this to set the current time on the Arduino.

Of course, once you turn off or reset the Arduino the time is lost. Beyond "Toytown" applications any that need accurate date/time information on the Arduino you are better off using an RTC interfaced to the Arduino.