static unsigned long outLoopTimer=0;
static unsigned long wundergroundUpdateTimer=0;
static unsigned long clockTimer=0;
static unsigned long tempMSClock=0;
//Createasecondsclockbasedonthemillis()count.Weus
ethis
//totrackrainfallbythesecond.We'vedonethisbecaus
ethemillis()
//countoverflowseventually,inawaythatmakestrackin
gtimestamps
//verydifficult.
tempMSClock+= millis() clockTimer;
clockTimer=
millis();
while (tempMSClock>= 1000)
{
secsClock++;
tempMSClock= 1000;
}
//Thisisaoncepersecondtimerthatcalculatesandprint
soffvarious
//valuesfromthesensorsattachedtothesystem.
if (millis() outLoopTimer>= 2000)
{
outLoopTimer= millis();
Serial.print("\nTimestamp:");
Serial.println(secsClock);
//Windspeedcalculation,inmph.timeSinceLastTickgetsu
pdatedbyan
//interruptwhenticksco
meinfromthewindspeedsenso
r.
if (timeSinceLastTick!= 0)windSpeed= 1000.0/timeSinceLa
stTick;
Serial.print("Windspeed:");
Serial.print(windSpeed*1.492);
Serial.println("mph");
//Updatetemperature.Thisalsoupdatescompensationvalu
esusedto
//calculateotherparameters.
Serial.print("Temperature:");
Serial.print(bme.readTempF(),2);
Serial.println("degreesF");
//Displayrelativehumidity.
Serial.print("%RH:");
Serial.print(bme.readFloatHumidity(),2);
Serial.println("%");
//Displaypressure.
S
erial.print("Pres:");
Serial.print(bme.readFloatPressure()* 0.0002953);
Serial.println("in");
//Calculatethewinddirectionanddisplayitasastrin
g.
Serial.print("Winddir:");
windDirCalc(analogRead(WIND_DIR_PIN));
Serial.print("");
Serial.println(windDir);
Page 1
of 20