Blog 09

From BitWizard WIKI
Revision as of 16:14, 18 September 2015 by Cartridge1987 (talk | contribs) (Created page with " == BETA! Missing other extra information you can get == == Temperature Station == First look at outside temperature: First you need to install: sudo apt-get install we...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

BETA! Missing other extra information you can get

Temperature Station

First look at outside temperature:

First you need to install:

sudo apt-get install weather-util

you can type:

weather 'your city/country' 

Sadly, it mostly will give a result that is saying that it is ambiguous. It will then give you the option to choose one of the results. Example:

weather rotterdam: 
Searching via name... 
Your search is ambiguous, returning 3 matches: 
   [ehrd] Rotterdam Airport Zestienhoven, Netherlands 
   [fips3609363935] Rotterdam town, NY 
   [fips3663924] Rotterdam CDP, NY 

If you choose the first one you have to type the code between the: [ ] So if I would choose the first one I should type:

weather ehrd

You can also type the full name of the place if you put it in quotation marks:

'Rotterdam town, NY'

That should also work.

The result with searching a station should look like this( some have extra information. ):
Searching via station... 
[caching result Rotterdam Airport Zestienhoven, Netherlands] 
Current conditions at Rotterdam Airport Zestienhoven, Netherlands (EHRD) 51-57N 004-27E -4M 
Last updated Sep 14, 2015 - 05:25 AM EDT / 2015.09.14 0925 UTC 
   Temperature: 62 F (17 C) 
   Relative Humidity: 82% 
   Wind: from the S (170 degrees) at 12 MPH (10 KT) (direction variable) 
   Sky conditions: overcast  

You can also find out which code to type by going to this website: 

On the site if you scroll down you can see the beginning code of every country. Look in which section your country is. Well you click on the beginning letters. Like for France:


There you can find the full 4 letter code which you than can type in the line. So if you want to know the weather in avord(France):


Than on the site you will get a list of all the place in France who can give the weather. If it is for yourself try to find a station as close in your environment.

Note: When I tested it out. I found out that some weather stations aren't supported any more. (and don't update any more )

As you maybe already figured out loading a temperature form a certain country can become a really long wait. Because it has to go trough a big list of stations until it finds the station you are searching for.

You can save your country as name in the system to make it faster. I will now take the temperature from: Domodedovo International Airport – Moscow



nano ~/.weatherrc

To go to the weather rc ( the title and description can both be random names the other lines shouldn't be changed. You can also remove the description of course, but takes makes it of course . )

description = Domodedovo International Airport - Moscow
metar =

After you saved and exit just type:

weather DIAMoscow 

And you will get to see the things you wanted to see in a split-second.

Now to get the Temperature visible on your Rb_ui_board. For this I installed lynx, because if I would read it like previous ways it will print it with ignoring the enter in the file.

apt-get install lynx 
lynx -dump

It will directly print the result:

Moscow / Domodedovo, Russia (UUDD) 55-24N 037-54E
Sep 18, 2015 - 09:00 AM EDT / 2015.09.18 1300 UTC
Wind: from the SSW (200 degrees) at 18 MPH (16 KT):0
Visibility: greater than 7 mile(s):0
Temperature: 78 F (26 C)
Dew Point: 50 F (10 C)
Relative Humidity: 36%
Pressure (altimeter): 29.97 in. Hg (1015 hPa)
ob: UUDD 181300Z 20008MPS CAVOK 26/10 Q1015 R88/010095 NOSIG
cycle: 13
| grep Temperature

With grep temperature added you want to get the line, where it is showing the temperature:

Temperature: 78 F (26 C)
|  sed -e 's/.*(//' -e 's/ C).*//'

This will remove everything for and after 26

The 2 commands in sed are: first command is:

-e 's/.*(//' 

This command make it happen that it will disappear everything before 26 The result with only this could would then also be:

26 C)

The second command:

-e 's/).*//'

Here is will obviously will make everything disappear after the C from 26 C so if I only would do this command it would be:

Temperature: 75 F (26 C

sed removes everything for or after .*

lynx -dump | grep Temperature | sed -e 's/.*(//' -e 's/).*//'

26 C

Now to make a script with it, so we can print it out on the display.

nano DIAMoscow

The script I made:


# What display to use:
DISPL="bw_tool -I -D /dev/i2c-1 -a 94" 

#clean the display
$DISPL -W 10:0:b

while true; do
        $DISPL -W 11:0:b
        $DISPL -t "Out Temp= "`lynx -dump | grep Temperature | sed -e 's/.*(//' -e 's/C.*//'` “'C”

        sleep 5

What I now only did is printing “Out Temp=” before it and “'C' after it. You can also replace “Out Temp” with “DIAMoscow=” of course or an other place you want to know the temperature from.

When you also have to remove a space you can just press the space bar button several times and after that put the letters, number etc. That you want.