}
}
//Keeptrackofwhenthelasttickcameinonthewindsenso
r.
void windTick(void)
{
timeSinceLastTick= millis() lastTick;
lastTick= millis();
}
//Capturetimestampofwhentherainsensorgottripped.
void rainTick(void)
{
rainTickList[rainTickIndex++]= secsClock;
if (rainTickIndex== NO_RAIN_SAMPLES)rainTickIndex=0;
rainTicks++;
}
//Forthepurposesofthiscalculation,0degiswhenthewin
dvan
e
//
ispointedattheanemometer.Theangleincreasesinaclo
ckwise
//mannerfromthere.
void windDirCalc(int vin)
{
if (vin< 150)windDir="202.5";
else if (vin< 300)windDir= "180";
else if (vin< 400)windDir= "247.5";
else if (vin< 600)windDir= "225";
else if (vin< 900)windDir= "292.5";
else if (vin< 1100)windDir= "270";
else if (vin< 1500)windDir= "112.5";
else if (vin< 1700)windDir= "135";
else if (vin< 2250)windDir= "337.5";
else if (vin<
2350)windDir=
"315";
else if (vin< 2700)windDir= "67.5";
else if (vin< 3000)windDir= "90";
else if (vin< 3200)windDir= "22.5";
else if (vin< 3400)windDir= "45";
else if (vin< 4000)windDir= "0";
else windDir= "0";
}
Note: When connecting to a WiFi network and the Wunderground
server, make sure to modify the variables
ssid , password , ID , and
key .
Expected output
Here is a picture of what you should expect upon starting up your ESP32
and letting it connect to WiFi:
Page 18 of 20