Help with RTC controlled LED/Valve

I’m trying to control a valve using an RTC so that it will open for one minute every 8 hours. I’m also making a visual countdown using 8 LEDs, so each hour one LED will go out until the valve opens, then all 8 come back on. There is a 9th LED that will turn on when the valve is open. Finally, there is a button that can manually open the valve without interrupting the countdown.

I’m new to arduino and self-taught, so I’ve kind of cobbled my sketch together from several different sources. With the code I have right now (below) the LEDs are all glowing except for the active LED*, which is on at full. If I add a delay to the sketch the non-active LEDs flash dimly at whatever the delay interval is. The button does seem to be working as intended except that if there is a delay in the sketch the button only lights up the LEDs at the delay interval (i.e. if the LEDs are flashing dimly every 1000ms, while the button is pushed they will flash at full but not stay on at full as is desired).

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include "RTClib.h"

const int ledPin = 13;        //This is the LED for when the valve is open
const int ledPin1 =  11;      // the number of the LED pin
const int ledPin2 =  10;
const int ledPin3 =  9;
const int ledPin4 =  8;
const int ledPin5 =  7;
const int ledPin6 =  6;
const int ledPin7 =  5;
const int ledPin8 =  4;
const int buttonPin = 3; //button is pulled HIGH
const int mosfetPin = 2; //Pin 2 is connected to GATE, 
  //Negative terminal of Solenoid is connected to DRAIN, Source is connected to battery

RTC_DS1307 rtc;

void setup () {
  Wire.begin();
  rtc.begin();
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(mosfetPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop () {
   tmElements_t tm;
    int buttonState;
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW) {         //if button is pushed
digitalWrite(mosfetPin, HIGH);  // turn mosfet on
digitalWrite(ledPin, HIGH);     // turn led on
}
 DateTime now = rtc.now();
 //We are going to water at 06:00, 14:00, and 22:00.  The LEDs will count down the 8 hours between each watering phase

if(now.hour() == 6 || 14 || 22 && now.minute() == 01) {
digitalWrite(mosfetPin, HIGH);  // WATER THE PLANTS!
digitalWrite(ledPin, HIGH);      //SHOW YOU ARE WATERING THE PLANTS!
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
 }

if(now.hour() == 6 || 14 || 22 && now.minute() > 01) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, HIGH);
digitalWrite(ledPin7, HIGH);
digitalWrite(ledPin8, HIGH);
}

   if (now.hour() == 7 || 15 || 23) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, HIGH);
digitalWrite(ledPin7, HIGH);
digitalWrite(ledPin8, LOW);
 }

if (now.hour() == 8 || 16 || 00) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, HIGH);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
 }

if (now.hour() == 9 || 17 || 1) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
 }

 if (now.hour() == 10 || 18 || 2) {
 digitalWrite(mosfetPin, LOW);
 digitalWrite(ledPin, LOW);
 digitalWrite(ledPin1, HIGH);
 digitalWrite(ledPin2, HIGH);
 digitalWrite(ledPin3, HIGH);
 digitalWrite(ledPin4, HIGH);
 digitalWrite(ledPin5, LOW);
 digitalWrite(ledPin6, LOW);
 digitalWrite(ledPin7, LOW);
 digitalWrite(ledPin8, LOW);
  }

if (now.hour() == 11 || 19 || 3) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
 }

if (now.hour() == 12 || 20 || 4) {
 digitalWrite(mosfetPin, LOW);
 digitalWrite(ledPin, LOW);
 digitalWrite(ledPin1, HIGH);
 digitalWrite(ledPin2, HIGH);
 digitalWrite(ledPin3, LOW);
 digitalWrite(ledPin4, LOW);
 digitalWrite(ledPin5, LOW);
 digitalWrite(ledPin6, LOW);
 digitalWrite(ledPin7, LOW);
 digitalWrite(ledPin8, LOW);
  }

 if (now.hour() == 13 || 21 || 5) {
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
  }
 }

Let me know if you have any thoughts on how to clean this up, or if there is a good way to make it so the LEDs are actually off. Thanks!

*EDIT: After looking at the arduino setup again, it looks like the code isn’t actually working. Only the final “if” statement is running, so whatever I set those pins to will display. The if statement does not seem to be working in relation to the time on the RTC.

if(now.hour() == 6 || 14 || 22 && now.minute() == 01) {

That reads OK in English, but it's not how it works in C. Here's what (I think) you meant:

if(now.hour() == 6 || now.hour() == 14 || now.hour() == 22 && now.minute() == 01) {

Other comments - I think you need to work on your variable names. Learn about arrays.

GypsumFantastic:

if(now.hour() == 6 || now.hour() == 14 || now.hour() == 22 && now.minute() == 01) {

I think you forgot two brackets

if ((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 01) {

or you could use

if (((now.hour() % 8) == 6) && now.minute() == 01) {

Whandall:
I think you forgot two brackets

Oops. How embarrassing. Thanks for picking that up.

Thank you! That darn difference between English and code… That seems to have solved most issues, but the if (now.minute) still doesn’t seem to be working. I’m using an LED in place of the mosfet for now, just for testing; as soon as the RTC rolls to hour=6, all 8 indicator LEDs turn on and the “mosfet” LED and the valve indicator LED glow. If I push the button the mosfet and valve indicator come up to full. What I want to happen is while the RTC reads 6:00, the valve opens and the valve indicator turns on. Then at 6:02, the valve closes, and the valve indicator turns off, and the 8 countdown LEDs turn on. Any thoughts? Here is my current sketch:

#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.h>
#include "RTClib.h"

const int ledPin9= 13;        //This is the LED for when the valve is open
const int ledPin1 =  11;      // the number of the LED pin
const int ledPin2 =  10;
const int ledPin3 =  9;
const int ledPin4 =  8;
const int ledPin5 =  7;
const int ledPin6 =  6;
const int ledPin7 =  5;
const int ledPin8 =  4;
const int buttonPin = 3; //button is pulled HIGH
const int mosfetPin = 2; //Pin 2 is connected to GATE, 
  //Negative terminal of Solenoid is connected to DRAIN, Source is connected to battery

RTC_DS1307 rtc;

void setup () {
  Wire.begin();
  rtc.begin();
  // set the digital pin as output:
  pinMode(ledPin9, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(mosfetPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop () {
   tmElements_t tm;
    int buttonState;
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW) {         //if button is pushed
    digitalWrite(mosfetPin, HIGH);  // turn mosfet on
    digitalWrite(ledPin9, HIGH);     // turn led on
  }
    DateTime now = rtc.now();
   //We are going to water at 06:00, 14:00, and 22:00.  The LEDs will count down the 8 hours between each watering phase

   if((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 0) {
    digitalWrite(mosfetPin, HIGH);  // WATER THE PLANTS!
    digitalWrite(ledPin9, HIGH);      //SHOW YOU ARE WATERING THE PLANTS!
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
   }

   if((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() > 2) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
   }


   if (now.hour() == 7 || now.hour() == 15 || now.hour() == 23) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, LOW);
  }
  
   if (now.hour() == 8 || now.hour() == 16 || now.hour() == 00) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
  }
   
   if (now.hour() == 9 || now.hour() == 17 || now.hour() == 1) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
   }
  
  if (now.hour() == 10 || now.hour() == 18 || now.hour() == 2) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
  }
  
   if (now.hour() == 11 || now.hour() == 19 || now.hour() == 3) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
  }
  
   if (now.hour() == 12 || now.hour() == 20 || now.hour() == 4) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
  }

   if (now.hour() == 13 || now.hour() == 21 || now.hour() == 5) {
    digitalWrite(mosfetPin, LOW);
    digitalWrite(ledPin9, LOW);
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
    digitalWrite(ledPin5, LOW);
    digitalWrite(ledPin6, LOW);
    digitalWrite(ledPin7, LOW);
    digitalWrite(ledPin8, LOW);
  }
}

In some of my free time today I’m planning on reading up on arrays and on functions to try to clean this up more, too…

Whandall:
I think you forgot two brackets

if ((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 01) {

or you could use

if (((now.hour() % 8) == 6) && now.minute() == 01) {

OP shouldn't be getting in the bad habit of using leading zeroes...

for how long is this true?

if((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 0) {

answer: one minute (three times a day).

Just typing as I go through your code.

First, have you heard of arrays?

Second, have you heard of arrays?

Third, have you heard of arrays?

:smiley: You get it once you do :wink: It will save you A LOT of typing :wink: I think it will shrink it by 100 lines or so.

And the "valve indicator led", is that ledPin9? If so, why call it ledPin9 and not the more logical valveLedPin?

And how do you know the time is 6:00? You never print it or something.

Sorry, I don't understand the comment about "for how long is this true?" Are you saying I need to put in a delay? I thought that referencing the hour and minutes would allow me to open and close the valve for a specified amount of time. (i.e. open the valve at 6:00, close the valve at 6:02).

I will certainly look at arrays! It seems like it could really help with some future, similar projects. I'm now away from the arduino and setup for the day, so I can't test anything else until tonight.

I'm not sure I understand the question about how I know it's 6:00-- the arduino is pulling that information from the RTC.

Still not sure why the LEDs are behaving differently in the "active" hours than the rest- what would cause them to glow instead of being on at full, and why would they all turn on at 6:00 when only the valve and the indicator should be on at 6:00

each time you go through loop() the time is being evaluated, and expressions like these are true for an entire minute:

if ((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 1)

so instead, look to evaluate the moment the minute changes. something like this:

void loop ()
{
  static byte lastMinute = 60;
  tmElements_t tm;
  int buttonState;
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW)
  {
    digitalWrite(mosfetPin, HIGH);  // turn mosfet on
    digitalWrite(ledPin9, HIGH);     // turn led on
  }
  DateTime now = rtc.now();
  //We are going to water at 06:00, 14:00, and 22:00.  The LEDs will count down the 8 hours between each watering phase
  byte currentMinute = now.minute();
  if (lastMinute != currentMinute)
  {
    if ((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() == 0) 
    {
      digitalWrite(mosfetPin, HIGH);  // WATER THE PLANTS!
      digitalWrite(ledPin9, HIGH);      //SHOW YOU ARE WATERING THE PLANTS!
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, LOW);
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin4, LOW);
      digitalWrite(ledPin5, LOW);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }
    if ((now.hour() == 6 || now.hour() == 14 || now.hour() == 22) && now.minute() > 2) 
    {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      digitalWrite(ledPin5, HIGH);
      digitalWrite(ledPin6, HIGH);
      digitalWrite(ledPin7, HIGH);
      digitalWrite(ledPin8, HIGH);
    }
    if (now.hour() == 7 || now.hour() == 15 || now.hour() == 23) 
    {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      digitalWrite(ledPin5, HIGH);
      digitalWrite(ledPin6, HIGH);
      digitalWrite(ledPin7, HIGH);
      digitalWrite(ledPin8, LOW);
    }
    if (now.hour() == 8 || now.hour() == 16 || now.hour() == 00) 
    {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      digitalWrite(ledPin5, HIGH);
      digitalWrite(ledPin6, HIGH);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }
    if (now.hour() == 9 || now.hour() == 17 || now.hour() == 1) 
    {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      digitalWrite(ledPin5, HIGH);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }

    if (now.hour() == 10 || now.hour() == 18 || now.hour() == 2) {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, HIGH);
      digitalWrite(ledPin5, LOW);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }

    if (now.hour() == 11 || now.hour() == 19 || now.hour() == 3) {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, HIGH);
      digitalWrite(ledPin4, LOW);
      digitalWrite(ledPin5, LOW);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }

    if (now.hour() == 12 || now.hour() == 20 || now.hour() == 4) 
    {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin4, LOW);
      digitalWrite(ledPin5, LOW);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }

    if (now.hour() == 13 || now.hour() == 21 || now.hour() == 5) {
      digitalWrite(mosfetPin, LOW);
      digitalWrite(ledPin9, LOW);
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, LOW);
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin4, LOW);
      digitalWrite(ledPin5, LOW);
      digitalWrite(ledPin6, LOW);
      digitalWrite(ledPin7, LOW);
      digitalWrite(ledPin8, LOW);
    }
    lastMinute = currentMinute;
  }
}

Ah, I think I see now- so this will put all of the if statements inside an if statement that will mean that they are only being evaluated once per minute, rather than constantly evaluating them?

jturnham:
I'm not sure I understand the question about how I know it's 6:00-- the arduino is pulling that information from the RTC.

Yeah, but how do YOU know what time the RTC has?

And please answer ALL the questions :wink:

@BulldogLowell, I get what you're telling but how will that change things? Setting a pin high a couple of million times doesn't change it...

What I don't get is what turns them off again. Might just be me missing the obvious... ::slight_smile:

jturnham:
Ah, I think I see now- so this will put all of the if statements inside an if statement that will mean that they are only being evaluated once per minute, rather than constantly evaluating them?

yes,

then, you need to evaluate for the state change back as well... could be a millis() timer (or a callback if you are so inclined to write one).

I set the RTC time with a separate sketch, and then verified it with the serial monitor. Once this sketch wasn't working properly I went back and double checked the time using the serial and that first sketch.

Also, as part of my troubleshooting, I set the time in the RTC to different times of the day. That's how I found that the LEDs were behaving as expected except for at 6:00, 14:00, and 20:00.

I'll also change the LEDpin9 to ValveLED- good point.

Thanks for the input, and please let me know if you have any more thoughts! I'll make sure to update again once I get home and can try some of these ideas out.

But that way you don't really know what the time is. Because you have to sort of guess it because it will just tick away after setting it. Why not print it as useful debug information in this sketch?

True! I'll add it in.