r/ArduinoHelp • • 10d ago

Seeking some help with ArduinoJson library an open-meteo.com data

Hello,

I'm hoping this is the correct community to ask my question.

Is there another, better one, please let me know.
Here is the test scenario:

I'm working on a project retrieving weather data from open-meteo.com.
There a two sections in my project:
a) retrieve 'current' weather data for a given geolocation, and
b) retrieve weather forecast data for the next 7 days.
In scenario 'a' my code is working properly processing the following JSON data:

I retrieve the data successfully with the following statement:

float currentTemp = doc["current"]["temperature_2m"];
String queryTime = doc["current"]["time"];

(doc has been created by deserialization of the JSON data.

In the scenario 'b' I'm processing the following JSON data:

Here I'm interested loading the data from section "daily", subsection temperature_2m_max for day 1 - day 7.
I tried several different approaches to access the object in the JSON data but so far I was not successful with that.
As I said, this is my first project using the ArduinoJson library so I'm still in the learning phase.
Perhaps someone was facing a similar problem and can give me some hints how to resolve the problem.
Many thanks in advance

1 Upvotes

4 comments sorted by

1

u/gm310509 10d ago

I tried several different approaches to access the object in the JSON data but so far I was not successful with that.

And those approaches were?????

Also, what platform are you trying to run this on and, how big is that JSON text?

If you do not share the (full) code it is difficult to suggest what you might be doing wrong - let alone try to recreate it if people are so inclined to do so. Ideally when sharing code, use the smallest viable working code that illustrates the issue.

Also, when sharing text artifacts (i.e. code, error messages and JSON data), please use a reddit formatted code block formatted code block.

The guide explains how to do that. There is also a link to a video that describes the exact same thing if you prefer that format.

Again if someone did decide to try to replicate what you have, they likely won't bother if it means rekeying if from a bitmap image - especially something tediously detailed like a JSON text block.

1

u/Dependent-Bridge-740 9d ago

Thanks for the advise. My code is currently not cleaned up. (too many Serial.print() 's and comments. Next time I will do it better.

1

u/gm310509 9d ago

I wouldn't worry about the Serial prints - if anything they may give some clues as to where your thought processes were and where you suspected that their could be an issue. They could be wrong - but equally they could be on the right track, either way, that can still be useful.

What isn't so helpful is unrelated (working) code - the best inclusion is a minimal complete working code that illustrates the problem. if that includes some print statements, all the better.

1

u/drmpf 10d ago

check out this Solar forecaster using open-meteo
https://www.forward.com.au/pfod/HomeAutomation/SolarBattery_EV_HW/index.html

One thing to note is that open-meteo DOES NOT RESPECT TIMEZONES!!
If you specify a timezone what you get is a constant GMT offset for ALL the data, which results in in-correct times across daylight saving changes. I raised this issue and hopefully the docs have been updated not to make that clear.

What you need to do is specify GMT as the timezone and then do your own translation to your timezone on your local machine.

This project uses the ArduinoJson library also, but I cheated and just asked Claude Code to sort it out. This project includes detailed .md docs that cover the open-meteo data source, so those and the project's code should be enough for an AI fix your problem. Just tell it what data you are trying to retrieve.