Help with troubleshooting error messages

Hello,
I am fairly new to programming and I would love some help troubleshooting/fixing the errors that are appearing on my code. I am programming a controller for a DIY greenhouse. This includes 2 sets of lights, a diffuser (for humidity), and a fan (for circulation).

Note - I am using an 8 channel relay to control the four items listed above. I am also using a DHT11 sensor to measure the humidity and turn on/off the diffuser to maintain humidity between 90% and 93%.

Code:

const unsigned long eventTime_humDelay = 5000; //5 sec delay
const unsigned long eventTime_lightOn = 16*60*60*1000UL; //16 hrs
const unsigned long eventTime_lightOff = 8*60*60*1000UL; //8 hrs
const unsigned long eventTime_fanOn = 15*60*1000UL; //15 mins
const unsigned long eventTime_fanOff = 30*60*1000UL; //30 mins
unsigned long previousTime_humDelay = 0;
unsigned long previousTime_lightOn = 0;
unsigned long previousTime_lightOff = 0;
unsigned long previousTime_fanOn = 0;
unsigned long previousTime_fanOff = 0;
#include <DHT.h>
int relayPosition = 0;
#define dht_apin A0
#define relay1 2 //light
#define relay2 3 //humidifier
#define relay3 4 //top light
#define relay4 5 //fan


void setup() {
digitalWrite(relay3,LOW);
digitalWrite(relay1,LOW);
}

void loop() {
  unsigned long currentTime = millis();
/*Humidifier Program*/  


  if ((relayPosition = 0) && (DHT.humidity < 90) && (currentTime - previousTime_humDelay>= previousTime_humDelay)) {
    digitalWrite(relay2,HIGH); //high means on. if the humidity is below 60, the relay will turn on.
    delay(250);
    digitalWrite(relay2,LOW);
    int relayPosition = 1
    previousTime_humDelay = currentTime;
      }
  else if ((relayPosition = 1) && (DHT.humidity > 93) && (currentTime - previousTime_humDelay>= previousTime_humDelay)){
    digitalWrite(relay2,HIGH);//low means off. if the humidity is above 70, the relay will turn off.
    delay(250);
    digitalWrite(relay2,LOW);
    delay(250);
    digitalWrite(relay2,HIGH);
    delay(250);
    digitalWrite(relay2,LOW);
    delay(250);
    digitalWrite(relay2,HIGH);
    delay(250);
    digitalWrite(relay2,LOW);  
    int relayPosition = 0
    previousTime_humDelay = currentTime;
  }
/*Lights Program*/
 if ((relay3 = HIGH) && (currentTime - previousTime_lightOn>= previousTime_lightOn )) {
  digitalWrite(relay3,LOW);
  digitalWrite(relay1,LOW);
 previousTime_lightOn = currentTime;
 }
  else if ((relay3=LOW) && (currentTime - previousTime_lightOff>= previousTime_lightOff )) {
  digitalWrite(relay3,HIGH;
  digitalWrite(relay1,HIGH);
  previousTime_lightOff = currentTime;
 }
/*Fan Program*/
 if ((relay4 = LOW) && (currentTime - previousTime_fanOn>= previousTime_fanOn )) {
 digitalWrite(relay4,HIGH);
 previousTime_fanOn = currentTime;
 }
 else if ((relay4=HIGH) && (currentTime - previousTime_fanOff>= previousTime_fanOff)) {
  digitalWrite(relay4,LOW);

}
}

error messages:

Arduino: 1.8.7 (Windows 10), Board: "Arduino Uno"

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino:2:46: warning: integer overflow in expression [-Woverflow]

 const unsigned long eventTime_lightOn = 16*60*60*1000UL; //16 hrs

                                         ~~~~~^~~

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino: In function 'void loop()':

Relay_Project:32:34: error: expected primary-expression before '.' token

   if ((relayPosition = 0) && (DHT.humidity < 90) && (currentTime - previousTime_humDelay>= previousTime_humDelay)) {

                                  ^

Relay_Project:37:5: error: expected ',' or ';' before 'previousTime_humDelay'

     previousTime_humDelay = currentTime;

     ^~~~~~~~~~~~~~~~~~~~~

Relay_Project:39:39: error: expected primary-expression before '.' token

   else if ((relayPosition = 1) && (DHT.humidity > 93) && (currentTime - previousTime_humDelay>= previousTime_humDelay)){

                                       ^

Relay_Project:52:5: error: expected ',' or ';' before 'previousTime_humDelay'

     previousTime_humDelay = currentTime;

     ^~~~~~~~~~~~~~~~~~~~~

In file included from sketch\Relay_Project.ino.cpp:1:0:

C:\Users\Eli\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment

 #define HIGH 0x1

              ^

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino:55:16: note: in expansion of macro 'HIGH'

  if ((relay3 = HIGH) && (currentTime - previousTime_lightOn>= previousTime_lightOn )) {

                ^~~~

C:\Users\Eli\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\cores\arduino/Arduino.h:41:14: error: lvalue required as left operand of assignment

 #define LOW  0x0

              ^

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino:60:20: note: in expansion of macro 'LOW'

   else if ((relay3=LOW) && (currentTime - previousTime_lightOff>= previousTime_lightOff )) {

                    ^~~

Relay_Project:61:27: error: expected ')' before ';' token

   digitalWrite(relay3,HIGH;

                           ^

In file included from sketch\Relay_Project.ino.cpp:1:0:

C:\Users\Eli\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\cores\arduino/Arduino.h:41:14: error: lvalue required as left operand of assignment

 #define LOW  0x0

              ^

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino:66:16: note: in expansion of macro 'LOW'

  if ((relay4 = LOW) && (currentTime - previousTime_fanOn>= previousTime_fanOn )) {

                ^~~

C:\Users\Eli\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\cores\arduino/Arduino.h:40:14: error: lvalue required as left operand of assignment

 #define HIGH 0x1

              ^

C:\Users\Eli\Documents\Arduino\Relay_Project\Relay_Project.ino:70:19: note: in expansion of macro 'HIGH'

  else if ((relay4=HIGH) && (currentTime - previousTime_fanOff>= previousTime_fanOff)) {

                   ^~~~

exit status 1
expected primary-expression before '.' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
    int relayPosition = 1

Missing semicolon

Which DHT library are you using ?
You do not appear to have created a DHT objct

In all your if statements, '=' means assign a value. You almost certainly want '==' which means compare two things.

And don't keep putting 'int' in front of a variable name e.g. int relayPosition. Each time you do that it creates another new variable with that same name, it doesn't assign a value to the previous version of relayPosition.

Steve

I am using the library from this website:
http://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/
I have fixed the errors that you all pointed out (thank you!!) and it is now compiling. Unfortunately, I believe that I burned out my board and have a new one coming in tomorrow. I have a feeling that there will be a few more problems that will arise, but we'll see!

Do you think that it is necessary to add the "UL" to the end of the const unsigned long?

Here is the updated version if anyone would like to look over it further for more errors:

const unsigned long eventTime_humDelay = 5000; //5 sec delay
const unsigned long eventTime_lightOn = 16*60*60*1000UL; //16 hrs
const unsigned long eventTime_lightOff = 8*60*60*1000UL; //8 hrs
const unsigned long eventTime_fanOn = 15*60*1000UL; //15 mins
const unsigned long eventTime_fanOff = 30*60*1000UL; //30 mins
unsigned long previousTime_humDelay = 0;
unsigned long previousTime_lightOn = 0;
unsigned long previousTime_lightOff = 0;
unsigned long previousTime_fanOn = 0;
unsigned long previousTime_fanOff = 0;
#include <dht.h>
int relayPosition = 0;
#define DHT11_PIN A0
#define relay1 2 //light
#define relay2 3 //humidifier
#define relay3 4 //top light
#define relay4 5 //fan
dht DHT;

void setup() {
digitalWrite(relay3,LOW);
digitalWrite(relay1,LOW);
}

void loop() {
  unsigned long currentTime = millis();
/*Humidifier Program*/  
  if ((relayPosition == 0) && (DHT.humidity <= 90) && (currentTime - previousTime_humDelay>= previousTime_humDelay)) {
    digitalWrite(relay2,HIGH); //high means on. if the humidity is below 60, the relay will turn on.
    delay(250);
    digitalWrite(relay2,LOW);
    relayPosition = 1;
    previousTime_humDelay = currentTime;
      }
  else if ((relayPosition == 1) && (DHT.humidity >= 93) && (currentTime - previousTime_humDelay>= previousTime_humDelay)){
    digitalWrite(relay2,HIGH);//low means off. if the humidity is above 70, the relay will turn off.
    delay(250);
    digitalWrite(relay2,LOW);
    delay(250);
    digitalWrite(relay2,HIGH);
    delay(250);
    digitalWrite(relay2,LOW);
    delay(250);
    digitalWrite(relay2,HIGH);
    delay(250);
    digitalWrite(relay2,LOW);  
    relayPosition = 0;
    previousTime_humDelay = currentTime;
  }
/*Lights Program*/
 if ((relay3 == HIGH) && (currentTime - previousTime_lightOn>= previousTime_lightOn )) {
  digitalWrite(relay3,LOW);
  digitalWrite(relay1,LOW);
 previousTime_lightOn = currentTime;
 }
  else if ((relay3==LOW) && (currentTime - previousTime_lightOff>= previousTime_lightOff )) {
  digitalWrite(relay3,HIGH);
  digitalWrite(relay1,HIGH);
  previousTime_lightOff = currentTime;
 }
/*Fan Program*/
 if ((relay4 == LOW) && (currentTime - previousTime_fanOn>= previousTime_fanOn )) {
 digitalWrite(relay4,HIGH);
 previousTime_fanOn = currentTime;
 }
 else if ((relay4==HIGH) && (currentTime - previousTime_fanOff>= previousTime_fanOff)) {
  digitalWrite(relay4,LOW);
}
}
//Or better yet, give the pins meaningful names. 
//#define lightRelay 2   --or maybe better, const byte lightRelay = 2;
//#define humidifierRelay 3
//#define topLightRelay 4 
//#define fanRelay 5 

void setup() {
//make the pin an output.  An array would be nice here.  
pinMode(relay1,OUTPUT); 
pinMode(relay2,OUTPUT);
pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);
pinMode(relay5,OUTPUT);
digitalWrite(relay3,LOW);
digitalWrite(relay1,LOW);
}

Might be why you think your board is burned out?

Don't know which relay board you have, but many use LOW to turn on, and HIGH to turn off.

ULRelay_Project.ino:2:46: warning: integer overflow in expression [-Woverflow]
 const unsigned long eventTime_lightOn = 16*60*60*1000UL; //16 hrs

The multiplies are done left to right and 166060 is too big for an int so you get an overflow. Put the UL on the leftmost value.

Relay_Project:32:34: error: expected primary-expression before '.' token

   if ((relayPosition = 0) && (DHT.humidity < 90) && (currentTime - previousTime_humDelay>= previousTime_humDelay)) {

                                  ^

As mentioned before, you don't have DHT defined. Look at the examples provided with your DHT library to see how it is done. If the library defines a "DHT" class you will have to call the object something else, like "dht", and change all the references in your sketch to the new spelling.

Relay_Project:37:5: error: expected ',' or ';' before 'previousTime_humDelay'

     previousTime_humDelay = currentTime;

     ^~~~~~~~~~~~~~~~~~~~~

Usually that means there is something missing on the previous line. Usually a ';'.

Arduino.h:40:14: error: lvalue required as left operand of assignment

  if ((relay3 = HIGH) && (currentTime - previousTime_lightOn>= previousTime_lightOn )) {

                ^~~~

You have defined 'relay3' as '5' and you can't assign 5 the value HIGH. Two mistakes here: If you want to read a pin, you have to use a function like "digitalRead(relay3)" and you can't assign that function a value so you probably meant to COMPARE "==" instead of ASSIGN "=".

Relay_Project:61:27: error: expected ')' before ';' token

   digitalWrite(relay3,HIGH;

                           ^

You clearly left out the ')' after HIGH. You should have been able to fix that one yourself. At least TRY to fix the errors before asking for help.