Monday, August 06, 2012

Logging multiple sensors to Cosm with Arduino

I'm no rocket scientist (congratulations NASA btw), but when I started out with my EtherTen (ethernet enabled arduino) i was amazed how easy it was to get internet data logging happening.


I first started with the example sketch in the Arduino IDE, but i fell down when i discovered that the example code only supports one sensor, and I wanted two (indoor and outdoor temp sensors).  Here's what i did to get two sensors running:
  1. Connected two thermistors using 10k pad resistors to my Arduino pins A0 and A1 as per the example.
  2. I created an account with cosm and had it generate me an api key etc.  Despite looking quite lovely, that site seems a little unintuitive, but stick with it; it will make sense after awhile.
  3. Create a new Arduino device/feed and copy the example sketch it provides you.  Note your API key and FEEDID.
  4. Create a new sketch in the Arduino IDE but instead of using their example (which will work fine for one sensor) use the sketch below.
  5. Substitute in your API key and FEEDID.  
  6. Change IPAddress ip(10,0,1,20); to suit you network.  You can use dhcp by simply following the layout from the example CosmClient sketch in the IDE.
  7. Finally change the name of your sensors from Inside, Outside, to something sane for you.
  8. Compile the code, upload to the Arduino etc and you should be good to go.
I have not yet however managed to get cosm to allow me to stack two data ranges on the same chart.

No comments: