EasyManua.ls Logo

sparkfun ESP32 - Page 15

sparkfun ESP32
20 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
{
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
5
of 20

Related product manuals