Tweeting the weather with a WS2350, Open2300 and Raspberry Pi

13 06 2012

Well the last day or two have brought another USB/Serial adapter and some success, the weather station (Ws2350) is now communicating with the Raspberry Pi via USB. So what was the problem and what was the solution?

The weather station is well know for being a picky little device (read non standard) about its serial comunications, you’ll find many horror stories from people who have had to link it via a USB adapter. It’s worth noting that even though I now have communications there may be further problems to come, so the side project of adding a serial port to the GPIO of the Raspberry Pi is only on hold.

Anyway the problem was having a USB/Serial adapter that both the Raspberry Pi and the weather station were happy with. Other people with similar issues have thought it may be power related as the Raspberry Pi doesn’t have a lot of power to pass to the USB, but these adapters draw less than 25mA and I tried via a powered USB hub too, it wasn’t a power issue.

Original (supplied with the weather station) FTDI adapter (FT232BM), worked with the weather station and using Ubuntu on a PC, hung the Raspberry Pi when accessed but was recognised by the Raspberry Pi when plugged in.

PL2323 Adapater, bought to try a different chipset. Raspberry Pi was quite happy with it, even hooked up a PSION Series 5 as a terminal (see this) but the weather station via Raspberry Pi or via Ubuntu on a PC did not want to play. This failure was almost certainly down to the WS2350 being picky about its adapters or possibly a non standard pin out on the adapter.

FTDI Adapter (FT232RL) I had a post about the problem at RasberryPi.org and someone confirmed that they had an FTDI device working with Raspberry Pi, a device using a newer chipset. I did some research at the chip manufacturer and decided to track down an adapter using the newer FT232RL chip, thinking that as the weather station was happy with the old FTDI adapter maybe it would be with the new one too. I found one at tronisoft.com and ordered it on Sunday evening, it arrived Tuesday am. It worked.

Now that communications were in full swing I started to hack a little bit of python code to read the Open2300 log file and tweet it, my current Cumulus software tweets the weather every hour or so and its pretty easy to tweet from code.

 

The tweet2300.py code

#
#tweet2300 Steve Wardell 2012
#
from subprocess import call
import twitter
#auth twitter
auth = twitter.OAuth("your", "twitter", "oauth", "keys")
t = twitter.Twitter(auth=auth)
t.account.verify_credentials()
#run log2300
call(["rm", "log2300.txt"])
call(["log2300", "log2300.txt"])
#open and read the tweet.txt file produced by log2300
file = open("log2300.txt","r")
log2300 = file.read()
file.close()
#chop up the string to get only the basics we are interested in
words = log2300.split()
tweet = "Forecast " + words[17] + " : Wind " + words[8] + "mph " + words[10] + " : Baro " + words[15] + "hpa " + words[16] + " : Temp " + words[4] + "c" + " : Rain " + words[13] + "mm " + " : Humidity " + words[7] + "%"
#tweet the content of tweet.txt
t.statuses.update(status=tweet)
#the end

Its not very elegant but as a quick hack it did the job.

Open2300 is a suite of programs to read data from the Ws2350 by Kenneth Lavrsen (his web site). For this quick hack we first get authorised with twitter then the Log2300 program writes (appends in fact) to a file a short data stream from the Ws2350. As I just want a file with a single data set the code above first deletes any existing log then writes a new one. The log is then read into a python variable and split into an array, the array is then mashed up into a suitable order with some additional text to form a tweet.

All very basic stuff and quite a bodge but we get a tweet

This simple script could be added to a CRON job to run every hour and keep on tweeting. Now that I’m happy with basic communications and have a little bit of code and a tweet to show for my efforts I can focus on developing some python routines to make use of Open2300’s fetch2300 program to write feeds for my web site weather.60redwood.com and the live gauges.

More posts as progress is made

About these ads

Actions

Information

8 responses

2 07 2012
Pi fan

How about using the serial port in the GPIO of raspberry pi?
The serial interface is described for example in here: http://lavalink.com/2012/03/raspberry-pi-serial-interfacing/

2 07 2012
Pi fan

Note also the second link in the post with another serial port

http://lavalink.com/2012/04/more-on-raspberry-pi-serial-ports/

19 07 2012
John Macrae

Nice work! I’m interested in the software aspects of logging the data from the wx station. Does the station open the file itself or do you have to interrogate it and write it out??

7 01 2013
Ben

I have exactly the same wish – to interface to a WS2300 weather station from my RPi using Open2300. Could you provide the name/model of the serial adapter you’re using?

Many thanks.

3 02 2013
Latisen

Care to share which model of adapter you bought to get working? Im about to try to change my 400W powerconsuming server for a Raspberry Pi (already got a couple of those to spare). Please tell me the model of the adapter so I can order one and lower my electricity bill a bit :)

3 02 2013
Steve

The one that worked was the FT232RL

11 04 2013
Todd

I have had success with a Prolific PL2303 based adapter connecting to my WS2315. I purchased a PPA 3312 for about $18 from Fry’s. Just in the last couple of days I connected it to my Raspberry Pi and used Russell Stuart’s python based WS2300 scripts with great success.

13 08 2013
Wetterstation in Baldramsdorf | Podex' Tagebuch

[…] Tweeting the weather with a WS2350, Open2300 and Raspberry Pi | Redwood Blog. […]

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




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: