BradCarlson
Posts: 3
Joined: Mon Nov 23, 2015 6:13 pm

Humidity from a weather web site

Tue Feb 23, 2016 11:33 pm

I would like to use the raspberry with C and get local humidity from a weather web site.
There are many weather web sites that give this information.
Can someone point me to examples of getting and reading web sites in C.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Humidity from a weather web site

Wed Feb 24, 2016 8:44 am

BradCarlson wrote:getting and reading web sites in C.
the curl library is a good starting point.
https://curl.haxx.se/libcurl/c/

its been a while but i think all you need to do is apt-get install libcurl3 and the compile against the library

a tip: rather than trying to parse html, look for a weather site that offers a data feed, say to a widget or app or something. it'll be much easier to parse.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Humidity from a weather web site

Wed Feb 24, 2016 10:17 am

fsr wrote:a tip: rather than trying to parse html, look for a weather site that offers a data feed, say to a widget or app or something. it'll be much easier to parse.
Yes. If you're running Raspbian, the optional taskbar weather widget might provide a more stable and reliable way of sourcing the relevant data.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

BradCarlson
Posts: 3
Joined: Mon Nov 23, 2015 6:13 pm

Re: Humidity from a weather web site

Wed Feb 24, 2016 4:40 pm

a tip: rather than trying to parse html, look for a weather site that offers a data feed, say to a widget or app or something. it'll be much easier to parse.
There are great weather sites by city and state in the USA at weather.gov that are xml sites.
Example: http://w1.weather.gov/xml/current_obs/KGEU.xml
I am a beginner at Raspbian. I do have experience in programing in C though.
I looked a libcurl and maybe able to use it with these sites.
Yes. If you're running Raspbian, the optional taskbar weather widget might provide a more stable and reliable way of sourcing the relevant data.
I am a beginner. Maybe I am slow, but I have not been able to find the optional taskbar weather widget. Can you help me a little more on where to find out how to install this optional widget and how to get info from it with a C program.

Thanks to fsr and GRT2Fan
Last edited by BradCarlson on Wed Feb 24, 2016 9:19 pm, edited 1 time in total.

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Humidity from a weather web site

Wed Feb 24, 2016 5:00 pm

I can only help with how to find the widget...

Right-click on the Raspbian desktop taskbar and select Add/Remove Panel Items, then click the Add button and select it from the list. To add your location to the weather widget, right-click on it in the taskbar and click on Weather Plugin Settings.

A pictorial representation of the current weather (sun, cloud, rain, etc) should now appear in the taskbar with the current temperature next to it. Left-clicking on this brings up an info panel that looks like this...
Raspbian Weather Widget.jpg
Raspbian Weather Widget.jpg (50.79 KiB) Viewed 1376 times
How you access the data itself is beyond me, but this seems like a nice lightweight way of grabbing the relevant data in Raspbian if someone can help you to extract it.
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Humidity from a weather web site

Thu Feb 25, 2016 12:34 am

BradCarlson wrote:how to get info from it with a C program.
look at the source code for the widget and see where it is getting its data from.
linux is open source. you can get the source code of any part of raspbian if you know the package it is in.

edit /etc/apt.d/sources.list and enable source downloads

Code: Select all

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
refresh the package database

Code: Select all

sudo apt-get update
then apt-get source <package name>, e.g.

Code: Select all

apt-get source plasma-widget-yawp

BradCarlson
Posts: 3
Joined: Mon Nov 23, 2015 6:13 pm

Re: Humidity from a weather web site

Wed Mar 02, 2016 4:26 pm

I found a site called Github.com. It indicates that it has the source for raspberrypi/lxpanel/weather.
I am using lxpanel as the desktop and choose it's weather app. It uses yahoo weather and seems fairly accurate. I am a beginner. Can anyone confirm that Github has the actual source for the lxpanel weather. Also how to you report problems you find with the application.

Return to “Beginners”