I’m working on a project using the forecast API to get the current day’s sunrise/sunset epoch. I’m running this program on a raspberry pi pico. The API call for the forecast returns more data than the pico’s memory can handle. Is there a way to limit the response for a specific day? If not, I would like to make a feature request to add an additional parameter to the call to only return 1 specific day, for example “day=0” returns only today’s forecast?
I am not sure what your project is and why you want to get the sunrise/sunset epoch using the Weatherflow forecast API. I have a project running on a raspberry pi taking sunrise and sunset photographs and what I use to calculate the times is ephem · PyPI
cheers Ian
If not ephem, which looks pretty cool, there are plenty of sunrise/sunset algorithms available that merely need latitude, longitude, and timezone info (UTC offset on the date in question). For more than a year I’ve been using some Javascript snagged from Github that’s seemed to line up well with the Weatherflow-provided times. It’s maybe 20 or 30 lines of code total (and of course relies on some basic trigonometric functions).
Or there are several free APIs out there that provide sunrise/sunset data for given latitude/longitude locations - e.g: https://sunrise-sunset.org/api
there are streaming json parsers that can help there too. I ran into the very same problem with a little arduino esp32. You wont be able to parse the entire json response into memory ever, but what you can do is if you know the structure, use a streaming json parser, and have it pull out the data you care about when you need it.
not sure that will run on micro pi.
other options…make a service on another pi to wrap these request to make them “smaller”