Delay question (yes I read the millis post)

Basically I want to keep pins on the UNO in state for x milliseconds. In this case I want it to be about 10 minutes. It’s not a complicated piece of code, but the delay just won’t stop for the 600k ms (10 minutes) it should. I can read all the sensors ok, it’s changing on the difference of a rain sensor but it’s doing it within a couple seconds rather than waiting until the next time it should look for sensor state. What’s going on here? It changes on any sensor state change (using I2C). And is reporting back every couple seconds. If I add another zero it takes 20min+ if I set delayValue=610000; it takes about 15 seconds. The delay value makes a difference but not one I can wrap my head around.

*/

#include “Wire.h”

#include “SparkFunBME280.h”
BME280 mySensor; //Global sensor object
const int sensorMin = 0; // sensor minimum
const int sensorMax = 1024; // sensor maximum
int RELAY1 = A2;
int RELAY2 = A3;
int delayValue=600000;
long count=0;

void setup()

{
//For I2C, enable the following and disable the SPI section

mySensor.settings.commInterface = I2C_MODE;
mySensor.settings.I2CAddress = 0x76;

pinMode(RELAY1,OUTPUT);
pinMode(RELAY2,OUTPUT);
digitalWrite(RELAY1,HIGH);
digitalWrite(RELAY2,HIGH);
Serial.begin(9600);
while(!Serial);
Serial.println(“Reading basic values from BME280”);

Wire.begin();

if (mySensor.beginI2C() == false) //Begin communication over I2C
{
Serial.println(“The chip did not respond. Please check wiring.”);
while(1); //Freeze
}

}

void loop()
{
// put your main code here, to run repeatedly:

/*while(count<10){ // delay between reads
delay(delayValue);
count++;
Serial.print(“Count:”);
Serial.print(count);

}*/

//delay(delayValue);

delay(delayValue);

int sensorReading = analogRead(A0);
Serial.print("Humidity: ");
Serial.print(mySensor.readFloatHumidity(), 0);

Serial.print(" Pressure: ");
Serial.print(mySensor.readFloatPressure(), 0);

Serial.print(" Alt: ");
//Serial.print(mySensor.readFloatAltitudeMeters(), 1);
Serial.print(mySensor.readFloatAltitudeFeet(), 1);

Serial.print(" Temp: ");
//Serial.print(mySensor.readTempC(), 2);
Serial.print(mySensor.readTempF(), 2);

Serial.println();

// map the sensor range (four options):
// ex: ‘long int map(long int, long int, long int, long int, long int)’
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// range value:
Serial.println(range);

if(range!=0){
digitalWrite(RELAY1,LOW);
digitalWrite(RELAY2,LOW);
Serial.println(“RELAY1 OFF”);
Serial.println(“RELAY2 OFF”);
Serial.println(“WATER TOO LOW”);

}
else if (range==0 && mySensor.readFloatHumidity()>60 && mySensor.readTempF()>65){
digitalWrite(RELAY1,LOW);
digitalWrite(RELAY2,LOW);
Serial.println(“RELAY1 OFF”);
Serial.println(“RELAY2 OFF”);
Serial.println(“TEMP OK”);
Serial.println(“WATER OK”);
Serial.println(“HUMIDITY TOO HIGH”);

}
else if(range==0 && mySensor.readFloatHumidity()<60 && mySensor.readTempF()<65){
digitalWrite(RELAY1,LOW);
digitalWrite(RELAY2,LOW);
Serial.println(“RELAY1 OFF”);
Serial.println(“RELAY2 OFF”);
Serial.println(“TEMP TOO LOW”);
Serial.println(“WATER OK”);
Serial.println(“HUMIDITY OK”);

}
else{
digitalWrite(RELAY1,HIGH);
digitalWrite(RELAY2,HIGH);
Serial.println(“RELAY1 ON”);
Serial.println(“RELAY2 ON”);
Serial.println(“TEMP OK”);
Serial.println(“WATER OK”);
Serial.println(“HUMIDITY OK”);

}

}[/code]

Study up on the maximum value of an int on an Uno:
https://www.arduino.cc/reference/en/language/variables/data-types/int/

int delayValue=600000;

The int is 16bit, 600k is out of range. The delay has parameter type unsigned long (32bit).

AHHH thank you.