MCP3008 + COSM vs. DHT + googledocs

by oytserphil on Tue Jan 01, 2013 5:35 pm

Dear Adafruit Community,

First off, thank you for existing. Much love.

Secondly, I received a grant and need to construct an environmental stability chamber, which I am hoping to use RPi to help me track and regulate the chamber functions (temp, humidity, and air flow).

As such, I have been researching your tutorials, and both the MCP3008 + COSM option and the DHT + google docs options have caught my eye. I have two questions regarding them:

1. I really want to use COSM, but can find no analog humidity sensor on your website. Could you recommend one that would be compatible with MCP3008?

2. I really like the DHT combined temp and humidity digital sensor. Is there anyway to use the data it generates with COSM?

If the answer to #2 is yes, then I would prefer that route to pursue. Any input you have would be much appreciated!

Again, much love,

OysterPhil
oytserphil
 
Posts: 1
Joined: Fri Dec 07, 2012 10:16 pm

Re: MCP3008 + COSM vs. DHT + googledocs

by gigamegawatts on Fri Jan 04, 2013 2:00 pm

Hi,

I've been running Python code on the Pi to post DHT22 data to Cosm. The Python code is part of a work-in-progress program that involves an LCD display and umpteen classes, but here is the part that posts to Cosm (nee Pachube). (NOTE: the leading tabs have been stripped out by the forum software.)

import logging
import urllib2

. . .

# fill in your feed ID here
PACHUBE_FEED_ID = "12345"
# fill in your API key here
PACHUBE_API_KEY = "xxxxxxxx"

def sendToPachube(dataPoint, floatValue):
# Note - the following codes uses the V2 Pachube API and CSV data format
url = 'http://api.pachube.com/v2/feeds/' + PACHUBE_FEED_ID + '/datastreams/' + dataPoint + '.csv?_method=put'
# HACK round to 3 decimal places and drop trailing zeros : technically not needed, but makes Pachube output nicer looking
data = ("%.3f" % floatValue).rstrip('0').rstrip('.')
headers = {'X-PachubeApiKey': PACHUBE_API_KEY}
req = urllib2.Request(url, data, headers)
try:
response = urllib2.urlopen(req)
except urllib2.HTTPError, e:
logging.exception('Error code ' + str(e.code) + ' sending to pachube, datapoint ' + dataPoint)
return False
except urllib2.URLError, e:
logging.exception('Reason code ' + e.reason + ' sending to pachube, datapoint ' + dataPoint)
return False

The 2 parms are the Cosm datapoint ID and the temperature or humidity value. (e.g. sendToPachube("OfficeHum", 38.745)). This code is basically the same as what I used in this project: http://www.gigamegablog.com/2011/10/29/ ... -hat-trick. The above code needs to have the leading tabs inserted or it won't run, so if you want to see the original code or the full application it is from, you can download the Python code from the link in that article.

The only analog humidity sensor I own is one I bought from Seeedstudio, and they no longer carry it: http://www.seeedstudio.com/depot/humidi ... ?cPath=190. Like most analog sensors, calibration was a pain. I'd recommend you stick with digital sensors unless you are using a device that doesn't support them (like an Xbee).

Dan.
gigamegawatts
 
Posts: 6
Joined: Sun Mar 01, 2009 8:24 pm