Weather Station Part 1

Way back in 2007 I made a weather station to be used on my dad’s property. The original idea was to build a station that could log temperature, humidity, wind speed and rain and make the data available on the net to be viewed remotely. I hollowed out a cheap weather station unit from ebay, built my own electronics and connected it up to an old PC running FreeBSD. Unfortunately I never really got it all working as the satellite internet connection did not have any incoming ports open (for web serving), the PC was noisy and power-hungry, and there were often brownouts (which seemed to destroy the UPS I had). Recently I decided to re-vamp the system, and overcome said obstacles.

The Plan:

The weather station sends data every 15 minutes via RS232, this is captured by the Arduino and saved to an SD card. This should provide a nice little backup if there are power outages or interruptions. The Arduino also sends the weather data via a software serial port to a router running OpenWRT. The router can then use a simple command like wget to open a php page on a webserver which will record the weather data and display it on a snazzy webpage. It would be possible to cut out the Arduino completely, I have seen hacks that add an SD card to the router, but this is too complicated and difficult for my liking.

To get started I ordered a Arduino from Sparkfun. Generally I avoid the Arduino, but it does have easy to use SD card and software serial libraries. I chose the Arduino Pro Mini 328 – 3.3V/8MHz as the SD card and router are both work on 3.3V.


The next step was to get OpenWRT (whiterussian-rc6) working on an old router I had. I hoped it would be a simple process: download the binary and use the router’s web interface to reflash. Alas, something went wrong and I was left with a semi-dead brick. I attached to the serial port on the router and found the bootloader couldn’t read the flash. Great.

After much messing around and research I managed to reflash using the serial port and Broadcom’s CFE (Common Firmware Environment). What I did:

  1. Run a tftp server on a local machine with a copy of the binary.
  2. Assign the router an IP on the local network:
    ifconfig eth0 -addr= -mask= -gw=
  3. Reflash, pointing to the binary (openwrt.bin) on the tftp server (
    flash -noheader flash1.trx

Note: this worked for me on a WRT54G V3.1, there’s no guarantee it will work for other hardware, but hopefully it will help someone out there.

After configurating the router and learning about VLANs, I needed some way to respond to the Arduino over the serial port. By default, the serial port in the whiterussian build is connected straight to the console under the root user. The hack method I came up with is to pretend the Arduino is a user, and use it to run a script every time there is new weather data. For example, the Arduino will send:

./ T06597 L0024 H00613 R00 W03726 D06

which runs the script ‘’ on the router:

ts=`date "+%s"`
sleep 1
echo "[$ts]"
wget -q -O - $url > /dev/null

The script will wait one second, echo back a timestamp, then use wget to open and send the data using a php script. As I said, this method is a complete hack, but man is it easy. I’ve also been informed it’s probably a good idea to send ‘^C’ before running the script, in case wget is still running from last time. All this sounds like a plan, and I’m sure I’ll find out if I can get it working reliably. Continued here.

This entry was posted in Projects, Weather Station and tagged , , , . Bookmark the permalink.

2 Responses to Weather Station Part 1

  1. Pingback: Weather Station Part 2 | Mechinations

  2. trahn ska says:

    Why don’t I see ads but everyone else does? (Because unlike all the robomata-netters out-there aka dumbasses, I leave js disabled, heh heh, morons)…ad rem, to the main the point, the weather-station project is kewl. I’ve actually been workin’ something similar myself. Keep up the good effort….trahnska

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s