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
auth = twitter.OAuth("your", "twitter", "oauth", "keys")
t = twitter.Twitter(auth=auth)
#open and read the tweet.txt file produced by log2300
file = open("log2300.txt","r")
log2300 = file.read()
#chop up the string to get only the basics we are interested in
words = log2300.split()
tweet = "Forecast " + words + " : Wind " + words + "mph " + words + " : Baro " + words + "hpa " + words + " : Temp " + words + "c" + " : Rain " + words + "mm " + " : Humidity " + words + "%"
#tweet the content of tweet.txt
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
Forecast Sunny : Wind 0.0mph E : Baro 1016.100hpa Rising : Temp 20.1c : Rain 0.00mm: Humidity 45%
— RedwoodWeatherUK (@RedwoodWeather) June 13, 2012
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