void sensor_setup() { bool status; // BME280 pressure, humidity, temperature status = bme.begin(); if (!status) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); } // TSL2591 Lux sensor if (tsl.begin()) { Serial.println(F("Found a TSL2591 sensor")); /* Configure the sensor */ configureTLS2591(); } else { Serial.println(F("No sensor found ... check your wiring?")); while (1); } #ifdef pmsEnable pinMode(pmsEnable,OUTPUT); digitalWrite(pmsEnable,LOW); #endif // PMS5003 Particulate sensor pmsSerial.begin(9600); }
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; }