Closed dreamy1 closed 1 year ago
It is because ArduinoJson has taken out some of the features in the latest version.
.as<char*>() no longer compiles.
Easiest fix is the following every time you see .as<char*>()
String Icon = current_weather["icon"];
WxConditions[0].Icon = Icon;
I am just getting this to work, I think the OpenWeather API has also changed
Thanks for your quick reply!
I just updated the Json library to an older version....works now :-)
The OpenWeather API still works too.
It is because ArduinoJson has taken out some of the features in the latest version.
.as<char*>() no longer compiles.
Easiest fix is the following every time you see .as<char*>() String Icon = current_weather["icon"]; WxConditions[0].Icon = Icon;
I am just getting this to work, I think the OpenWeather API has also changed
@HowardAtHome thanks for diving into this a bit. I'm not fully sure I understand what you mean.
I see things like:
WxConditions[0].Main0 = root["weather"][0]["main"].as<char*>(); Serial.println("Main: " + String(WxConditions[0].Main0));
Howeer, it's unclear to me what it should look like once it's fixed.
Could you maybe post a working code section so we can see?
Quick update: I was able to find https://arduinojson.org/v6/api/jsondocument/as/, where it looks like repacing
.as<char*>()
with
.as<const char*>()
should be the ticket. I did exactly this and, indeed, it compiles!
However, I am having trouble with the OpenWeather API. The console spits out:
WiFi connected at: 192.168.43.251
Thu Mar 23 2023 18:54:58
connection failed, error: connection failed, error: connection failed, error: connection failed, error: Received all weather data...
Thu Mar 23 2023 18:54:58
Awake for : 1.536-secs
Based on @dreamy1's comment about the API still working, it's possible this is due to some issue with parsing the returned API data.
@dreamy1 do you see a route to making the software could be made compatible with the latest ArduinoJSON, instead of downgrading it? (I know it's not your responsibility, but just kind of thinking out loud here.) It can cause a lot of headaches and stress to maintain old library versions, especially as people will inadvertently use them. Arduino, whether for better for worse, pushes the latest libraries onto users, so it's fair to assume that moving forward, if you were, if you were, people will have the old library.
I replaced in the meantime the json issue like mentioned above - for me it worked as before.
It seems that you have a problem with your connection, with verifying your api key or with getting the NTP time.
The question is: did your code work with the older json lib?
Maybe it is a general problem with the code - it seems that there was an "issue" with the original author.
Maybe you want to try his software as i have too: https://github.com/G6EJD/LilyGo-EPD-4-7-OWM-Weather-Display-1
The question is: did your code work with the older json lib?
I only just downloaded the code today and gave it a try, so I don't have a reference from the past.
It seems that you have a problem with your connection, with verifying your api key or with getting the NTP time.
I think you're right that the problem is the API key. Looking at https://openweathermap.org/api#current, it's unclear to me which product I would need to subscribe to. The couple I randomly clicked on require creating payment plans, and that's definitely not something I want to do just in order to play around with the LilyGo.
Do you have any guidance here?
From https://openweathermap.org/faq#error401
API calls return an error 401
You can get the error 401 in the following cases:
- ...
- Your API key is not activated yet. Within the next couple of hours, it will be activated and ready to use.
- ...
So maybe I need to wait a bit...
Yes, all you have to do is to register there. So you will automatically get the subscription / API key, it is visible in you account when you are signed in.
With this key you will get API data for:
And this two data arrays are used in the software.
Hello,
i installed all libs, but the compiler does an exit with al lot of errors:
`In file included from c:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:37, from c:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9, from C:\Users\Admin\Documents\Arduino\Libraries\LilyGo-EPD-4-7-OWM-Weather-Display-1-main\OWM_EPD47_epaper_v2.5\OWM_EPD47_epaper_v2.5.ino:12: c:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In instantiation of 'static T ArduinoJson6201_F1::Converter<T, Enable>::fromJson(ArduinoJson6201_F1::JsonVariantConst) [with T = char; Enable = void]': c:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRefBase.hpp:52:34: required from 'typename ArduinoJson6201_F1::enable_if<(! ArduinoJson6201_F1::ConverterNeedsWriteableRef::value), T>::type ArduinoJson6201_F1::VariantRefBase::as() const [with T = char ; TDerived = ArduinoJson6201_F1::MemberProxy<ArduinoJson6201_F1::ElementProxy<ArduinoJson6201_F1::MemberProxy<ArduinoJson6201_F1::JsonObject, const char> >, const char>; typename ArduinoJson6201_F1::enable_if<(! ArduinoJson6201_F1::ConverterNeedsWriteableRef::value), T>::type = char]'
C:\Users\Admin\Documents\Arduino\Libraries\LilyGo-EPD-4-7-OWM-Weather-Display-1-main\OWM_EPD47_epaper_v2.5\OWM_EPD47_epaper_v2.5.ino:194:72: required from here
c:\Users\Admin\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:24:20: error: no matching function for call to 'convertFromJson(ArduinoJson6201_F1::JsonVariantConst&, char&)'
convertFromJson(src, result); // Error here? See https://arduinojson.org/v6/unsupported-as/