Start work on fetching weather
This commit is contained in:
parent
4567adf91b
commit
5ffc1b8b0c
4 changed files with 25 additions and 0 deletions
12
Weather.cpp
Normal file
12
Weather.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "Weather.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "openWeatherMapApiKey.h"
|
||||
|
||||
Weather::Weather(char *lat, char *lon){
|
||||
sprintf(_url, WEATHER_URL, lat, lon, OPEN_WEATHER_MAP_API_KEY);
|
||||
}
|
||||
|
||||
void Weather::update(){
|
||||
|
||||
}
|
9
Weather.h
Normal file
9
Weather.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#define WEATHER_URL "https://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&appid=%s"
|
||||
|
||||
class Weather{
|
||||
char _url[100];
|
||||
|
||||
public:
|
||||
Weather(char *lat, char *lon);
|
||||
void update();
|
||||
};
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "sensors.h"
|
||||
#include "NaturalLight.h"
|
||||
#include "Weather.h"
|
||||
|
||||
#define HOSTNAME "Fishtank"
|
||||
#define MQTT_SERVER "192.168.1.3"
|
||||
|
@ -30,6 +31,7 @@ PubSubClient _mqttClient = PubSubClient(MQTT_SERVER, 1883, mqttCallback, _wifiCl
|
|||
|
||||
Sensors _sensors = Sensors(TEMPERATURE_PIN, TEMPERATURE_TOPIC, PH_TOPIC, _mqttClient);
|
||||
NaturalLight _naturalLight = NaturalLight(LATITUDE, LONGITUDE, TIMEZONE_OFFSET);
|
||||
Weather _weather = Weather(LATITUDE, LONGITUDE);
|
||||
|
||||
CRGB _leds[LED_COUNT];
|
||||
|
||||
|
@ -76,6 +78,7 @@ void setup() {
|
|||
configTime(0, 0, NTP_POOL);
|
||||
|
||||
_naturalLight.update();
|
||||
_weather.update();
|
||||
|
||||
FastLED.addLeds<WS2811, LIGHT_PIN, GRB>(_leds, LED_COUNT).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
|
||||
}
|
||||
|
|
1
openWeatherMapApiKey.h
Normal file
1
openWeatherMapApiKey.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define OPEN_WEATHER_MAP_API_KEY ""
|
Loading…
Add table
Add a link
Reference in a new issue