Saturday, September 15, 2012

C# Arduino ThingSpeak and COSM

I bit the bullet and put together a C# app to read the serial from my Arduino weather station and send it to COSM (Pachube) and Thing Speak.  The Ethernet shield library for the Arduino has memory problems and with all the other things going on in the Arduino sketch it locks up after a few minutes. That part of the project is on the back burner for a while

I had tried a few times before to get a serial monitor between the Arduino and the computer using various libraries and languages.  All to no avail.  However if you dig around on the net long enough you can get libraries and code that others have used and cobble it together to get the job done.

I found some Rs232 code here.   I found a ThingSpeak class here. I found some COSM code here. Cobbled it together, got it working and put it up on Google Code.

Believe it or not - Google code was the hardest part - Had to install TortoiseHg/Mecurial and figure that all out and then figure out how to get it into Google.  Let me just say if you want to do the same - it works backwards from what you think.  Build the Google Repository - then clone it to your local machine, copy your source there and push it back to Google.

You have to configure ThingSpeak manually, The settings are a simple check-box for each new graph, and you push the data as field1, field2e.t.c.  However a nice thing about COSM is that it picks up what you send to your channel. and auto creates a data-set to graph.  I plan to exploit that a little more when I get the Radios working again and have sensors all over inside and outside the house.

Please excuse the code - It is incredibly raw, and it will take some time to massage it into reusable classes.

I found some interesting .NET classes for Gauges here and here but haven't taken the time to plug the code in yet.