hi guys please give me some help, I am forever trying to improve my grow room and I now have changed my sensor to a bme 280 and I am controlling my light fan and humdifer at the same timw, my code however does not want to work
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <DS3231.h>
LiquidCrystal_I2C lcd(0X27, 2, 1, 0, 4, 5, 6, 7); // 0x27 is the I2c bus for a unmodified back pack
int Light = 3;
const byte RelayPin = 5;
DS3231 rtc(SDA, SCL);
Time ti;
const int OnHour1[] = {6};
const int OnMin1 [] = {0};
const int OffHour1[] = {6};
const int OffMin1[] = {0};
const byte OnHour[] = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
const byte OnMin[] = {0, 1, 3, 5, 7, 9};
const byte OffHour[] = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
const byte OffMin[] = {2, 4, 6, 8, 10};
//humidity control points
#define SETPOINT 90.0
#define DEADBAND 2.0
//These just make code easier to read
#define HUMIDIFIER 9 //instead of using 9 for pin 9 we will name it HUMIDIFIER
#define FAN 4
#define ON false
//the relay is sort of backwards. a low/0/false output is actually on
#define OFF true //the relay is sort of backwards. a high/1/true output is actually on
Adafruit_BME280 bme;
//the setup routine only executes once, when the ardunio is powered on
void setup() {
bme.begin();
rtc.begin();
pinMode(Light, OUTPUT);
digitalWrite(Light, LOW);
pinMode(RelayPin, OUTPUT);
digitalWrite(RelayPin, LOW);
pinMode (FAN, OUTPUT);
pinMode(HUMIDIFIER, OUTPUT);
digitalWrite(HUMIDIFIER, OFF);
digitalWrite(FAN, OFF);
//activate LCD module
lcd.begin(16, 2); // for 16x2 LCD module
lcd.setBacklightPin(3, POSITIVE);
lcd.setBacklight(HIGH);
//Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("TEMP");
lcd.setCursor(8, 0);
lcd.print("FAN");
lcd.setCursor(0, 1);
lcd.print("RH");
lcd.setCursor(8, 1);
lcd.print("LAMP");
}
bool isInByteList(byte value, const byte *array, byte length)
{
for (byte i = 0; i < length; i++)
if (array[i] == value)
return true;
return false;
}
void loop() {
ti = rtc.getTime();
delay (1000);
if (isInByteList(ti.hour, OnHour, sizeof OnHour) && isInByteList(ti.min, OnMin, sizeof OnMin))
{
digitalWrite(RelayPin, LOW);
Serial.println("FAN ON");
lcd.setCursor(9, 0);
lcd.print("ON");
}
else if (isInByteList(ti.hour, OffHour, sizeof OffHour) && isInByteList(ti.min, OffMin, sizeof OffMin))
{
digitalWrite(RelayPin, HIGH);
lcd.setCursor(9, 0);
lcd.print("OFF");
}
if (ti.hour == OnHour1 && ti.min == OnMin1)
{
digitalWrite(Light, LOW);
lcd.setCursor(13, 1);
lcd.print("0n");
}
else if (ti.hour == OffHour && ti.min == OffMin)
{
digitalWrite(Light, HIGH);
Serial.print("LIGHT OFF");
lcd.setCursor(13, 1);
lcd.print("OFF");
}
//Read the temperature and humidity into floating point variables
float h = bme.readHumidity();
float t = bme.readTemperature();
//Move the cursor to the end of the word temp: and print the reading to 2 decimal places
lcd.setCursor(5, 0);
lcd.print(t, 2);
//Move the cursor to the end of the word Humidity: and print the reading to 2 decimal places
lcd.setCursor(4, 1);
lcd.print(h, 2);
//Now begin with the control logic
if (digitalRead(HUMIDIFIER) == ON)
{
//If the humidifier is on, check to see if the humidity is above set point
if (h > SETPOINT + DEADBAND)
//we've reached the upper limit, so kill the humidifier
digitalWrite(HUMIDIFIER, OFF);
digitalWrite(FAN, ON);
}
else
{
// If the humidifier is off, check to see if humidity is below setpoint
if (h < SETPOINT - DEADBAND)
// We've reached the lower limit, so kiick on the humidifier
digitalWrite(HUMIDIFIER, ON);
digitalWrite(FAN, OFF);
}}