Errors in previously compiled code

Could someone please explain what changed recently to start giving me errors in code which I have previously compiled and uploaded to an Arduino Etherten? Was using Arduino 1.0.1 but after the errors I have tried 1.0.5.

The errors seem to relate to time, I did update libraries but these were EthernetUDP.h and a few others not time.h.

Sample of error message:
code:38: error: 'time_t' does not name a type
code.ino: In function 'void loop()':
code:83: error: 'now' was not declared in this scope
code:117: error: 'prevDisplay' was not declared in this scope
code.ino: In function 'int updatePVoutput()':
code:172: error: 'year' was not declared in this scope

Sample of relevant code:

 Xantrex GT Inverter Logger with integration
 v0.01d - 08.01.2013
   - inital development code
   - 0.01c added leading zero for month and day output
   - 0.01d removed leading zero for day
 This sketch will ultimately use DHCP to obtain an IP address,
 get the current time from an NTP server, poll a Xantrex GT inverter
 via serial port and log the relevant statistics to
 originally by Isaac Hauser (
 now by michael ward
#include <SPI.h>         
#include <Ethernet.h>
#include <Time.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

//int led = 13; for red LED on board

// set the MAC address for our controller below.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // must be unique on local network
IPAddress timeServer (203, 14, 0, 250); // changed to telstra to fault find no updates since 31.12.2012, was internode
const long timeZoneOffset = +36000L; // time offset in seconds
unsigned int ntpSyncTime = 3600; // how often to sync to NTP server in seconds

// NTP variables, don't modify
unsigned int localPort = 8888;
const int NTP_PACKET_SIZE= 48;
byte packetBuffer[NTP_PACKET_SIZE]; 
EthernetUDP Udp;
unsigned long ntpLastUpdate = 0;
time_t prevDisplay = 0;

// PVoutput variables, please set your API key and System ID
char serverName[] = "";
char apiKey[] = "2769fa08ce8a84eec1f15"; // insert your own apiKey here
char sid[] = "80"; // insert your own system ID here
unsigned long PVoutputLastUpdate = 0;
unsigned int PVoutputUpdateTime = 300; // how oftern to send updates to PVoutput in seconds

// initialise the Ethernet client library
EthernetClient client;

// initialise our software serial connection
#define rxPin 0
#define txPin 1
SoftwareSerial xantrexSerial(rxPin,txPin);
// set max number of times to try getting a useful value from the inverter
int MAXTRIES = 20;

void setup() {
  pinMode(txPin, OUTPUT);
  pinMode(rxPin, INPUT);
//  Serial.begin(9600);
//    pinMode(led, OUTPUT); for LED on board  
  // try to get and set the date and time
  int trys = 0;
  while(!getTimeAndDate() && trys < 10) {
  } if (trys < 10) {
    Serial.println("ntp server update success");
  } else {
    Serial.println("ntp server updated failed");

void loop() {
  // check if time needs to be synced to NTP server
  if(now()-ntpLastUpdate >= ntpSyncTime) {
    int trys = 0;
    while(!getTimeAndDate() && trys < 10){
    } if(trys < 10) {
      Serial.println("ntp server update success");
    } else {
      Serial.println("ntp server update failed");
  // check if it's time to update PVoutput
  if(now()-PVoutputLastUpdate >= PVoutputUpdateTime) {
    // if inverter is online, then do pvoutput update, else no update needed
    //if (1) {
    if (get_status() == 1) {
      PVoutputUpdateTime = 300; // if the inverter is online we go back to 300 seconds checks
      int trys = 0;
      while(!updatePVoutput() && trys < 10) {
      } if(trys < 10) {
        Serial.println("PVoutput update success");
      } else {
        Serial.println("PVoutput update failed");
    } else {
      Serial.println("Inverter offline, update not required getstatus = 0");
      PVoutputUpdateTime = 60; // if the inverter isn't online, we check again in 60 seconds
      PVoutputLastUpdate = now();

  // Display the time if it has changed by more than a minute.
  if(now()-60 >= prevDisplay) {
  //if(now() != prevDisplay) {
    prevDisplay = now();

// display welcome banner
void welcomeBanner() {
  Serial.println("Xantrex Logger - v0.1d");
  Serial.println("By Michael Ward");

// start ethernet communications
void startEthernet() {
  Serial.println("Connecting to network..."); 
  // Connect to network and obtain an IP address using DHCP
  if (Ethernet.begin(mac) == 0) {
    Serial.println("DHCP Failed, reset Arduino to try again");
    // no point in carrying on, so do nothing forevermore
  } else {
    Serial.println("Connected to network using DHCP");
    Serial.print("IP Address: ");
    Serial.print("Subnet Mask: ");
    Serial.print("Gateway Address: ");
    Serial.print("DNS Server Address: ");

// function for sending inverter info to
int updatePVoutput() {
  int flag = 0;
  if(client.connect(serverName, 80))
    client.print("GET /service/r2/addstatus.jsp?key=");
    // send date
    // client.print("0");
    // send time

Would you like a sample of the solution? Or, would you prefer to have all of it? We feel the same way about the errors and the code.

Full information is always helpful. However common errors are things like forgetting
to select the correct board, or having an out-of-date version of a library, or not having
a library installed in the right place.

A sample of the solution please, I hope I can then fix the remaining errors.

The correct board is selected, if things are working I try not to change anything. I don't remember changing libraries or anything Arduino related between error free compiling this code and error ridden compiling. I have checked the libraries are installed in (what I understand is) the right place.

A sample of the solution please, I hope I can then fix the remaining errors.

I don't remember changing libraries or anything Arduino related between error free compiling this code and error ridden compiling.

But earlier you said:

I did update libraries

Hi Mark T

I have previously compiled this code in 2 separate versions. It compiled and uploaded to the Arduino and ran fine.

When I came to compile the code on January 1 it threw errors. I do not remember changing anything between the last successful compilation in late September 2013 and the error ridden compilation on January 1 2014. Hence my O P question asking what changed recently and my confusion.

After receiving the errors I tried to research each error and tried to resolve them by:
updating arduino from 1.0.1 to 1.0.5
updating libraries
changing code to reference the updated libraries.

I have succeeded in reducing the number and the type of errors, therefore I believe I am moving forward.

Does anyone have some helpful input into my problem?

Post the code and the errors in entirety if you want someone to reproduce your problem(s).

If you keep changing the code you are working with there's a danger you introduce new issues, go back the original code (that once worked) and post that and provide details
of any libraries it uses.

Clearly something changed, and we can't guess what you did. Its a very dangerous thing
to update software without keeping the original version and testing for regression - for instance I have Arduino versions 0021, 0022, 1.0, 1.0.1, 1.0.5, 1.5.4 and 1.5.5 all installed
separately - if something stops working I can go back and see where it broke - and I can
also quickly test code with multiple versions.