Introduction: Wireless Outdoor Arduino Weather Station With PC Logging and Graphs
Features
- Temperature, Humidity and barometric pressure measurement
- No external power for outdoor sensors required (solar powered)
- Wireless communication between outdoor sensor and PC
- Full logging and reporting on weather information on PC
- Relatively inexpensive and easy to build
Code is also available at https://github.com/zmashiah/arduino-StalkerV2WeatherStation
Components of the solution
- Arduino compatible Seedstudio Stalker board for remote sensors.
- XBee based communication between outdoor sensor and PC
- Solar panel and LiPo battery for outdoor sensor power
- XBee Explorer connected to PC for communication reception
- C# based PC application to store, report and graph all data
What will you need to build this?
- Seeduino Stalker v2 ($39). If you chose v2.1 there will be some code modifications required.
- Solar panel for powering the outdoor sensor ($ 2.00)
- A LiPo battery of 1000mAH or 2000mAh ($7.5 - $12)
- DHT22 Humidity sensor ($ 9.95)
- BMP085 Barometric pressure sensor ($19.95)
- A 10K Resistor
- 2x Xbee series 2 modules (2x $25.95)
- XBee Explorer ($ 24.95)
- Jumper wires
- USB Cable to connect PC to XBee Explorer
- Optional small bread-board to hook up the two sensors above. Choose either a solder-less one or something like this that does require soldering or any other alternative you think is suitable for you.
Notes about the components:
Battery: I built the outdoor sensor unit with 2000mAh battery, however by monitoring the device for few months now, including winter I can tell you this is really an overkill as the battery does not get drained or even close to that. I have every reason to believe a 1000mAh or even less will be enough.
Price: For almost any of the components above, I recommend spending some time online, including eBay to find a much better price for each. My experience in the last 6months is that you can find things on eBay for fraction of the cost compared to the amateurs sites.
Board: I used the Seedstudio Stalker for remote sensor controller, however one can really build it with many other Arduino compatible boards. The reason I chose this one is because it has both XBee module socket, on-board real-time-clock (RTC), ready for LiPo battery power and charger, which are all great features that are required here. I did take advantage of the RTC for waking up the board periodically.
XBee: I used the 2mW Series 2 ZigBee modules while in fact for this application without future enhancements that I consider, one can use Series I modules and perhaps the 1mW versions. Since I plan future enhancements I used the Series 2 modules. As for transmitting power, the 2mW will be my recommendation. My house is built of concrete and the distance between outdoor sensor station and PC is not too long, still if I take it 5 meters further, the reception becomes very poor.
DHT22: You can choose to use DHT11 instead of the DHT22
Other Tools you will need:
- Arduino IDE. I use the version 0022. Porting the code and libraries to newer IDE version should not be too difficult but pointless as far as I am concern.
- X-CTU tool for configuring the XBee modules
- I use the following libraries: TMP102 (Stalker on-board temperature sensor), R8025 (Stalker on-board RTC), BMP085 (barometric pressure sensor), DHT (for DHT22 humidity sensor), NewSoftwareSerial (for debugging console), Xbee-arduino (for wireless communication). All these libraries are included in the code ZIP file here, however if you decide to port or modify things here, I thought is important to mention this list. Specifically when porting to newer IDE note the name of NewSoftwareSerial was changed, and you need to use #include instead of #include (back-compat of the IDE was not high on the list I guess :-))
- Soldering Iron
Disclaimer:
This is a hobby build and not a product. I did not include any languages support other than English. I use only Celsius temperatures (you can modify code to use Fahrenheit if you want), there is no data archiving and grooming support and more similar stuff that makes something a product rather than a hobby build.
Attachments
Step 1: Assembly Instructions
- Connect all the sensors to the Stalker/Arduino board
- Make minor modification to the Stalker
- Configure the XBee modules
- Load program onto the Stalker
- Run program on the PC
DHT22 connected to digital pin 2.
DHT22 Pin 4 to GND of Arduino
DHT22 Pin 2 to digital pin 2 of Arduino
10KOhm resistor between pin 1 (Vcc) to pin 2 (data) of the sensor
DHT22 Pin 3 is left not connected.
Consider using small bread-board for this small circuit
For this to work you will need to connect the FTDI to the below pins or simply use
additional FTDI board (that's what I did). If you only use one board then you will need
to connect it to the programming side, load the program then connect to the console pins to see the output, which is pretty tedious if you ask me.
To connect console only, here are the connections required:
GND from the FTDI to Arduino GND
Rx from the FTDI to digital pin 9 of the Arduino
Tx from the FTDI to digital pin 3 of the Arduino
Gnd from sensor breakout board to GND of Arduino
SDA from sensor breakout board to Aruino analog pin 4
SCL from sensor breakout board to Arduino analog pin 5
If you are using small bread-board for the DHT22 sensor, you can probably include this sensor on it too.
Minor modification to the Stalker board
In the v2.0 you will need to place a short on the bottom side of the board to connect INTA\ and PD2 pads, see this picture.
I did not checked it with v2.1 of the Stalker, but could see the same functionality still exist there. Having said that, the RTC module used in the Stalker v2.1 is very different DS3231 compared to R8025 on the v2.0. There are Arduino libraries for this new version RTC module out there, but it will obviously require some code modifications on the sketch I have here. This is not very difficult though, so don't be too scared of that.
Next connect Arduino digital output 5 to XBee pin 9. You will see Pin 1 marked on the XBee and Pin 9 is one before last on that row. The Stalker does expose 0.1" header that represents the XBee pins so it is easy to solder a header and do the connection, or use simple wire for that.
Configuring the XBee modules
There is quite a bit of information and in-depth on the XBee modules on the net. I will not go into all the details here. Few notes though: The XBee modules have API mode and Command mode firmwares. I use the library that requires the API mode. Also, with Series 2 of XBee, there is a role for each module, so we need one coordinator that is connected to the PC and one endpoint which is the module installed on the remote weather station. Also there is some addressing information that needs to be identical between units, and I chose this address code to be 2266 (my birthday if anyone is curious). Obviously you can choose something different. On the coordinator side (PC) the AO needs to be 0. On the weather station side the AO should be 2 (but in any case I ignore the return codes, so it will work anyway).
- Install the X-CTU utility
- Optionally do firmware upgrade to the XBee Modules (please note you need the API mode firmware)
- Configure one unit to be coordinator and another to be endpoint
- Configuration for both coordinator and endpoint (the sensor) is included in the ZIP file for this instructable
- Write down the Coordinator XBee address (Nodes Addressing/SH and Addressing/SL).
- Place the XBee module configured as endpoint into the Stalker socket
- Place the XBee module configured as coordinator into the XBeeExplorer and connect it to the PC
- Connect the UartBee to the Stalker programming pins (see Seeduino site for details).
- Make the recommended modifications to Arduino IDE so that it will know about this type of board (see the content in ArduinoIDE sub directory of the ZIP file attached here)
- Add the libraries from the ZIP file sub directory Libraries to the user libraries of your Arduino IDE
- Connect the UartBee to your PC USB
- Place the code for the Stalker in your development area,
- Go to the line in the ..pde file that says "static XBeeAddress64 addr64 = XBeeAddress64(0x0013A200, 0x40869EF2);" and modify the numbers to have the address of your coordinator as you wrote down in previous section XBeeAddress64(SH, SL);
- Compile and load the program onto the Stalker
- Connect battery and solar charger once you also assembled all in your enclosure
- Place the .exe and .dll files on your PC in some directory of your choice (no, did not do an install program). WeatherSationMan.exe and DTG.Spreadsheet.dll are located in the WeatherStationMan\bin\Debug
- Run the program and double click on the COM port to which your XBee is connected to
- After a minute or so, you should start to see readings of the weather information from the remote station
- Add the program to automatically start on boot time by following steps in this explanation. Follow the path and file name of the program with the parameter specifying the COM port to which the XBee is connected. For example, if the COM port is COM20, you will do something like: C:\Temp\WeatherStationMan.exe COM20
Attachments
Step 2: About the Software
I am not really a GUI person, and actually had very little hands on experience with C# too before. I am saying that because I think there could be better ways to do the design of the software here. Also, I run into problems on the Arduino side due to memory constraints that made it reboot with no apparent reason as well as some hardware issues with turning XBee module on and off from the controller. All those problems are solved and the weather sensors station is now running for months. The PC software is also running for long time without any issue, though I did add few graphs and export to Excel recently.
The way things work system wide:
Every minute the Stalker wakes up, using an interrupt from the RTC module. It collects information from the different sensors, sends it over XBee and goes back to sleep. On the PC side, a C# program is opening serial port, listening to the XBee and if received information is correct, writes it down to a CSV file (default location is C:\Temp\NewWeatherStation.csv and can be changed as a constant on the PC side).
On the remote weather sensors station there are actually 3 different temperature sensors. One TMP102 which is an on-board sensor. The DHT22 has temperature sensor too and so does the BMP085. All this information, together with time from RTC, Humidity, Barometric pressure, altitude calculation as well as battery charging information are sent over the XBee to the PC, where it is all saved in the CSV file and displayed on the main application screen.
I chose to report from the remote weather sensor station once every minute, but obviously this is way too frequent than weather is actually changing. The major reason for that is I did not want to wait an hour for every packet for debugging... In the future, I might implement an averaging of once every 30 minutes sampling on the PC side. Longer wait times by the way have implications on the XBee connection between endpoint and coordinator that require re-negotiation and discovery that I prefer to bypass. The only downside to too frequent sampling is larger history file. Using the system for some months now it takes about 4MB per month, which is not that much and can be further reduced by dropping some of the redundant information there too. Bottom line, this is good enough.
Originally I chose to use CSV file for easier implementation and to have simple way of import to Excel for graphing and reporting. Eventually I chose to do the graphing myself, just because I wanted to experiment with that too in C# (Microsoft did a really nice job there I must admit). I also found a free C# library (assembly) to export information directly to Excel. The name of this is JetCell and it is pretty good one for what I need here, so I added that too. In the future, I might change the storage to be a data-base if I will find any good reason to do so.
Step 3: Using the Software
Understanding application main window
The screen has 4 areas:
- On the top left is the XBee Serial port selection and open/close button. Double click on a any serial port name will open it, or you can select it and click the Open button. Once a port is opened, the button changes to Close and the name of the serial port that is open.
- Still on the top, right there is a Communication Status area with 4 fields. The packet rectangle is typically grey, but on packet reception it will blink green. The receiving button is green when communication with remote weather sensor station was made recently. It will turn yellow few seconds before a new packet is expected. If it turns red, that means communication was lost. In the Status line the program updates when it got last packet or communication error message should one happen. The Station Time displays the time of the remote weather sensor station as saved on the Stalker RTC.
- At the bottom there is the Date section with information from every sensor on the remote station, including battery power and charging indicator. The battery should be green almost always, while yellow is still not a bad thing. If battery is red then it means not enough power for the remote weather sensor station. Right to that rectangle there is a charging indicator. It should turn yellow when charging the battery, green if charging is complete and grey during dark times.
- On the right hand side of the screen there are 3 buttons, to close the application, Graphs to open the grid view of the data and the famous About... I would have skipped that but JetCell requires that if you are using the free version as we do here.
Showing Graphs
On the main window there is a button named Graphs. It will is available most of the time, though just before a new packet is expected from the remote weather sensor station, it will turn grey and be disabled to avoid locking on the file. Pushing this button will open up a grid view of the entire period stored in the file.
Seeing graphs of weather parameters per minute
Double click on any cell or row other than the header of the columns will result in a report on all measurements of that day.
Changing Sorting of the information
Double click on the header row of the columns will result in different sorting options.
If you want to see meaningful graph of temperatures for the period or any other parameter, leave the sorting to be by date.
Filtering the period for graphs and grid view
You can change the filter to include only part of the period saved in the file to be presented. Once done, the grid view will display only dates in that range, and graphs for the period will only show graphs of the filtered period.
Exporting information to Excel
You can export to Excel that will save information as either .XLS or .XLSX file formats. Default is .XLSX as I have office 2010 installed.
Step 4: Mounting Outdoor Weather Sensor Station Notes
Few notes that might look like the obvious to some, still worth mentioning. You need to place the outdoor unit in a shaded location, and better have also some rain protection too. Although you can use a water-proof enclosure, why test it :-)? If the unit is exposed to direct sunlight, temperatures reading will be very high, especially in the summer.
On the other hand, the Solar panel should be located somewhere where direct sunlight does occur from time to time. This will ensure the battery gets fully charged. From my experience about 1 hour of direct sunlight and rest without is enough to fully charge the battery. I placed the panel facing the east side but shaded most of the day. This is enough to charge the battery fully after 2 hours of daylight.
Last but not least, Enjoy the weather!
40 Comments
Question 4 years ago
Hello! I was wondering if you are happy with the humidity sensor in long term ?
I have a similar project (but not with a DHT22) and face some trouble that sometime the humidity is measured too high (upto 100%)
I think it may be some dew on the sensor.
Reply 4 years ago
I did not had issues with it as you report. Do note though that it is better to measure few times and average the results than relying on single sample. I noticed that in few rare cases I get some noisy samples due to electrical noise (drill or somet other powerful electro mechanic tool) in proximity. Did not implemented that yet...
6 years ago
Hi zmashiah, can you please send me the pdf by email?
I thank you so much if you send me with the tutorial, I wanna try this project in my University and this is really support my lecture.
Reply 6 years ago
Hi,
Am no longer a premium user and can't download PDF of my own Instructables :-( Sorry.
Reply 5 years ago
Do you have an email? Pls emailing me wildan.majid354@gmail.com
Maybe u can help me on my research
6 years ago
Doesn't it make faulty temperature and humidity readings by placing the DHT22 sensor inside the cage? Arduino and battery heat compromises the readings, as I have seen in my own projects.
Reply 6 years ago
Hi Daniel,
In some other projects with closures I have seen this, however in this project the Arduino wakes up for less than a second to collect readings from sensors, and hence entire power dissipation in this circuit is so low that the temperature barely changes as a result of power here.
As for humidity, this is a bit tricky indeed, but what I got is a cord feeding the unit from solar plate, and I did not seal it. That provides enough room for air to circulate through and not be locked in the enclosure. Is this scientifically absolute measure? Most likely not. Good enough however to know as standard person if we got 80% humidity outside or not :-)
7 years ago
Can you explain how you placed a short on the Stalker board?
Reply 7 years ago
Hi Thomason,
The short is done between two pads that are really close to each other (see the picture in the instructable text). Use your iron and drop of tin to make the short mentioned.
Reply 7 years ago
Hi Zmashia,
the text and picture are very vague. Can you send a specific picture and text that shows the exact area and give more detailed directions? thanks!
Reply 7 years ago
There is a picture showing the bottom of the board (Red PCB).
Right in the middle of the picture are pads marked with INTA_RTC (If you look at the S of the Seeduino logo, follow left the leads on the PCB until they make a bend down (south), you will see the mention pads.
8 years ago on Introduction
Thank you for the Instructable. I want to note that since you state cost is an issue, you could think about replacing those Xbee's with generic RF modules for a fraction of the price (1.25$ on eBay for a set of receiver and transmitter including shipping). Also you can easily run this on a simple Arduino on a breadboard solution and add a step up converter and a lipo charger module for a total of 7 or 8 bucks. Last you can find barometric pressure sensors for as little as $1.40 on eBay. These changes will save you $120 easily.
Reply 8 years ago on Introduction
Thanks Rick. Not all options you mentioned were available at the time, and indeed you can save quite a bit on this if you go with different HW options. The biggest savings could be the RF modules as I use very little features of the Zigbee stack (nothing but CRC actually). I was suspicious about the range and reliability of the other modules. Time proved I was wrong. The Zigbee modules were replaced few times due to module problems and other projects I done with penny RF modules continue to work flawlessly. You always learn something new...
8 years ago on Introduction
Hi again! I updated the arduino code to the new stalker 2.3 and it´s fine on the arduino side. There is however a parsing error on the PC app.
I don´t know C so I am stuck.
I think this may be a small sequencing size or order thing inside the packets, as they are received and obviously you structured the sending and receiving.
I understand this is now an old project for you but, believe me, you can´t find much help on sending and receiving digital sensors data on API mode!
Can you help?
Regards!
Reply 8 years ago on Introduction
It is C# not C. Much easier than C, but without debugging I can't really help. Sorry
Reply 8 years ago on Introduction
Hi Zakie
I reconfigured the xbees and now I get a reading on the PC side with no errors. The problem is the PC program WeatherStationMan stops working as soon as the first set of data is received and Windows closes the program (which actually is showing the correct data on the background.
Can you help? We are almost there this time!
Regards
Reply 8 years ago on Introduction
Please check your XBee configuration in case your configuration now sends to the PC some of the Mesh internal message. I don't quite remember the name of that configuration parameter, but I remember there is one. The C# program does not know how to parse those messages, and we don't need that in this case.
Reply 8 years ago on Introduction
Always happy to help.
Have you modified code on the sending side (arduino)? If so, send me that code please.
Do you know how to use X-CTU by any chance? If so, please send me the dump of the received packet on the PC side. That will be very helpful
Reply 8 years ago on Introduction
Hi Zmashiah
Thanks for your reply. I was away for a few days so I am answering only now.
I did modify the code a bit to include the new RTC; works fine on the arduino side.
Problem is on the PC side: error or parsing packets.
I have the code ready to send you and a few sample packets, as you asked but I don´t know if it will upload.
If you don´t receive them let me know how to send.
Regards
Pedotech
Reply 8 years ago on Introduction
Hi,
I did receive the files, and couldn't find the issue easily. I think you will need to go into debugging to find out. On the PC side, place a breakpoint in source file MainWindow.cs and method: SerialDataReceivedEventHandler. Look at the flow of bytes and see if there is any need to change the offset of those.