0 votes
asked in WeatherStationClassic by (120 points)
My weather station is working fine and I am using two .96" OLED displays with one display showing just date and time (without seconds & updated every minute) and the other display alternating through frames as in your original weather station design/project. I have space and want to display additional data on the date/time only display, such as city and state and observation_time, etc?

If I submit the conditions url in my web browser, I receive back the above fields and many other fields. I have looked over the code in  WundergrounClient.h and cpp but can't figure out how to add get functions or how to do it if it's more than adding functions...

Your project provides great (and complex) starter code and I am slowly trying to figure out how things work and am willing to share my add-on to your project in the future... Thanks

1 Answer

0 votes
answered by (8.9k points)

I admit my json stream parser based code is not that simple to understand. It is great with handling huge JSON files by only using little memory, but this comes at the price of complexity. If you want to add additional fields you have to copy the WundergroundClient.h and WundergroundClient.cpp into your project. Then add attributes for them in the WundergroundClient.h file. In the .cpp file in the WundergroundClient::key method add a new "if" block which looks out for the appearance of a specific key, then store the value in the member variable. As last point you'll have to add a getter method in both .h and .cpp file to access your new attribute.

BTW, the WundergroundClient files are the old style. You can see the new style in the WundergroundForecast, *Condition, etc classes. There you pass in a struct which contains the attributes. They will be filled by the parser.

I worte a longer blog post about how the streaming parser works: 

commented by (120 points)
Thanks so much for your reply and I figured it out and have added a city field that also has a parent key, after reading your reply and reviewing your code (your JSON parser blog wasn't clear enough for me!).

For other readers: I couldn't read the Sun rise and fall fields and realized that I had to do an Astronomy call (found the get function but it didn't return anything). To get it to work, I added the following call, right after the forecast one (works with the free license):


Thanks again, Jim

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.