Wow, that should be simple. So I post the following commands and responses;
(I putty/SSH into my terminal home directory)
jack@jacksrpi31 ~ $
lsAdafruit-Raspberry-Pi-Python-Code bcm2835-1.8 Desktop hello_.txt
arduino-1.0.2 bcm2835-1.8.tar.gz gspread sketchbook
jack@jacksrpi31 ~ $
sudo ./Adafruit_DHT 22 22[sudo] password for jack:
sudo: ./Adafruit_DHT: command not found
(I expected this to fail, so I go to the directory that Adafruit created (
http://learn.adafruit.com/dht-humidity- ... cs-logging)
jack@jacksrpi31 ~ $
cd Adafruit-Raspberry-Pi-Python-Codejack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code $
sudo ./Adafruit_DHT 22 22 sudo: ./Adafruit_DHT: command not found (again I expected this to fail)
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code $
lsAdafruit_ADS1x15 Adafruit_I2C Adafruit_MCP4725
Adafruit_BMP085 Adafruit_LEDBackpack Adafruit_PWM_Servo_Driver
Adafruit_CharLCD Adafruit_LEDpixels README.md
Adafruit_CharLCDPlate Adafruit_MCP230xx
Adafruit_DHT_Driver Adafruit_MCP3008
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code $
cd Adafruit_DHT_Driver ( so I went here...)
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver $
lsAdafruit_DHT Adafruit_DHT.c Adafruit_DHT_googledocs.ex.py dht1.py Makefile
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver $
sudo ./Adafruit_DHT 22 22Using pin #22
Data (40): 0x1 0x68 0x0 0xf3 0x5c
Temp = 24.3 *C, Hum = 36.0 % (and this works)
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver $
python dht1.py (and I try my test code and it fails the same way.)
Traceback (most recent call last):
File "dht1.py", line 44, in <module>
output = subprocess.check_output(["sudo ./Adafruit_DHT", "22", "22"]);
File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
What directory should I expect
output = subprocess.check_output(["sudo ./Adafruit_DHT", "22", "22"]); to work from?
Is it possible to make the
"sudo ./Adafruit_DHT", "22", "22"]) from my home directory?
This is the code that fails in WebIDE, as well as from my home-Adafruit directory.
- Code: Select all
import subprocess
import re
import sys
import time
import datetime
import gspread
# ===========================================================================
# Google Account Details
# ===========================================================================
# Account details for google docs
#email = 'xxx'
#password = 'xxxx'
#spreadsheet = 'xxxxxx'
# ===========================================================================
# Example Code
# ===========================================================================
# Login with your Google account
#try:
# gc = gspread.login(email, password)
#except:
# print "Unable to log in. Check your email address/password"
# sys.exit()
# Open a worksheet from your spreadsheet using the filename
#try:
# worksheet = gc.open(spreadsheet).sheet1
# Alternatively, open a spreadsheet using the spreadsheet's key
# worksheet = gc.open_by_key('0BmgG6nO_6dprdS1MN3d3MkdPa142WFRrdnRRUWl1UFE')
#except:
# print "Unable to open the spreadsheet. Check your filename: %s" % spreadsheet
# sys.exit()
# Continuously append data
while(True):
# Run the DHT program to get the humidity and temperature readings!
output = subprocess.check_output(["./Adafruit_DHT", "22", "17"]);
print output
matches = re.search("Temp =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
temp = float(matches.group(1))
# search for humidity printout
matches = re.search("Hum =\s+([0-9.]+)", output)
if (not matches):
time.sleep(3)
continue
humidity = float(matches.group(1))
print "Temperature: %.1f C" % temp
print "Humidity: %.1f %%" % humidity
# Append the data in the spreadsheet, including a timestamp
# try:
# values = [datetime.datetime.now(), temp, humidity]
# worksheet.append_row(values)
# except:
# print "Unable to append data. Check your connection?"
# sys.exit()
# Wait 30 seconds before continuing
# print "Wrote a row to %s" % spreadsheet
time.sleep(30)