Skip to content

Commit

Permalink
Update Simple_Latitude_Longitude_Weather_Example.ino
Browse files Browse the repository at this point in the history
Updated 07/30/2024 to include Air Quality sample calls
  • Loading branch information
JHershey69 authored Jul 30, 2024
1 parent 3ba14be commit 6121c09
Showing 1 changed file with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/*
Open Weather One Call Library
v3.0.4
v3.3.1
Copyright 2020 - Jessica Hershey
www.github.com/JHershey69
Sample Simple Longitude Latitude Weather Call updated 7/30/2024 to show Air Quality calls example
One Call API key at www.openweathermap.org
Google Developer Key no longer required.
Expand All @@ -30,9 +32,9 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
//========= End TFT Library =============================


#define HOMESSID "PUT YOUR SSID HERE"
#define HOMEPW "PUT YOUR PASSWORD HERE"
#define ONECALLKEY "PUT YOUR OPEN WEATHER API KEY HERE"
#define HOMESSID "SSID HERE"
#define HOMEPW "PASSWORD HERE"
#define ONECALLKEY "OPENWEATHER ONE CALL API KEY HERE"

// Only needed if WiFiTri installed for Triangulation may have fee from Google
#define GOOGLEKEY "YOUR GOOGLE DEVELOPER API KEY""
Expand All @@ -41,8 +43,8 @@ TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
// OpenWeatherOneCall variables
//For Latitude and Longitude Location setting if used
float myLATITUDE = 30.421309; //<-----Some location on theGulf Coast of Florida
float myLONGITUDE = -87.216;
float myLATITUDE = 39.9537; //<-----Toms River, NJ
float myLONGITUDE = -74.1979;
//For City ID Location setting if used
int myCITYID = 4504476; //<-----Toms River, NJ USA
Expand All @@ -53,7 +55,7 @@ int myUNITS = IMPERIAL; //<-----METRIC, IMPERIAL, KELVIN (IMPERIAL is d
int myHISTORY = NULL; //<-----Only required for historical data up to 5 days
//See manual for excludes, only CURRENT Data allows 1,000,000 calls a month
int myEXCLUDES = EXCL_D+EXCL_H+EXCL_M+EXCL_A; //<-----0 Excludes is default
int myEXCLUDES = EXCL_A+EXCL_D+EXCL_H+EXCL_M; //<-----0 Excludes is default
//for debugging loop counting
Expand Down Expand Up @@ -115,7 +117,7 @@ void setup() {
// Choose one of the following options
// Here we use the Lat and Lon for Pensacola, Florida (Using the predefined values)
//OWOC.setLatLon(myLATITUDE, myLONGITUDE);
OWOC.setLatLon(myLATITUDE, myLONGITUDE);
// If we are using CITY ID
//OWOC.setLatLon(myCITYID);
Expand All @@ -141,26 +143,35 @@ void setup() {
printf("\nLocation: % s, % s % s\n", OWOC.location.CITY, OWOC.location.STATE, OWOC.location.COUNTRY);
//Verify all other values exist before using
if (myHISTORY) //Remember you can't get historical and current weather at the same time
if (myHISTORY) //Remember you can't get historical and current weather at the same time so we are checking here for NULL
{
if (OWOC.history)
{
printf("Mean Temp for % s : % .0f\n", OWOC.history[0].weekDayName, OWOC.history[0].temperature);
}
} else
} else //If History was NULL we go to Current Weather. Air Quality is returned with Current Weather (Historical Air Quality COMING SOON!)
{
if (OWOC.current)
if (OWOC.current) //Always check to see if data is in the struct for all variables before using them
{
printf("Current Temp : % .0f\n", OWOC.current->temperature);
printf("Current Humidity : % .0f\n", OWOC.current->humidity);
printf("Current Humidity : % .0f\n", OWOC.current->humidity);
}
if(OWOC.quality) //See Addendum for complete list of Air Quality Variables
{
printf("\nAir Quality\n");
printf("Carbon : % .2f\n", OWOC.quality->co);
printf("Nitrogen : % .2f\n", OWOC.quality->no);
printf("Ozone : % .2f\n", OWOC.quality->o3);
}
if (OWOC.forecast)
{
printf("\nForecast Temp Tomorrow : % .0f\n", OWOC.forecast[1].temperatureHigh);
}
if (OWOC.alert) {
if (OWOC.alert) //Only if ALERTS aren't excluded
{
printf("ALERT *** ALERT *** ALERT\n");
printf("Sender : % s\n", OWOC.alert->senderName);
printf("Event : % s\n", OWOC.alert->event);
Expand Down

0 comments on commit 6121c09

Please sign in to comment.