Weather Forecast

In my vision the final setup will be a water-proof box to put outside and let it go.
But to have a proper measure, accurate, I have to expose the microphone of the AR844.
Any sort of plastic bubble will affect the sound pressure waves and so I need to let the microphone of the AR844 to be completely exposed.

Now the proble is: how about rain? ... I need to somehow "close" the box.

I still don't have a mechanical solution on "how to close the box" but the issue is also "how to predict the weather" ?
Other sensors to be added to the BillOfMaterials? nah ... too expensive!

Lucky my the RaspberryPi unit has WiFi!!

Wget Weather Report

One of the many websites that do provide weather forecast for my area is

This website is fairly accurate and does provide a nice UI to the hourly based weather conditions for a specific area. Looking to the page sources I saw that they actually send ALL the data for the whole day, and then filter with some javascript to short the list.

That was exaclty what I was looking for.

If I can have a text table listing he wheather conditions hour by hour I can eventually trigger a GPIO and se the microphone to a safe (waterproof) position.

The Script

RasperryPi is a full feature linux machine. This is a very basic perl script I wrote, that does a wget on a fixed web address and then filter the data. I'm using the HTML::TableExtract extension so you might have to install that in cpan by doing:

   #> cpan
   #> install HTML::TableExtract

Running the script is trivial, you just have to launch it as

   #> ./ > weather-table.txt

The result will be a plain text file that does contain a csv table like this one:

03.00,pioggia debole,8.1
04.00,pioggia debole,8.1
05.00,pioggia debole,8
06.00,pioggia debole,8
07.00,pioggia debole,7.9


The first conlumn is the hour of the day (24H format), the second column is the forecast wheather, the third column is the predicted temperature.

Now leveraging cron I can run the script at midnight and check every hour if I have to stop the unit. In my case I will have to parse for the word "pioggia" (it means "rain") and take action.

Hey ... looks like today was really a rainy day ah? :-)

You can download the full script here: and here is the full script source code:


# This file is part of the BrainWorks RPi Environmental Monitor.
# Copyright(c) 2013 Gianluca Filippini
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see .

use strict;
use warnings;
use HTML::TableExtract;
use LWP::Simple;

my $file = 'meteo.html';

my $rc = `wget -q -O page.html`;

open (RESULT, '>', $file);
open (FILE, 'page.html');
while () {
  # chomp;
  $_ =~ s/ //g;
  $_ =~ s/°/ /g;
  $_ =~ s/à/ /g;
  print RESULT $_;
close (FILE);
close (RESULT);

my @headers = qw( Ora Tempo T );

my $te = HTML::TableExtract->new(
   headers => \@headers,
   attribs => { class => 'datatable' },


my ($table) = $te->tables;

for my $row ($table->rows ) {
  my $line=join(",", @$row);
      print $line."\n";