void setup() { //Check for current EEPROM data if(EEPROM.read(0) == 117) { EEPROM.get(1, preferences); } else { preferences = {-8, 1000, -1, -1, -1, -1, -1.0, -1.0, -1.0, "US"}; EEPROM.put(1, preferences); EEPROM.put(0, 117); } //Update settings according to EEPROM data if(preferences.DSTRule == "US") { DSTJumpHour = 2; } else if(preferences.DSTRule == "EU") { DSTJumpHour = 1 + preferences.timeZone; } else { DSTJumpHour = 0; } dataSyncFrequency = preferences.dataSyncFrequency; lightCycleLength = preferences.lightCycleLength; waterCycleLength = preferences.waterCycleLength; targetTemperature = preferences.targetTemperature; targetHumidity = preferences.targetHumidity; targetSoilMoisture = preferences.targetSoilMoisture; //Set the proper time zone according to DST status Time.zone(isDST(Time.day(), Time.month(), Time.weekday(), preferences.DSTRule) ? preferences.timeZone + 1 : preferences.timeZone); //Setup sensors tempHumidSensor.begin(); lightSensor.begin(); lightSensor.setGain(TSL2591_GAIN_MED); lightSensor.setTiming(TSL2591_INTEGRATIONTIME_100MS); pinMode(pumpPWMPin, OUTPUT); pinMode(pumpIn1Pin, OUTPUT); pinMode(pumpIn2Pin, OUTPUT); pinMode(growLEDPin, OUTPUT); pinMode(socketPin, OUTPUT); pinMode(fanPin, OUTPUT); //TEST ONLY lightCycleStartHour = Time.hour(); lightCycleStartMinute = Time.minute()+1; lightCycleLength = 1 * 60 * 1000; }
void temp_init() { htu = Adafruit_HTU21DF(); htu.begin(); }