uninstalled all of Arduino ide including library folder, appdata and registry. should have been a clean install from the latest release.
I cut and pasted the code to a new sketch.
#include <RTClib.h>
#include <DateTime.h>
#include <Wiring.h>
#include <Arduino.h>
#include
#include <Dusk2Dawn.h>
//#include "DS3231.h"
const int RELAY_1_A = 2;
const int RELAY_1_B = 3;
int door_opened = 1;
int door_closed = 0;
int sunrise;
int sunset;
DateTime current_day;
DateTime current_time;
RTC_DS3231 rtc;
DateTime now = rtc.now();
//current_day = now.day();
void CloseDoor()
{
//Set one relay one and the other off
//this will extend the actuator
digitalWrite(RELAY_1_B, LOW);
digitalWrite(RELAY_1_A, HIGH);
door_closed = 1;
door_opened = 0;
delay(5000);
digitalWrite(RELAY_1_A, LOW);
}
void OpenDoor ()
{
//Set one relay off and the other on
//this will retract the actuator
digitalWrite(RELAY_1_A, LOW);
digitalWrite(RELAY_1_B, HIGH);
door_opened = 1;
door_closed = 0;
delay(5000);
digitalWrite(RELAY_1_B, LOW);
}
Dusk2Dawn rainstone(32.715, -117.1625, -8);
void setup()
{
// Start the I2C interface
//Wire.begin();
// Start the serial interface
Serial.begin(9600); //set up Serial library at 9600 bps
pinMode(RELAY_1_A, OUTPUT);
pinMode(RELAY_1_B, OUTPUT);
}
void loop()
{
DateTime now = rtc.now();
Serial.println("test");
if (now.day() != current_day) //if this is not the same day then initialize for tomorrow
{
sunrise = rainstone.sunrise(now.year(), now.month(), now.day(), true);
sunset = rainstone.sunset(now.year(), now.month(), now.day(), true);
Serial.println(sunrise);
Serial.println(sunset);
current_day = now.day();
door_opened = 0;
door_closed = 0;
}
else
{
Serial.println("open");
delay(1000);
Serial.println("close");
delay(1000);
int current_time = (now.hour() * 60) + now.minute();
if (current_time > (sunrise + 30))
if (door_opened == 0)
{
OpenDoor();
}
if (current_time > (sunset + 60))
if (door_closed == 0)
{
CloseDoor();
}
unsigned long seconds = 1000L;
unsigned long minutes = seconds * 60;
delay(minutes);
}
}