Weather station project, the beginning
November 11, 2010
I've been thinking about making a weather station for a while. My goal is to have it running when I go for a two week trip at the end of the year so I can check how cold it is back here in Finland :-) To put it simply, the idea is this (the usual weather station stuff I think):
- Remote unit outside checking the weather and transmitting data to main unit
- Main unit inside showing temperature and stuff and also measuring room temperature
- PC logging data
- Remote access over Internet (or Twitter feed, or Facebook thingie, or something...)
Last Saturday I finally got started and it's been going pretty well so far. I got FT232R USB UART chip working, Hope RFM12B transceiver modules are handling wireless data just fine, SHT15 is giving me temperature and relative humidity readings and my LCD is displaying those readings. Of course it's all just a big mess on breadboard at this point. Well, actually on two breadboards and a piece of perfboard. This is how it looks like (click to get the big picture):
Would you believe there's wireless connection between remote and main units?
Here's a small explanation of the picture above:
Upper left: FT232R USB UART connection from PC to main unit
Upper right: Remote unit with ATTiny2313, RFM12B rf-transceiver and SHT15 temperature and humidity sensor
Lower part: Main unit with ATMega168, RFM12B rf-transceiver and LCD
What's missing? Well, at least nice casing for all the stuff, wind measurement thing (although I don't have good place for that), rain gauge (won't need this until spring), barometer and lot's of software. I can probably (hopefully) deal with those. One thing I'm not so sure about is how to power the remote unit. Lithium batteries would probably be the simplest approach (and my plan B). What I really would like to do is to have solar power for it. Only problem is the long, cold and dark winter here in Finland. That means I must have some kind of battery for the remote unit and that battery has to stand -40°C (temperatures below -30°C are not uncommon here in winter). So far only thing that I can think of is lead acid/gel battery and charge that with solar panels when it's sunny. I have to do some more digging around the Internet because I'm really not a battery expert. Any good suggestions for batteries are welcome :-) Anyway, if I can't figure out the power problem I'll make a forum post later.
What I'll do next: Maybe (try to) build a wind measurement thingy. And browse the Net for batteries.
Update Nov 12, 2010:
I just added a snapshot of my current code. Some things to note:
- ATTiny-rf12-transmitter-v0 is for ATTiny2313
- ws-main-unit-v0 is for ATMega168
- Both ATTiny and ATMega use internal oscillator @8MHz
- Main unit code uses floating point math so make sure you use correct libm (at least AVR Studio+WinAVR uses wrong one by default)
- Bugs expected. Don't fry your chips if you try my code :-P
And here's a list of some (not all) resources I found useful:
- Example code for RFM12B here: http://www.hoperf.com/upfile/RF12_code.pdf (V1.2)and here: http://www.sparkfun.com/datasheets/Wireless/General/RF12B_code.pdf (V1.1)
- I found schematic for negative gate drive voltage generator (for adjusting LCD contrast) here: http://www.electro-tech-online.com/electronic-projects-design-ideas-reviews/96614-555-negative-voltage-your-criticism.html#post780426. I difference in my neg. voltage generator is that I used 1N5818 Schottky diodes instead of 1N4148s and BC327 and BC337 transistors instead of 2N3906 and 2N3904.
- Atmel app note 319 had nice examples how to do SPI with USI. It's listes here (among other nice app notes): http://www.atmel.com/dyn/products/app_notes.asp?family_id=607
- Well of course datasheets of all the stuff...
Update Nov 13, 2010:
Another update for those who are interested about RFM12B's range. I did some testing and got some results even though the weather wasn't very good (at was snowing) and it was already getting dark until I got my test software ready.
Here's some estimates of ranges I got:
- Main unit placed inside by a window. Remote unit outside with me: I got maybe 40-50 meter range without problems. At that range I had to stop and "get out of the way" myself. Holding the remote unit steadily and keeping myself out of the way I was able to get about 70-80 meter range. I wasn't able to test it further away because at that point another building was starting to get to the way.
- Both units placed outside and trying to keep line of sight: I got maybe 80-90 meter range without any hiccups then I occasionally had to stop get a clean signal. I was able to get transmission as far as 170-180 meters away but then I really had to search for a good place for reception and align the remote unit "correctly".
[Ranges are estimated using my "gut feeling" and a 1:2000 scale map. Laser range finder would be nice toy here :-)]
So, RFM12Bs are definitely good for my weather station and at least short range remote control. I used really simple "send and wait for ACK" protocol in my test and there wasn't much data to be transferred (15 bytes back and forth every 1 second or so). Using a bit more sophisticated protocol with resend and other nice stuff would take care of some hiccups at smaller ranges. Also, I used my transceivers at 4.8kbps speed. Higher speeds may or may not work at the ranges I got.
I've also updated attached code to the version I used in my tests today.