Skip to content

Commit 8610095

Browse files
committed
Specify delay as uint16_t to avoid overflow
On 16-bit platforms like ATmega based Arduino boards a delay of 5*60*1000 = 300'000 is above the max allowed number of an integer. Arduino delay expects unsinged long and we have to explicitly cast bigger delay values to ensure no overflow occurs.
1 parent bbd90c1 commit 8610095

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

SCD4x_I2C_FRC_Forced_Recalibration_Example/SCD4x_I2C_FRC_Forced_Recalibration_Example.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void setup() {
6060

6161
// wait for 5 minutes to equilibrate sensor to ambient
6262
Serial.println("# Waiting 5 minutes for equilibration");
63-
delay(5 * 60 * 1000);
63+
delay((unsigned long)5 * 60 * 1000);
6464

6565
Serial.println("# CO2 values before calibration");
6666

0 commit comments

Comments
 (0)