     }
   }
 
-  // battery voltage is good, boot system
-  pinMode(D7, OUTPUT);
-  digitalWrite(D7, HIGH);
+  daytime = true;
+  if (solarVoltage < 1000)
+    daytime = false;
 
-  delay(500);
+  delay(100);
   uvIndex.begin();
   tempSensor.begin();
 }

  batteryVoltage = analogRead(A0);

  // early exit - battery voltage is too LOW
  if (batteryVoltage < 2180)
  {
    // if at night time wait 20 minutes before trying again
    if (solarVoltage < 2250)


void setup()
{
  pinMode(D4, INPUT_PULLUP);
  currentState = STATE_BOOT;

  // test if input at D4 is LOW, enter program mode if so
  // turn on LED, and start connection process
  if (digitalRead(D4) == LOW)
  {
    currentState = STATE_PROGRAM;
    pinMode(D7, OUTPUT);
    digitalWrite(D7, HIGH);
    Spark.connect();
    return;
  }

  // turn off main led to save power, also use our own LED colors for states
  RGB.control(true);
  RGB.color(0,0,0);

