Raspberry Pi 2 Weather Station

31,298

349

25

Intro: Raspberry Pi 2 Weather Station

Our hackerspace (Bloominglabs) recently received an ADS-WS1 weather station from a generous benefactor. Additionally, we were selected by Instructables for the Raspberry Pi 2 hackathon so we got some RPi2's to hack on. For my project, I decided to use an RPi2 to put our weather station online.

Our station can measure wind direction, wind speed, rain, temperature, and humidity. The unit can output data in a number of ways, including serial. I needed a way to read the data and get it down off the pole and onto our network. The Raspberry Pi 2 will do this nicely with a PoE run to a water tight enclosure on the mast.

Step 1: Parts List

1) ADS-WS1 Weather station (any weather station which supports serial data output will work though)
2) Raspberry Pi (any version will work, we used version 2)
3) Serial-to-USB adapter
4) Serial cable with at least one female DB9 shell
5) Ethernet - enough to reach to your outdoor weather station
6) 5V power supply, 1-2A
7) Outdoor enclosure

Optional but recommended:
8) Ethernet surge suppressor
9) Power-Over-Ethernet injection adapters

The first thing to acquire is a weather station. I used an ADS-WS1 station by Argent Data but that is not required. However this unit is very well documented and also has an integrated TNC for broadcasting weather data via APRS (if you hook it up to a ham radio). However that is not required for what I am doing, all I need is a serial port output to read in data. The power draw is only 50mA so it can be fed by RPi or by splitting off from the supply power to the RPi.
http://wiki.argentdata.com/index.php?title=ADS-WS1...

Step 2: Setup an OS on the Rasperry Pi 2

You can use any OS, however I used Raspbian 7.1 on an 8GB SDcard. Follow the directions for the OS you are working from:

https://www.raspberrypi.org/documentation/installa...

Once you have your SDcard prepped, install it in the RPi2 and power it on. It helps to have a local console (display that supports HDMI, and a USB keyboard). Raspbian should use DHCP by default and get on your network if you have a router. However I've found this to be hit-and-miss.

The rest of this document assumes you have some basic familiarity with Linux, the Raspberry Pi docs are very good if you have problems getting your RPi2 setup from here:

https://www.raspberrypi.org/documentation/

One last thing for this step is to plug in your USB-to-Serial adapter. Assuming it's a standard FTDI or other common Serial-to-USB device, Raspbian will automatically configure it. After you plug it in you should see a new /dev/ttyUSBx device show up.

pi@raspberrypi ~ $ ls /dev/ttyUSB*
/dev/ttyUSB0

Assuming it's the only USB-to-Serial device plugged in it will be /dev/ttyUSB0. The "lsusb" command will display all of your USB devices which may help you identify the device if it's not showing up correctly:

dosman@raspberrypi ~ $ lsusb<br>Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

I prefer to setup a static IP as it's one less thing to worry about going wrong when the RPi2 is up on a pole in the sky. Edit /etc/network/interfaces and change this line:

iface eth0 inet dhcp

To this line:

iface eth0 inet static

And add these lines. Replace with the IP address and gateway with appropriate values for your network:

address 192.168.x.x
netmask 255.255.255.0 gateway 192.168.x.x

Now install the software we need, Apache2 for a webserver and some other utilities. Minicom is a good tool for verifying serial communications are working correctly, and wget is for downloading the weather.sh script in the next section.

apt-get install apache2
apt-get install wget apt-get install minicom

For future testing purposes I recommend downloading this script:

wget -O weather.sh "http://server1.nuge.com/~weather/software/weather-...

If for some reason the above link fails you can find the latest version of the weather.sh script here:

http://server1.nuge.com/~weather/

Last but not least, you may need to edit your /etc/group file and add the account "pi" or whichever account you will be testing with to the "dialout" group. This will give appropriate permissions for the account to read and write to the serial device (/dev/ttyUSBx).

Step 3: Install and Configure Weewx, Configure Services to Start on Boot

Weewx is a program that reads in serial data from several makes of weather station and presents a web interface for graphing the data.

apt-get install weewx

Now you will want to configure it. Edit /etc/weewx/weewx.conf and adjust the variables that make sense. The config file is self-documented so it's easy to customize.

# $Id: weewx.conf 2901 2015-02-05 21:15:03Z tkeffer $
# # WEEWX CONFIGURATION FILE # # Copyright (c) 2009-2014 Tom Keffer # See the file LICENSE.txt for your full rights. ############################################################################## # This section is for general configuration information # Set to 1 for extra debug info, otherwise comment it out or set to zero. debug = 0 # Root directory of the weewx data file hierarchy for this station. WEEWX_ROOT = / # How long to wait before timing out a socket (FTP, HTTP) connection: socket_timeout = 20 # Do not modify this - it is used by setup.py when installing and updating. version = 3.1.0
############################################################################## [Station] # This section is for information about your station # Description of the station location. location = "Bloominglabs - Bloomington, Indiana" # Latitude and longitude in decimal degrees ...

Lastly, configure apache2 and weewx to start on boot:

update-rc.d apache2 defaults 99 2
update-rc.d weewx defaults 99 2

Now these services will come up automatically every time the RPi2 powers on. That should be about everything you need for your RPi2.

Step 4: Prepare the Serial Cable and Power Cables

You only need 3 wires plus 2 power wires to wire up the controller. In my photo there are wires in the top 5 screw-down terminals, those are for sending TNC/APRS data to a ham radio and are not required for this tutorial.

So, first you need to wire up a serial cable to the weather controller. Connect your cable to your Serial-to-USB adapter. Now cut the remaining end of the serial cable off, be sure to give yourself enough slack to route the cable as needed and to strip the outer sheath over the wires at least 2 inches. The individual wires only need to be stripped 1/4" or so. You will need to use a multimeter to map out the pins of the cable and find the wires which match up to pins 2, 3, and 5 of the pins inside the DB9 shell. Usually if you look closely the pin numbers are listed next to the pins.

The wire for pin 2 goes to TXD1 on the controller.
The wire for pin 3 goes to RXD1 on the controller.
The wire for pin 5 goes to ground on the controller.

Once that is all wired up you need some power for the controller. A 9V battery will work fine for testing, or a 5V or 12V supply. Wire the positive up to the "DC in" and the ground wire to the lower GND input on the controller.

I used a pair of Power-over-Ethernet (PoE) adapters for this install. I powered both my RPi2 and the weather controller off 5V, I made up an adapter for the remote end to split power between them. Since this will be in the elements I used shrink tubing to make the connection tidy and more weather resistant. Even though this will all be in a weather tight box, it doesn't hurt to add extra layers of protection in case there's a leak.

Last but not least, the 5V supply for the RPi2 is fine to power both devices. In fact, you can cut the microUSB connector off and use that on the remote end of the PoE adapter.

Step 5: Verify You Can Read in Data From the Weather Station

Now you should be able to power up the RPi2 and the controller. Once they are both powered up, use minicom to verify communication is working. We had to reflash the firmware in our ADS-WS1 controller before it would work correctly. There is an interactive serial interface on the controller which may require configuration. Argent maintains a wiki for the controller which includes the commands you can send to the unit:

http://wiki.argentdata.com/index.php?title=ADS-WS1...

Once the controller is sending out regular data try using the weather.sh script. That should confirm that you are getting intelligent data out.

Step 6: Prep the Gear for Outdoor Use

Now you need to put everything into some type of container for outdoor container. Technically you should build a Stephenson screen to ensure proper outdoor temperature readings. The temp and humidity sensors are inside the weather controller box (with an opening for readings).

http://en.wikipedia.org/wiki/Stevenson_screen

I used a PVC NEMA 4" water tight enclosure though for now. The downside is that we won't get humidity readings and day-time temp readings may be increased by 10-15 degrees F. At a future date we plan to build a Stephenson screen to get accurate readings.

Step 7: Get It All Mounted Outdoors

I mounted ours on a mast with a horizontal bar so I could mount multiple antennas on the one pole. The box below the horizontal pole is the NEMA enclosure with the weather controller and the RPi2.

Step 8: Lightning Surge Supression

Since this device is outdoors and elevated in height I recommend using some kind of electrical surge suppressor on your outdoors ethernet run. If there's any kind of electrical surge you don't want to take a chance of to fry every device on your indoor network. This won't protect from a direct lightning strike, but it will keep anything short of that from causing you head-aches. Also it's important that if your surge suppressor has a separate ground wire that it be connected to a real ground. Some suppressors use the ground of an AC outlet which is fine. If the ground is not hooked up it does no good as there is no place to shunt any surge to.

Step 9: Power It All Up and Verify the Install

Plug in your power and your ethernet. Fire up your web browser and point it at your RPi2. The default install for weewx setups up the web directory /var/www/weewx on your filesystem, if you browse to http://192.168.1.x/weewx you should see your weather data.

That's it!

Share

    Recommendations

    • Audio Contest 2018

      Audio Contest 2018
    • Optics Contest

      Optics Contest
    • Electronics Tips & Tricks Challenge

      Electronics Tips & Tricks Challenge

    25 Discussions

    0
    None
    ramjd238

    Question 7 weeks ago on Step 5

    how to reflash the ADS-WS1. I believe there is nothing being transmitted from the weather station to my Raspberry Pi. Please help.

    My sudo screen /dev/ttyUSB0 is empty.

    Please do not hesitate to ask for additional info

    12 more answers
    0
    None
    ramjd238ramjd238

    Answer 5 weeks ago

    @dosman:

    I have figured it out. reflashed the firmware, used the right cable, and when problem still persisted Argent sent me a new device because there was hardware failure in the original one. It works as expected now.

    I would just like to say thanks for your time and support.

    Cheers,

    Ram

    0
    None
    dosman33ramjd238

    Reply 7 weeks ago

    I'm not sure what you mean by "My sudo screen /dev/ttyUSB0 is empty". Try "ls /dev/ttyUSB*" and make sure your serial2USB adapter shows up when plugged in. Verify it goes away when removing it as a double-check to make sure you have the correct device. Once the serial2USB adapter shows up correctly, use minicom to verify connectivity. Launch it with "minicom -s" and configure the serial port first - change the device name and path if needed in the config. Change the baud rate to 2400. The Argent wiki linked in the article has commands you should be able to use. If all that fails, double check your wiring from the serial2USB to the ADS-WS1 (gnd, TX, RX).

    0
    None
    dosman33dosman33

    Reply 7 weeks ago

    Also, it's possible your serial2USB adapter has a different name, it could be /dev/ttyACM0 or something else even.

    0
    None
    ramjd238dosman33

    Reply 7 weeks ago

    Please see the attached images. I have tried and verified all the points mentioned above.

    "screen" is similar to "minicom" I used initially. But never mind. Below are the troubleshooting steps I have done:

    1) Checked the wiring from ADS-WS1 to the Pi (I have used a male DB9, and a Female DB9 to USB cable to make this connection). Pin 2 of Male DB9 is connected to RX1 of ADS-WS1. Pin3 of DB9 to TX1 on ADS-WS1, and pin 5 to GND. Is this correct????

    2) Plugged and unplugged the USB to see the connection is successful. I can confirm that ttyUSB0 is the device indeed and ACM0 and ACM1 are my wifi router and solar charge controller.

    Can you please look at the images and let me know if they are of any help? Am I supposed to see any light indication on the weather station itself?

    Thanks for you time and I really appreciate your support with this.

    3.JPG4.JPG5.JPG1.JPG2.JPG6.JPG
    0
    None
    dosman33ramjd238

    Reply 7 weeks ago

    Your TX and RX pins are swapped:

    From the vantage point of the DB9 connector on the USB adapter:
    The wire for pin 2 goes to TXD1 on the controller.
    The wire for pin 3 goes to RXD1 on the controller.
    The wire for pin 5 goes to ground on the controller.

    0
    None
    ramjd238dosman33

    Reply 7 weeks ago

    I really wished that was problem. But I did wire up the way you mentioned initially and ended up with the ones I have explained in previous reply.

    Do you have access to your weather station now?

    If so, can you or someone who has access to it, run the "sudo cat /dev/ttyUSB0" and share the screenshot of the output please?

    I'm not sure what I am looking for to if confirm the Raspberry Pi is receiving the data indeed. Do you know how I can check that?

    I did not find any support or documentation for this on the web.

    Thanks,

    Ram

    1
    None
    dosman33ramjd238

    Reply 7 weeks ago

    You asked if your wiring was correct as you had it listed, and what you listed was incorrect which I noted. When having difficulties it is always important to go back and recheck our most basic assumptions, such as: power. Use a volt-meter to verify your power supply for the controller is working under load. Double check that the supply is putting out the correct DC voltage and not AC, and double check it's not wired backwards.

    If you have access to an oscilloscope you could hook that up to the TX line on the station to see if anything is happening at all. It should spit out some data at power on at a minimum. My experience is that 'cat'-ing tty devices can have mixed results, if it has worked for you in the past that great, otherwise I would not trust that as a reliable indicator here. Use a proper terminal emulator like screen or minicom. Since you prefer screen, try this tutorial to see if you can force a connection at 2400 baud (8n1):
    https://www.cyberciti.biz/faq/unix-linux-apple-osx...

    There will be nothing "receiving" data on the RPi from the weather station unless there is a program (like WeeWX) or a terminal emulator running against the serial port.

    Our weather station is physically disassembled because our hackerspace moved recently, it will be some time before I'm able to get it installed again. It's also possible your unit is dead. I would contact Argent for further assistance. I'm heading out of town for a while so I won't be able to provide further assistance until next week. Good luck.

    0
    None
    ramjd238dosman33

    Reply 7 weeks ago

    Thank you so much. I really appreciate your support.

    I will get in touch with Argent to find out more as I see the light on my weather station blinking red right now. It used to blink green in the beginning.

    Have a safe weekend.

    Cheers.

    0
    None
    ramjd238ramjd238

    Reply 6 weeks ago

    Hi dosman33,

    I think I am almost there in having this up and running but stuck at the output format from the weather station. When I use minicom to connect via the settings as shown in the attached pictures, I receive some random data but not in Peets Bros format? have you had this issue ever? Or can you suggest any troubleshooting ideas?

    I think this will fix all the issues. I really appreciate your help.

    Thank you.

    1.JPG2.JPG
    1
    None
    dosman33ramjd238

    Reply 6 weeks ago

    This is usually a symptom of the baud rate being off. You have the correct baud rate for the controller set in the settings pic though. You might try some others even though it is supposed to be 2400.

    0
    None
    ramjd238dosman33

    Reply 6 weeks ago

    Thanks for the reply Dosman33.

    So, I connected the controller to windows pc and tried to read the data using WxConfig.exe as suggested by Argent. Unfortunately that didn’t work either with error message “Blank firmware detected, or reload selected. Please select firmware source”.

    Hence, I tried to upload the latest firmware from the Argent wiki site but I have the result as “Invalid address” See the attached screenshot.

    Can you tell me how you have loaded firmware to ADS WS1?

    26607C61-BD17-4DE4-A8AD-63ADBA70BA4D.jpeg
    0
    None
    ramjd238ramjd238

    Reply 6 weeks ago

    Just to inform, I've tried both "File" and "Internet" options. While "Internet" would give me a different error though.

    0
    None
    Ducksy

    Question 9 months ago on Step 4

    Hi Again, you do not show the computer connection, I assume the cat cable is connected to a usb port in the Computer or are you using a ready made receiver for the transmitted weather information.

    Yours truly David.

    1 more answer
    0
    None
    dosman33Ducksy

    Answer 9 months ago

    Hi there,
    The weather controller (the white Argent box) is connected to the "computer" via the USB to Serial adapter (the computer in this case is the RaspberryPi). The RPi is connected to a network inside the building over CAT5 cable. The software I recommended to run on the RPi is WeeWX which sets up a web server and other packages needed to interpret the weather data coming off the weather controller. You view the data with a web browser over the network from a different computer.

    Also, I ran other wires from the TNC connections of the weather controller, hopefully this was not confusing. The weather controller has other functions for ham radio use which I did not cover as it was not the focus of the article.

    I hope this answers your question.
    Thanks!

    0
    None
    Ducksy

    9 months ago

    Good Day Great project. I am interested in building, one question, what is the reason for using a USB to Serial connector just to connect the control and ground wires, I have limited knowledge on wiring, cannot you hook up the wires direct from the USB Cable ?.

    All the best David.

    1 reply
    0
    None
    dosman33Ducksy

    Reply 9 months ago

    Greetings,

    If I'm understanding your question: I believe you are asking if it's required to use the serial cable I cut up in order to connect to the USB-to-Serial adapter?

    I believe I already had a serial cable on hand (with DB9 connector) which I had already cut for another purpose. However, the other reason is that this is an outdoor installation which may get knocked around quite a bit. I wanted a very sturdy connection which would not come loose. There are other ways to do this though, this is just the way I did it.

    I hope this is helpful.

    Thanks,
    -dosman

    0
    None
    DarwinF

    3 years ago on Introduction

    this is very cool, i think i can make my thesis, with this and your help, thank you so much for this ,you know this is my project,please help me if ever i mistakes. thanks

    0
    None
    ArtF

    3 years ago on Introduction

    Looks like my Ambient Weather setup minus the temp, unless it's run somewhere else. The one thing I hate about my unit is it overstates the temps on hot days due to the crappy radiator it comes with. There is a larger replacement unit, but it looks like it is crap too based on reviews, and the base unit seems to freeze up when the buffer starts to get full...

    Does this setup remove the need for my windows computer and Ambient display unit?

    1 reply
    0
    None
    dosman33ArtF

    Reply 3 years ago on Introduction

    This unit has an on-board webserver. Also the WeeWX package supports easy browsing by smartphones too. You need either a computer or a phone to view the data. I don't see that WeeWX supports any Ambient weather stations yet, but it looks like Ambient possibly sells other brands of stations. You can check here:
    http://www.weewx.com/hardware.html

    Also I would suspect you could make a second radiation protector for your temp sensor which would fit over top of it and would help get more accurate temp readings. It might not look pretty is all.

    Thanks!