loading

Step 4: Preparing Your Cosm Feed

Create a cosm account

Go to http://cosm.com and create an account.

Create an API key

Login to your Cosm account and unfold the account menu (the small diamond left to your account name). Select "Keys". 
Now press the [ + Key ] button. Generate a key with the following properties:

- Use any feed
- All access privileges

Now press "Create" and copy the new API key into a text file for future reference.

Create a feed

Go to the console menu and press [ + Device / feed ]. Select "Something else" as device type.

Use the following properties;

- No I will push data to Cosm
- A descriptive title (something like: Energy usage)

You can leave the tags empty but it is possible to use some keywords like "gas, electricity" and so on.

When the new feed is created, make a note of the feed number. You will need this later!

Edit the shell script "cosm.sh"

Open an editor like nano or vi (which ever you are comfortable with) and change the curl line as follows:

--------------------------------------------------
curl --request PUT \
     --data-binary @/tmp/cosm  \
     --header "X-ApiKey: PLACE YOUR API KEY HERE" \
     --verbose \
     http://api.cosm.com/v2/feeds/FEEDNUMBER
--------------------------------------------------

Save the file and do a test run from the commandline (enter "./cosm.sh").

--------------------------------------------------
root@raspberrypi:~# ./cosm.sh
* About to connect() to api.cosm.com port 80 (#0)
*   Trying 216.52.233.121... connected
* Connected to api.cosm.com (216.52.233.121) port 80 (#0)
> PUT /v2/feeds/61796 HTTP/1.1
> User-Agent: curl/7.21.0 (arm-unknown-linux-gnueabi) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: api.cosm.com
> Accept: */*
> X-ApiKey: Padashgdahgjhgsdjhsfdkjfskjgfkjz0g
> Content-Length: 332
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Sat, 02 Jun 2012 14:10:48 GMT
< Content-Type: application/json; charset=utf-8
< Connection: keep-alive
< X-PachubePurgeCache: t:feeds/61796
< X-Runtime: 104
< Content-Length: 1
< X-Pachube-Logging-Key: logging.j7fIUd67vzlDk5l8e06Cr
< X-PachubeRequestId: 65e5f627e1563206bf39afb8c67679ce47baff53
< Set-Cookie: _pachcore_app_session=BAh7BjLc2Vzc2lvbl9pZCIlN2I5Y2RkMzc5YTk4MWM3MjdiODUzNjQyMjdiNWRjOGU%3D--c5f8be5a6632f29b836146fa3a96ec1e5d167cb1; domain=.cosm.com; path=/; expires=Sat, 16-Jun-2012 14:10:48 GMT; HttpOnly
< Cache-Control: max-age=0
< Vary: Accept-Encoding
<
* Connection #0 to host api.cosm.com left intact
* Closing connection #0
--------------------------------------------------

The script should run without any obvious errors.

Open the cosm website and login. Open the console to see whether any values have been posted.

Cosm is now set up. You have created an API key and have created a new feed where the information is pushed to.

Automating the data logger

Cron is a nice way to schedule the data logger. Issue the crontab -e command. An editor will open with the crontab in it. I use the following schedule:

*/2 * * * * /root/cosm.sh

This will upload every 2 minutes.
Hi CPO ! <br>just a simple question... <br>i'm not so expert about curl. <br>i can't understand well the &quot;--data-binary @/tmp/cosm&quot; \ comman <br>i need to sent this string with negative, and decimal number <br> <br>i've a cron based poller that get from arduino the datas and write it into the following file /tmp/cosm/data-to-send <br> <br>cat /tmp/cosm/data-to-send <br>-1,18,12.22,-12,34,0 <br> <br>how can i send this (multi datastream ?) <br>thankyou !
Klopt het dat het juiste type van de ftdi kabel : &quot;FTDI TTL-232R (5V)&quot; is ? <br> <br>Alvast dank !
Great instruction, but... I can't figure which TFDI cable or FTDI breakoutboard to order... I can't find the breakoutboard on their site and/or do I order this cable? <a href="http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf" rel="nofollow">http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_TTL-232R_CABLES.pdf </a>Could you please send me the correct links? thanks
Look good. Will a 5 volt FTDI cable like this one also work ? <br> <br>http://www.ebay.com/itm/FTDI-FT232RL-USB-to-TTL-Serial-cable-5V-Converter-Adapter-for-Arduino-CTS-RTS-/170918433764?pt=LH_DefaultDomain_0&amp;hash=item27cb8853e4
Not sure why you used the ftdi cable. To adjust the voltage of the signal coming from the Kamstrup ? <br>You do know what the raspberry pi has a UART with its pins exposed. Right ?
Yes it has an UART, but working on 3.3v levels. Anything above 3.3v that will destroy your little friend. Also, I had the FTDI around to it seemes the next logical step :) <br> <br>The Kamstrup also features an IR port. When I get around to it, I will create a bidirectional IR device to communicate with the meter.
this is a great project! Can you talks through the process for configuring the FTDI cable to invert the RXD pin using the FT_PROG tool with a windows Machine - is that by connecting the cable to raspberry first?
Thanks for your kind comment!<br /><br />You should download the FT_PROG first at http://www.ftdichip.com/Support/Utilities.htm<br /><br />The cable does not need to be connected to the raspberry pi. After installing the FT_PROG the cable will be detected. When you start the FT_PROG, press F5 to load the cable eeprom. Now find the &quot;Invert&quot; options in the tree. <br /><br />You should only invert the RX pin there.<br /><br />After modifying, program the settings back into the cable.<br /><br />Undoing this is simply the same, only disabling the invert option :)<br /><br />Easy peasy...
Many thanks for talking us through - awesome!
BTW: If you need any further assistance, please let me know; maybe I can add screenshots to this instructable to clarify the process.
I never thought to use RPi as a data logger like this, that's a great idea and a perfect use for it. <br> <br>I just ordered mine through www.tinyputers.com so should get mine... eventually. The confirmation email said mid-August. My first project will be an advanced alarm clock. Hopefully there's some good instructables available for that once the time comes.
It's a very nice platform to work with. The Linux system has all the tools you need to easily parse the data from the meter. <br> <br>I like it a lot, if you make anything cool when you get yours, please let me know! :)

About This Instructable

27,830views

22favorites

More by cpo:Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi! Create the Arduino driven LED growbox 
Add instructable to: