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





The Weather with Raspberry Pi – unsettled but brightening up later

9 06 2012

Well, my Raspberry Pi weather station project has been stumbling along. So, first, a little update on where I am at with it.

pywws doesn’t work with my weather station, ws2350, not unexpected and a quick chat with its author confirmed it. There are a few other weather enthusiasts out thee who are trying to get it working on the RPi so check on the forums. I will be keeping an eye on progress as getting basic comms working is a common problem, as you will see….

Open2300 has been most successful at this point, its a simple set of programs that will obtain and decode the weather station data and help you use it, there is even a program that will update Weather Underground for you. Compilation on RPi did kick out some warnigns, but I had similar warnings when I compiled it on Ubuntu. The bad news, I am still not able to confirm this works on RPI, because…

Serial/USB converters – as you would expect, take two well defined standards, the latter of which was ushered in as the replacement for the former and connect them together, yeah, it was never going to just work was it! Lets be clear this is NOT a RPi issue, it’s bigger than that.

So my weather station, an entry level consumer product, about a hundred quid, has a serial link. It also comes with a serial to USB adapter as very few modern computers come with an old RS232 serial port. The USB adapter is well known as a source of endless data trouble with even the most reliable connections producing corrupt data from time to time.

Plugging this adapter, which identifies itself as FTDI, seems fine, its recognised but trying to run Open2300 with it hangs the RPi. hard to know which bit is at fault or if all of it is contributing. Running the same adapter and Open2300 under Ubuntu (on a PC not RPi) works fine though, the weather station data is retrieved and decoded.. Using a powered USB hub makes no difference in this case, the adapter is drawing around 25ma at most so power shouldn’t be the issue anyway.

To see if it was the weather station on the end of the wire causing the problem I dusted off a Psion Series 5 and serial cable, plugged it in to the RPi via said adapter and tried the terminal program, nothing, dead, hung RPi.

A second adapter arrived this morning, this time using the Prolifc PL2303 chipset (or rip off of), first off, as it was still sat on the desk, I plugged in the Psion Series 5 and, LIFE! The terminal app on the Psion communicated with the RPi.

Encouraged by some communications success I plugged in the weather station and tried Open2300, nothing for a few minutes then a time out of sorts. Moving the test to an Ubuntu PC produced the same disappointing result, it seems that although RPi is happy with the PL2303 the weather station is not.

So two different types (chipset) of Serial/USB converters and different failures. At this point I started to look for any other adapter types but on such cheap items expecting a datasheet is a little too much.

Clearly the combination of things is a key and finding an adapter that both the RPi and the WS2350 are happy with is critical, it could also be like looking for a very specific bit of hay in a haystack (I always thought that looking for a needle in a haystack sounded quite do abel to me, big magnet, little needle, problem solved)

It was time to start exploring alternative options and RPi is not without some, namely the GPIO header.

Next step, obtain or build an RS232 interface for the GPIO header, the good news is others are way ahead of me and it looks like it should be fairly straight forward, though I cant find anything pre-made for the RPi, yet.

After some hours trying to find out more about the issue via the RPi forums, lots of folks with similar issues, and more generally looking for Debian, Arm, FTDI and so on it would seem that the FTDI drivers are not ARM compatible, so if this is correct the FTDI based adapters are not going to work. I think them being identified by RPi when plugged in and checked means nothing at this point as that’s not using the driver it’s just listing the USB data, but I don’t know.





Raspberry Pi and the weather

29 05 2012

Ever since I heard about the Raspberry Pi project I knew that it would potentially be the ideal always on low power ‘pc’ to hook up to a weather station and fire data off to a web site. Realising that project has taken its first step with delivery of my first Raspberry Pi this week.

RaspberryPi

RaspberryPi

In outline the project is simple enough, use the Raspberry Pi device with a combination of pywws and Open2300 to read the data from my WS2350 weather station and ftp a data stream to my web site. Currently this is done using the excellent Cumulus software from Sandaysoft but this runs on a Windows based PC and finding a mini pc suitable isn’t cheap (which I regard as one of the main tenets of a hobby).

Currently my web site is built using various Cumulus bits but the principle is that Cumulus feeds a simple, structured text file every 15 seconds or so, via ftp, and the web site reads it and uses some basic JavaScript to dynamically update the page. A principle requirement of this project is that it either writes a compatible text file (in fact various text files for gauges and graphs etc) or I code a web site based converter that can take the Raspberry Pi feed and translate it.

Stage 1 will be to get the Raspberry Pi up and running with a stable OS, this should be fairly straightforward

Stage 2 will be interfacing the Ws2350 to the Raspberry Pi via USB (possibly via serial later)

Stage 3 will be seeing if pywws will run and read the ws2350, if not then some lower level investigation using Open2300 is going to be needed

Stage 4 will be to extract from Stage 3 a suitable file on a regular (cron) basis and ftp it to a web server (the web server will initially be one in my office, it may even be on the Raspberry Pi or another Raspberry Pi)

Each stage will be liberally inter spaced with as yet undefined quantities of alcohol which will be at various times proportional to success or inversely proportional to failure.

If any fellow weather geeks want to help out or just see how it goes I will try to blog progress here and no doubt on twitter via @stevewardell. If anyone has any ideas or suggestions or anything that may help this little venture I would be interested in hearing from you.

Let the hacking commence…

Update 30/5/12

Stage 1 held up a little awaiting some essential parts that I forgot to order initially then forgot again when I eventually got a shipping notice. Anyway, parts en route. I started to look in more detail at pywws and a few other similarly minded weather geeks have embarked on similar projects, so far it looks like the usb libs in the debian distro are dropping packets on the Raspberry Pi so there may be some issues there, also I still don’t know if pywws will even read my weather station at all.

In order to get things moving and determine if pywws was an option I set up on one of my Ubuntu servers in the office, after some fiddling to get the weather station recognised via usb/serial converter (Raspberry Pi has USB) and a few hours playing with pywws I’ve concluded it either doesn’t work with a WS2350 or I cannot get the right combination’s of usb libs to play with python. So pywws question passed to its author, in the meantime Open2300 checked out and compiled, a little configuration and success, a simple cron job has the weather station updating my Weather Underground site, all mostly thanks to the Open2300 code I have to say.

If I can decode the full memory map from the station with Open2300, which I think I can, then this looks like it should work out quite well, assuming it can be compiled on the RPi ofcourse





Tablets : Windows 8 – Metro @ //BUILD/

14 09 2011

Microsoft have been unveiling Windows 8 at //BUILD/ and the keynote from Steve Sinofsky was, to say the least, inspiring. //BUILD/ was about revealing Windows 8 to the developer community, showing them what it is, where it’s going and what they can expect as it launches, in its various guises.

I’m interested (here) with what Windows 8 and the Metro UI, first seen on Windows Phone 7, means in the tablet space. Or as its more accurately known, the iPad space. What really interests me here is the idea that it might be a year until we see a Windows 8 tablet, assuming this is correct, it would appear to be a catastrophic case for Microsoft, surely the tablet wars will be over in a year?

Well, perhaps that might play to Microsoft.

Right now there isn’t much of a tablet war. We have Apple’s iPad dominant and nothing looking remotely likely to get close, much less topple it. It’s a great device and it has created the market from the previous failed attempts by Microsoft, among others. The there is Android, Googles smartphone OS hacked for tablets. The first generation of devices has been poor and they are approaching end of life, the first signs of the second generation are appearing and maybe Android will get a second chance. HP killed the Touchpad and, well everyone knows what happened with that. Blackberry launched an expensive toy and cant be considered a contender in my opinion, perhaps their second generation will make up for the first. And lastly we have Amazon, rumoured to be about to enter the game, but with a small, cheaper than iPad, based on old Android, low spec device. I don’t really think Amazon is entering the same game as everyone else, maybe with a competitive device but this 7″ shopping tablet isn’t it.

Then there is Microsoft. Metro, the UI, looks very good, it brings something new to the party, but as has already been pointed out Windows Phone 7 brought Metro to our attention and that hasn’t exactly changed Microsoft’s fortunes in the smartphone space, why would it do so in the tablet space? My thought is Microsoft isn’t looking for it to revolutionise anything. Imagine in 12 months, Windows 8 tablets launch, with a decent spread of apps, using the same basic OS that’s been around for some time on the desktop, laptop and server, slowly replacing the Windows 7 (Vista, XP, etc) systems in use by 100′s of millions. The tablet space, probably still lead by Apple, has settled down, its not a war of innovation anymore, its an established market, moving along the adoption curve. There may have been a few casualties, maybe even a new contender. But when Windows 8 tablets launch across a range of manufacturers the sheer choice of devices, all bearing a familiar badge, sporting a look and feel that has had months to become familiar, may be a very compelling idea in the mind of the Early and Late Majority.

There are clear signs that Apple is trying to converge its iOS and OSX operating systems, Microsoft is doing the same thing. Google is working with Intel, Microsoft is working with ARM. In 12 months there is going to be a lot less that divides tablets than there is today.

If you can’t get into and win the war, make sure you are around to win the peace.





Google+ some more thoughts

23 07 2011

I just read  this ‘Why twitter is obsolete‘ and despite there being the usual mass of comment on Google+ and how it will or wont change the world, this one has a fact I hadn’t been aware of before.

“Twitter defines an “active user” as one who follows at least 30 people and has at least 10 people who follow him. A source with access to Twitter’s API who was quoted by Business Insider in April says that there were only 21 million people or accounts on Twitter that met the “active user” criteria.”

This is interesting and until I read it I had never considered the quality value of user metrics, just their quantative value. If this is true, and I have to say I suspect it might be, then Google+ can (and should) go for the jugular and change the game. In my opinion the Google+ UI and hence UX, while good, is lacking some simple but vital features. Right now the ‘stream’, the main feed of everyone you have circled in some way, is too noisy and circles currently don’t provide quite enough flexibility to tailor your default stream. But this is trivial to resolve for Google and many people have already commented on the 2 or 3 options to fix it, I’m sure Google will.

Another point raised in the previously mentioned article is that a lot of posts are nothing more than a teaser or snippet that then links to a fuller blog post. In fact Tweetdeck a very popular client for twitter and recently acquired by twitter, provides a tweet extender. But Google can beat this simply, it could allow you to post a full blog, direct into your stream. If Google allows for a simple two level posting mechanic, something like a summary, length restricted but including media and then a fuller extended post, hidden by default but with a clickable extend button on the post then it has in stream bloging taken care of.

twitters greatest asset in its early days, long before I wanted to use it, was its open and available API, this allowed them to build twitter and anyone to build add-ons and clients. But now twitter is much bigger, and not so open to others delivering the features it thinks (rightly or wrongly) it should be delivering. Once Google+ delivers its API we will see some of the current social media clients (Seesmic, Hootsuite, etc) including Google+, at this point its going to become apparent that twitter itself lacks in many areas compared to Google+ and it might just be a matter of time.

That time may also be a lot shorter than people think (myself included), this comparative graph of Google+ growth v’s twitter v’s Facebook, while not being a fair direct comparison, shows how rapidly Google+ has taken off (and its still invite based) and may give some indications to how volatile the social media user base is.





Cloud Music – a village looking for an idiot?

15 07 2011

Let me start by saying that right now my music is not in the cloud and although I’ve had a play with both Google Music and Amazons Locker I do not use them yet (as they are not officially available in this country yet) and Apple has yet to launch its iCloud service.

There have been a number of ‘cloud’ music services making news to some degree in the last few months, including; Amazon, Google and Apple. I’ve been doing a little thinking about these services and there are a few things I’m more curious about.

Let’s start with Apple and its iTunes in the Cloud (iCloud), my understanding of this is that it’s a great offering, all your iTunes tunes in the cloud to download and play anywhere, well anywhere so longs as it’s on an Apple product of course. Interesting thing number 1, your iTunes purchases don’t count against your iCloud limit, that’s a great sell, you’ve got 20gigs of iTunes music and you can have it all in your iCloud for nothing! But the thing that has raised most interest though is iTunes Match. For your annual fee you can get all your non iTunes music into the cloud, but without all that tedious faffing about uploading it, Apple will match your music against their library and give you a nice new 256bit AAC of your dodgy old mp3. My final point here is price, Apple, once king of charging its loving little fans silly money is continuing its iPad tactic (which you have to say is winning) of beating the competition (such as it is) on price. My music collection is vast, if I were to put half of it into Amazons locker it would cost me a fortune ($200), Apple seems to be saying it will cost me $25!

Now, Amazon. This is basically a locker service. I buy space for my music, upload it and can then play it anywhere. Well in theory I can. It’s much the same with Google Music, though I don’t think anyone knows pricing yet. Here is problem nunmber one, have you ever tried to upload a lot of data from a domestic broadband connection? You’re going to find out what it means to have a different upload and download speed and boy is it going to hurt when you are trying to upload that big music collection. It could take days if not weeks. In my opinion it’s not going to happen, you just won’t do it, do you know why? Because you already have the music, it’s on your PC, it’s on your phone. The Amazon and Google music products require me and you to upload our music and that’s a painfully slow process. Apple has the winning hand here and its not as though you needed to be a genious to figure it out.

I should state at this point that it could be better than it seems if these services use some form of de-duplication. But I don’t know if they do or will. In principle if they did then once I’ve uploaded ‘Linkin Parks – A Thousand Suns’ you shouldn’t have to. That’s a greatly simplified explanation but the point is we both don’t need to upload the same thing, so if all of my music was already uploaded by several other users, all I would need to do is have my music matched up and get access to the common tunes. Oh, wait a second, we have heard that before, that’s what Apple is doing, but its licensed to do it using its own music library.

Cost and convenience, seemingly two points to Apple.

My final point is the cost of listening to the music I’ve already paid for. Let’s assume I’ve got all the music I’m interested in on the service of my choice. I now want to play it back. Play it anywhere, that’s the idea, right? How much of your 3G data plan do you think is going to be chewed up listening to a few hours of music a week? It’s not Apple or Google or Amazon who will be charging you, it’s your mobile operator. I don’t yet know how well any of these services will cache music already played, in other words, if I play an album today do I need to have it stream all over again tomorrow. Paying my mobile phone operator to stream an album once sounds painful enough, paying every time I listen to an album sounds ridiculous. Don’t forget, I already own this music. I paid for it once. Obviously this is less of an issue at when I’m hooked up to Wi-Fi somewhere, but consider how long public access Wi-Fi , a technology already creaking under the strains of today’s content to be delivered, will remain free or usable. Sit down in Starbucks, hook up to Wi-Fi, pick up your email, check in on Foursquare and stream your music to listen to and watch it all fall down as everyone else does the same thing. So in reality, what I need to be able to do is grab the music from the cloud onto my device so I can listen to it without lining my operators pockets. We will assume their network data is up to the job, but we both know thats a big issue.

So what is the alternative? Well it’s what you already have. Your device of choice has an ever increasing amount of available storage and more is available (unless its Apple) at an ever decreasing cost. My cell phone has about 100 albums on it right now, that’s a lot of music to listen to. I’m just not sure I need, or want, it in the cloud.





Google+ some thoughts

10 07 2011

I’ve been playing around with Google+ for a few days and I am impressed and disapointed in equal measure. So far Googles latest attempt at creating a social networking platform is, without doubt, their best effort yet. It includes some new features and adds some polish to some established ones.

Right now its STILL in invite only phase, it really needs to be out of this in the next few days. Already people I know using it all agree, the biggest missing feature is their friends. What use a social networkng site with no one to be social with? What else is missing? Well a lot of things but the two they need a solid answer to very quickly are Facebook and twitter.

Everyone uses Facebook, not everyone is going to be using Google+, not even if they give away £10 with every sign up. They need a mechanism to ease people over from Facebook to Google+ and the obvious way is to allow Google+ to post into Facebook. The same is true of twitter, but thats a different party.

So why is there no tickbox in Google+ to ‘Post to Facebook’? Either Google couldnt or wouldnt, I dont buy the idea that they didnt. Its an intersting issue. Facebook are unlikely to allow any kind of posting that potentially takes away their traffic or their users. This is going to set Google+ and Facebook against each other. Facebook is established, feature rich (relatively), has an open API for developers and 750 million users. Google+ has… Circles?

So thats a knockout and a win for Facebook then, not quite in my opinion. Facebook has been on the wrong end of privacy issues time and time again and its always won because there was no alternative. Google+ is shiny and new, though I have yet to figure out why this could ever translate into a meaningful selling point, we are not talking about cars!

Ok, so what about twitter. Neither Facebook nor Google+ allow direct native posting to twitter, though there are plenty of Social Media applications that get around this, though now yet for Google+ (damn, not having that API is already a problem, isnt it!). twitter is not a competitor to Facebook or to Google+ in my opinion, they are overlapping and complimnetary. twitter is more public, its the open room big conversation. Facebook is the closed party of friends and like minded individuals. What is Google+? Well it has potential to be both, I’m minded to consider that Google and twitter could really forge a strong realtionship here.

Google+ needs to create Circles, its feature to group friends, that can be your twitter friends and your Facebook friends. I think the winning play is to play every game, social media is people, not systems. When there are no options 3rd parties fill the gaps. But if Google relies on 3rd parties, when they can eventually get hold of an API, to build features needed for Google+ survival they may find them writing for the platform that suported them first.

I think this landscape feel over crowded but I think it has room for the life and soul of the party to make an appearance. Mobile is going to be the decisive factor. So thats game set and match to Google then, after all they have Android for phones and tablets (yes, the tables are a joke, but that will change) and they launched a truly killer Google+ Android app. Game over? No.

Not by a long way. Apple has got the Google+ app to approve, I’m sure it will approve it in the next few days and I’m sure it will be great. The Facebook app sucks, on all platforms. The twitter app is fine everywhere, though nothing special. But Apple has a possible game changer about to appear.

Its widely rumoured that when Apple launches the iPhone5 later this year, with the public release of iOS5, it will alos launch a new, lower price, iPhone. Imagine an iPhone that can eat into the phone market on price, who will want to buy anything else? An iPhone that is as cool as an iPhone5, can do every thing an iPhone5 can do, but is cut down in some ways. Apple may just be about to blow up the smartpjhone market again in the same way, with the same tactic, it used on the tablet market. Make an Apple product everyone will want and make it a aprice no one can compete with.

So who wants to put money on which platform is going to have the best Faecbook and twitter apps in a few months?

Interesting, isnt it?








Follow

Get every new post delivered to your Inbox.