Memory Card & Date/Time

Sets the clock UTC offset, appends timestamped lines to a log file on the memory card, and prints the full datetime() object.

while(run()){

  setEnv('sys.utc_offset',-8); // Set UTC offset


  // minute hour weekDay monthDay month year valid epoch are all valid properties of the dateTime object
  // e.g. dateTime.year would return the current year

  // Log the unix epoch timestamp followed by the ch3 values
  //234323:    ch3: {"ripple":0.001314,"state":false,"max":0.002665,"min":0.001114,"inst":0.001841,"avg":0.001937}
  // string( is used to convert numbers to a string for logging.

  sd.append('log.txt',string(datetime().epoch) +  ":    ch3: " + string(23.454) + "\n");



  // Print the entire dateTime object to show all paramaters
  print(string(datetime()));
  // {"valid":true,"uptime":1437.058175,"epoch":1589247811,"year":2020,"month":5,"monthDay":12,"weekDay":2,"hour":1,"minute":43,"second":31}

  waitMS(10000); // wait 10 second before repeating

}