Weather Station Part 2

Continued from part 1. Alright! So I got my Arduino, time to mess around with it! …and in the process of messing around with it, the serial port on the router stopped working. <Sad-Face>. Luckily the WRT54G has two serial ports, but only the first is connected to the console by default. After some reading, this is what I needed to do: change /etc/inittab so it refers to tts/1 instead of tts/0

tts/1::askfirst:/bin/ash --login

Add a line to /etc/init.d/S15serial to set the IRQ of the second serial port on startup. Both ports share an IRQ of 3:

/usr/sbin/setserial /dev/tts/1 irq 3

Success! After the (second!?) reboot these changes took effect and I didn’t have to tear some hair and abandon things.

The Arduino

So, I have an Arduino. First thing was to get an SD card attached. I used an add on board from Futurlec and the Arduino’s SD library and was up and running surprisingly quickly. With a free 32MB card from a digital camera, at a logging rate of 47 bytes every 15 minutes, I’d have enough space to last 20 years. Sweet!

Data from the weather station comes in over a RS232 link. To get this down to 3.3V for the Arduino I needed an interface circuit. I’m only concerned with receiving data so a simple transistor inverter will suffice:

This connects to the RX pin on the hardware serial port of the Arduino. I also needed a software serial port to talk to the router, using the NewSoftSerial library. The fastest the software serial port can run is 9600 baud, so I would need to slow down the baud rate of the serial port on the router (add this to /etc/init.d/S15serial):

stty -F /dev/tts/1 raw speed 9600

However, the default speed of tts/1 is already 9600, so I didn’t need to do anything.

The rather simple Arduino code I came up with, which ties everything together is here. After a few days of testing, this is what it finally looked like:

It looks a little messy, but it works. Both the Arduino and the actual weather station on the roof use some siphoned power from the router, thus the whole system runs off a single 12V 1A power pack. The router sits inside the house, with the grey wire above going out to the weather station on the roof:

That’s it! Now I have weather data flowing in to my server at home. With a little bit of PHP to display it all, the results look pretty good. (Update 22/02/2013: The station needs some repairs and is out of action right now)

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

One Response to Weather Station Part 2

  1. Pingback: Weather Station Part 1 | Mechinations

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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