LED Wind Indicator

16K9314

Intro: LED Wind Indicator


I have something with the weather. I always like to know how warm or cold it is, how much rain has fallen, how hard the wind blows and from what direction,... and so there are lots of sensors around our house to keep me up to date. These sensors give only a limited range of data, so I still need the internet to inform me about everything I want to know.

I am lucky because one of the national weather data collecting points is located in the village where I live. And all its data is to be found on the internet, together with the data of all other collecting points and predicions for the upcoming days in a very handy XML-file.

The only drawback is that you always need a computer to acces that data. So I decided to start buiding a device to display the data without a pc. This wind indicator is a testversion, displaying only the wind direction, its force and a prediction for the next day. It is connected to a pc via a USB to RS232 converter, but the future project should be able to work as a stand alone version.





STEP 1: What Do You Need

  • 31 LED's
  • 10 x 150Ohm resistor
  • 1 x 1K5 resistor
  • 1 button
  • 2 screwterminals
  • 1 isp 10pins connector
  • an atmega8
  • a 100nF capacitor
  • a USB to RS232 cable or something similar. ( I use the RX and TX pins of an xbee to USB connector)
  • a programmer
  • python 2.6

I made this project with smd components, but it can be build with thru hole parts. I also used a lot of copper thru hole links. These are completely optional, you can use a soldered wire to connect the 2 layers. 


STEP 2: The Circuit


The circuit for this project is very simple.

28 leds are arranged in two matrixes.
  • One is a 4x4 matrix connected to Port B of the microcontroller. Those leds will point the direction on the compass card.
  • One is a 3x4 matrix connected to Port C of the microcontroller. Those leds will display the force of the wind on the Beaufort scale.
The 3 remaining leds are used as indicators
  • Two leds on PortD.3 and PortD.4 indicate indicate whether it is actual data or a forcast. 
  • One led on PortD.7 flashes when new data is received.

DonĀ“t forget the 150Ohm resistors for the leds,

The button is connected to Pind.2 (the INT0 pin) with a 1K5 pullup resistor on one side and ground on the other side.

The ISP connector is added to the miso, mosi and sck pins Port B and with the reset pin.

RX and TX (PortD.0 and PortD.1) are connected with a screwterminal. This will enable us to add our RX an TX lines from the USB to RS232 cable.

Add a screwterminal for power and don't forget a 100nF capacitor between the lines.
 

Testing the uart and the leds:

STEP 3: Programming the Microcontroller

I've added the bascom code here. It is still a bit quick and dirty but it gives a good idea on how the device is programmed. I also added a hexfile for those who just want to try it.

The program itself works very simple:

It waits until it receives 4 pairs of bytes. The first byte tells the program what kind of data the second byte holds. Two pairs contain the present data and two pairs contain the forecast.

When the microcontroller has received the 4 pairs it will process the first 2 pairs and display the current data. If the button is pressed an interrupt occurs and the microcontroller will display the second set of data (aka the forcast) for 5 seconds.

Don't forget to change the fusebits so that Portc.6 is an IO pin instead of reset, but do it after the microcontroller is programmed because afterwards it won't be programmable anymore.

STEP 4: Getting the Required Data to the Device.

'And now for something completely different...' 

A bit of Python:

It is actually the first time that I write a bit of code in Python. And I must say that I love to learn more of it because it's really great to use.

I added the code written in python 2.6 here and I am open to all comments or suggestions about it because it's also new to me.


The basis for the data is an XML-file that contains the weather data for the Netherlands. Python looks the wanted data up in the file and sents it to com 4 every 5 minutes.


###############################################################################################
import urllib
import serial
import time
from xml.etree.ElementTree import ElementTree
StationId = "6319"
speed = {"1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","10":"a","11":"b","12":"c"}
direction = {"N":"1","NNO":"2","NO":"3","ONO":"4","O":"5","OZO":"6","ZO":"7","ZZO":"8","Z":"9","ZZW":"a","ZW":"b","WZW":"c","W":"d","WNW":"e","NW":"f","NNW":"g"}
url = 'http://xml.buienradar.nl'
ser = serial.Serial(3)
while True:

print "nieuw"
root = ElementTree(file= urllib.urlopen(url))
iter = root.getiterator()
for element in iter:

if element.tag == "weerstation":

p = element.items()

for name, value in p:

if value == StationId:

for child in element:

if child.tag == "windsnelheidBF":
q = "1"
q = q + speed[child.text]
print q
ser.write(q)
if child.tag == "windrichting":
q = "2"
q = q + direction[child.text]
print q
ser.write(q)

if element.tag == "dag-plus1":

for child in element:

if child.tag == "windkracht":

q = "3"
q = q + speed[child.text]
print q
ser.write(q)

if child.tag == "windrichting":

q = "4"
q = q + direction[child.text]
print q
ser.write(q)

ser.close
time.sleep(30)              

###############################################################################################

14 Comments

Thanks!
Super job on the PC design. Very intelligent use of copper shapes and text. I agree with the nautical feel (I'm a sucker for boats anyway). It would be neat to see it housed in a mahogany box. Gotta stick with a weather resistant wood if you want to maintain the nautical aesthetic.

David
It took me quite a long time to figure out the layout for the PCB. I am glad that you like it.
I wonder if you could make it standalone using a Lantronix Xport device?

Fantastic work, as always!
I was actually planning to attach an Xbee to the RS232 port on te router that I used for the wifiradio to send the data to a stand alone device. That one should give a lot more info like temperature, presure, amount of rain falling, wind direction and speed and predicitons for 5 days ahead. But an xport would work I guess. I have no experience with those.
They're pretty nice, but wired. If you want wireless then an Xbee is definitely the way to go.
That has to be one of the most beautiful PCBs I have ever seen!
Thanks a lot!
Very nicely done. I love the nautical look of the board. I was wondering if the thru hole copper pieces you used are a product that you found or something that you made. I've been using cut copper wire to make my vias but would love to have soemthing purpose made for the job.

great instructable.
Thank you! Ik bought the vias at an online shop in the Netherlands. smdshop.nl
Very Cool! And what a great pcb-lay-out!
Nice project. Do you know how to get the same or similar data for US weather stations?
www.weather.com has an XML service.