0

Dark Sky & Arduino MQTT Subscription
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Dark Sky & Arduino MQTT Subscription

by 1cc386ea8e470a on Tue Aug 06, 2019 8:36 pm

Does anyone have any idea how to get the weather data from the DS integration? All I could find online is a python example of getting DS to work, not using Arduino. Doing the following doesn't work...

Adafruit_MQTT_Subscribe weather = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/integration/weather/xxxx/current");
...
mqtt.subscribe(&weather);
...
if (subscription == &weather) {
Serial.print(F("Got: "));
Serial.println((char *)weather.lastread);
}
I would assume it would dump the current published weather data to the serial console but it doesn't. This was a modified version of the MQTT winc_1500 example. Any help would be greatly appreciated. Many thanks!

1cc386ea8e470a
 
Posts: 17
Joined: Mon Jul 04, 2016 10:44 am

Re: Dark Sky & Arduino MQTT Subscription

by brubell on Wed Aug 07, 2019 6:47 pm

You'll want to subscribe to the following feed, replacing :username and :id with your Adafruit IO Username and Dark Sky Integration Location ID.
Code: Select all | TOGGLE FULL SIZE
/api/v2/:username/integrations/weather/:id


Using Adafruit Arduino MQTT, it'd look like the following:
Code: Select all | TOGGLE FULL SIZE
Adafruit_MQTT_Subscribe weather = Adafruit_MQTT_Subscribe(&mqtt, /api/v2/:username/integrations/weather/:id);

brubell
 
Posts: 537
Joined: Fri Jul 17, 2015 10:33 pm

Re: Dark Sky & Arduino MQTT Subscription

by 1cc386ea8e470a on Wed Aug 07, 2019 9:54 pm

Brubell,
Thanks for your help. A couple of questions...

In your string you have both a Subscribe and Publish. Shouldn't they both be Subscribe?

Also, according to the Dark Sky API for MQTT, it says to use integration, not integrations (singular not plural). Can you confirm? The randomizer word service uses the singular form of integration and DOES work. So, I would imagine the weather service would be singular as well???

Finally, the MQTT publish string doesn't list "/api/v2/" in in the line of code. Can you confirm that and I'm assuming I have to add a :type as well???

Thanks again!

1cc386ea8e470a
 
Posts: 17
Joined: Mon Jul 04, 2016 10:44 am

Re: Dark Sky & Arduino MQTT Subscription

by brubell on Thu Aug 08, 2019 9:29 am

Sorry, I was looking at the REST API for Dark Sky.


It should look like this:
Code: Select all | TOGGLE FULL SIZE
Adafruit_MQTT_Subscribe weather = Adafruit_MQTT_Subscribe(&mqtt, /:username/integration/weather/:id/:type);



Valid :types are:
current
forecast_minutes_5
forecast_minutes_30
forecast_hours_1
forecast_hours_2
forecast_hours_6
forecast_hours_24
forecast_days_1
forecast_days_2
forecast_days_5

brubell
 
Posts: 537
Joined: Fri Jul 17, 2015 10:33 pm

Re: Dark Sky & Arduino MQTT Subscription

by 1cc386ea8e470a on Thu Aug 08, 2019 8:03 pm

Thanks for the help! I'm sad to say, that it doesn't get any data with that subscription string you suggested. I substituted ":type" with different types and ":id" with my ID I got on the adafruit I/O site. Have you tried this by chance with an arduino? I'm wondering if its working at all???

Thanks

1cc386ea8e470a
 
Posts: 17
Joined: Mon Jul 04, 2016 10:44 am

Re: Dark Sky & Arduino MQTT Subscription

by brubell on Mon Aug 12, 2019 5:35 pm

1cc386ea8e470a wrote:Thanks for the help! I'm sad to say, that it doesn't get any data with that subscription string you suggested. I substituted ":type" with different types and ":id" with my ID I got on the adafruit I/O site. Have you tried this by chance with an arduino? I'm wondering if its working at all???

Thanks


It might be running out of space, that's a long topic string.

I'm going to add this into the Arduino library and try this out later this week.

brubell
 
Posts: 537
Joined: Fri Jul 17, 2015 10:33 pm

Re: Dark Sky & Arduino MQTT Subscription

by 1cc386ea8e470a on Tue Aug 13, 2019 8:20 am

Would you like me to put the MQTT library in debug mode and send you the console output?

Thanks!

1cc386ea8e470a
 
Posts: 17
Joined: Mon Jul 04, 2016 10:44 am

Re: Dark Sky & Arduino MQTT Subscription

by brubell on Tue Aug 13, 2019 10:24 am

1cc386ea8e470a wrote:Would you like me to put the MQTT library in debug mode and send you the console output?

Thanks!


That'd be awesome! Could you paste your output below in
Code: Select all | TOGGLE FULL SIZE
[code]code[/code]
tags?

brubell
 
Posts: 537
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.