Weather Report.

Hi

I am a college student in the British education system. The goverment have recently started a new inititive called the "Extended Project". This encourages people to go further in the area of study ...etc

Imediately i thought of the arduino kit i had recently purchased, great. Now, i have some experiance with programming it (i study computing), but what i want to do is well outside my comfort zone.

I intend to create a piece of hardware for the computer that reports the weater. There are several component of this project.

I am fine with the electronics. Thats the easy bit.

I am working on a way of getting the weather report for the day into a file that my software can read.

What i really need help on though is how to output this information to the arduino. I have read around a bit and understand that i need to use serial over USB. However, how do i impliment this in Mac OSX?

Any comments, criticism or help greatly apreciated. Thanks.

Dups

Three words: Design, design, design.

Some questions you need to be asking yourself are:

  • What data about weather are you planning on measuring?
  • What are you intending to do with this data you collect and encode?
  • How are you intending to deploy the entire package of hardware and software?

This is just a start. Define your problem space, and this will drive your design.

You can certainly using the Arduino to collect data from various sensors. The key is, how will you do this, and what will you do with the data.

If you just wanted to make a datalogger by pushing the data over a wire to a computer, then you can use your Mac, the onboard USB and some serial programming for that. At the simplest, you will have a persistent serial connection that the computer uses to suck data from. Then you can store and manipulate this data how you like.

If you want to deploy the Arduino in a remote location then your design will change a lot.

Implementing a basic serial connection that you can use to send information back and forth over the USB serial link is covered in the Playground on arduino.cc. Likewise, the Arduino docs cover the various serial programming options you have for this. There are also some third-party serial libraries that may give you more advance capabilities.

I interpreted the original proposal as downloading a weather forecast from a website and showing it on (for instance) an LCD attached to the Arduino.

Who's closest? :slight_smile:

Andrew

Ah, upon review, I suspect you might be closer. Though, my comments regarding design are even more relevant then :wink:

Indeed i will design, but this is before i even design. It falls under feasibility study, which is part of the project.

Basically, the data goes like this:

internet --> computer --> arduino --> display.

Also i had been thinking of keeping it simplistic with meters made from LED's. But you say i could display the weather on a mini-display.

Thanks for your help. Tis much appreciated.

This (weather forecast on web -> Arduino -> some kind of display) is actually yet another thing on my list of things I'm going to do one day "when I get around to it" so I thought I'd pass on what I was thinking in case you find it useful.

I was planning to use an ethernet shield and get the Arduino to fetch the weather forecast data itself over the network. In preparation for this I looked at "scraping" the info off the BBC's horrible new weather forecast pages and transforming it on a server to a simpler string that the Arduino could read direct to offload the heavy duty processing. I discovered a PHP library called "simple_html_dom" that lets you parse and manipulate html and made a page on my server that returns the bare bones of the forecast.

The PHP on my webserver is as follows:

<?php
include_once('simple_html_dom.php');

// create HTML DOM
$html = file_get_html('http://news.bbc.co.uk/weather/forecast/2201?printco=Next12Hours&temp=centigrade');

$timeblocks = $html->find('div[class=times]', 0);
$timeblock = $timeblocks->find('div[class=time]');

foreach($timeblock as $block) {
      echo trim($block->find('h3', 0)->plaintext);                // time
      echo " ";
      echo trim($block->find('img', 0)->alt);                     // forecast
      echo " ";
      echo trim(str_replace("&deg;", "." , $block->find('span[class=cent]', 0)->plaintext));  // temp
      echo " -- ";
}
    
// clean up memory
$html->clear();
unset($html);

?>

and it turns the complicated HTML of the weather page into a string like this:

19:00 Sunny Intervals 13.C -- 22:00 Light Rain Shower 11.C -- 01:00 (Sat) Light Rain Shower 9.C -- 04:00 (Sat) White Cloud 7.C --

The Arduino could easily read that string and send it direct to an LCD or LED display, or you could say just use the forecast temperature and control one of those LED bargraph things you used to get on Hi-Fi's. Or make a retro display with an analogue gauge or two, maybe one for temperature and another one that points to sunny, cloudy, rainy etc. using servos.

Anyway, just some ideas I had before I got distracted by the next cool thing I was going to do...

Andrew

well, acn you do the save with a RSS feed like this :
http://www.rssweather.com/wx/fr//dole+tavaux/rss.php

You can get a feed of the BBC weather too:

http://newsrss.bbc.co.uk/weather/forecast/8/Next3DaysRSS.xml
http://newsrss.bbc.co.uk/weather/forecast/8/ObservationsRSS.xml

If you go to BBC Weather - Home and enter a location, a little orange RSS button appears in the boxes you can get feeds for.

Unless I'm mistaken you can't get the BBC's next 12 hours forecast as an RSS feed, and that's the one I wanted.

Andrew

RSS, feeds, fantastic, this makes things a lot easier. Thanks.

Also, onto parsing. I did some research and found Process. Would it be feasible to have it extracting the relevant temperatures and sending to the arduino over serial?

Or how would you do it? Aside from the ethernet shield that was mentioned. Which i know nothing about, but am willing to learn.

Just realized i meant Processing.

Done some more digging and python looks like a good option to consider.

Right, i now have half the solution.

An automator script downloads a rss feed and extracts the text from it to give a file containing:

Friday: sunny, Max Temp: 21°C (70°F), Min Temp: 9°C (48°F) - 
2009-05-26 20:35:09 +0100

Max Temp: 21°C (70°F), Min Temp: 9°C (48°F), Wind Direction: SE, Wind Speed: 9mph, Visibility: poor, Pressure: 1031mB, Humidity: 62%, Sunrise: 04:58BST, Sunset: 21:18BST



Thursday: sunny intervals, Max Temp: 19°C (66°F), Min Temp: 10°C (50°F) - 
2009-05-26 20:35:09 +0100

Max Temp: 19°C (66°F), Min Temp: 10°C (50°F), Wind Direction: W, Wind Speed: 8mph, Visibility: good, Pressure: 1030mB, Humidity: 73%, Sunrise: 04:59BST, Sunset: 21:17BST



Wednesday: heavy rain, Max Temp: 15°C (59°F), Min Temp: 9°C (48°F) - 
2009-05-26 20:35:09 +0100

Max Temp: 15°C (59°F), Min Temp: 9°C (48°F), Wind Direction: WSW, Wind Speed: 16mph, Visibility: poor, Pressure: 1017mB, Humidity: 86%, Sunrise: 05:00BST, Sunset: 21:15BST

Next a python program takes it and parses the file and outputs: the weather, max temp and min temp.

The python is:

#!/usr/bin/python
# Filename : weather1.py

import datetime
from datetime import date

enableser = bool(input("Enable serial, (True or False) : "))
if enableser:
      import serial
      ser = serial.Serial('/dev/tty.usbserial-A8004Iyv', 9600)

import time

def getday():
      dayshift = int(raw_input("Enter dayshift, (eg 0 for today,1 for tomorrow.) : "))
      now = datetime.datetime.now()
      year = now.year
      month = now.month
      day = now.day + dayshift
      dayofweek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saterday', 'Sunday']
      daytoday = dayofweek[date.weekday(date(year,month,day))]
      return daytoday

def findcolon(no):
      for x in range(1, len(strweather)):
            if strweather[x] == ':' :
                  no =no -1
                  if no == 0:
                        return x
      
def parseline(str):
      strsky = str[ findcolon(1)+2 : str.index(',') ]
      print strsky
      strmax = str[ findcolon(2)+2 : str.index("C") -1]
      print strmax
      strmin = str[ findcolon(3)+2 : str.rindex("C") -1]
      print strmin

today= getday()
fileoverride = bool(input("Override default file, (True or False) : "))
if fileoverride:
      newfile = raw_input("Enter the path for the file : ")
      file = open(newfile, "r")
else:      
      file = open("HerefordWeather3Days.txt", "r")

for line in file:
        if today in line:
            strweather = line
            occurs = True
            break
      else:
            occurs = False
print "The day is", today
if occurs:
      print strweather
      if enableser:
            ser.write("Y")
      parseline(strweather)
else:
      print  today, "is not in the file"
      if enableser:
            ser.write("N")

#time.sleep(5)

It contains a lot of useless serial stuff which makes a green or red led on my arduino signify if the script worked or failed.

Sorry for the lack of comment, but i haven't had time yet. Just learnt python in a few days and my heads still spinning a bit =P. Just ask away if you want.

Thanks for your help pointing me in the right direction.

Right, for the next bit i would like to hook up an LCD display for text.

I was thinking maybe this: Basic 16x2 Character LCD - Red on Black 3.3V - LCD-09051 - SparkFun Electronics

Is it compatable, if so how hard will it be to get the arduino displaying short phrases of text?