A while ago I bought one of these kits which included an Arduino clone and a Roving Networks wifi mdule. It is meant to be the cheapest way to get the Arduino onto a wifi network and hence send data out to the world. This blog post is my notes on getting it all working and any issues that I had. This might also be useful to people trying to get this device working with the new Cosm website, rather than the old Pachube which is used in the tutorial I followed, although the API (the method of sending data) is the same.
After adding a temperature sensor (see my previous post on reading temperaure), I needed to set up a feed on my Cosm account and use the key for this feed to program into the Arduino. I used a key which was allowed to ‘read, update, create’ although the only function required will be to update (or PUT as it used to be called).
I saved the key for use in the arduino programming. I also created two datastreams, one called ‘0’ and one called ‘1’. These will display data I will send to them.
I downloaded the latest version of John Crouchley’s WiFly code. It is worth noting that this must be compiled and uploaded using the latest Arduino 1.0 IDE. There have been a number of changes to the Ethernet libraries, hence the code does not work on Arduino 0022 IDE. Save the files to your ‘libraries’ folder within your sketchbook. Open the Arduino IDE and you should have a number of examples under the WiFly tab.
Open ‘WiFly_PachubeClient_Ciseco’ and have a look at it. There are two pages, one with the main code and a additional page called ‘Credentials.h’. You must put the data specific to your set up into ‘Credentials.h’. This includes:
- WiFi network info (SSID and network password)
- Pachube/Cosm key
You can create one by logging in, clicking your details and clicking ‘Keys’. Follow the tutorial mentioned above for more details.
- Pachube/Cosm feed ID
The feed ID can be found by clicking on the feed you have created and then checking the http address. This will include the feed ID in the format: https://cosm.com/feeds/XXXXX where XXXXX is the feed ID you need.
This compiled correctly and uploaded. The example is designed to read data from the analogue 0 pin and upload to Cosm.
I wanted to read data from a temperature sensor (as shown in this article). So I created new example code which reads a DS18B20 1-wire temperature sensor which is attached to pin 6. This data is then fed to your Cosm feed.
The Arduino 1.0 code can be downloaded here. You will need to fill in the Credentials.h file with the relevant data for your network/Cosm feed.
If you are interested the test temperature feed is available for public viewing here. The data might be a bit sporadic as I’m still working on the unit, which will eventually be a WiFi connected weather station, with temp, humidity, windspeed and irradiance…..
You can also easily embed the code into your website using a line similar to, but replacing ‘504’ with your feed ID and ‘1’ with your data stream ID:
<img src="http://www.pachube.com/feeds/504/datastreams/1/history.png" alt="alt" />
Data from my stream is here, this is temperature in my workshop (ignore the weird testing numbers at the beginning):