I have mixed and matched Adafruit WEBIDE python code to read some ds18 sensors and a DHT22 sensor. I can successfully read and printout ds18 temps. But I am getting consistent errors while trying to read the DHT22 sensor.
(Because I am using gpio4 for the ds18, I am connecting the DHT to gpio22. After much mussing around, I am able to operate a command line Adafruit_DHT 22 22 and get good results.)
After discovering the error, I have copied the Adafruit_DHT_googledocs.ex.py python code to my home - Adafruit_DHT directory, and 'hacked-remarked' out all the code segments to talk to the googlespreadsheet' in an attempt to isolate the problem. Again, from my home-adafruit directory, I can operate a command line Adafruit_DHT 22 22 and get good results.
If I execute my modified code - dht1.py program or the official Adafruit_DHT_googledocs.ex.py code in either the webide directory or my home-adafruit directory, I get the following error;
jack@jacksrpi31 ~/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver $ sudo python dht1.py
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
the python2.7 folder and the subprocess.py file exist. I have performed a update/upgrade cycle.
Can anyone help with this problem?
Adafruit_DHT from Python
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Adafruit_DHT from Python
it cant find the "Adafruit_DHT" file - it must be in the same directory
-
- Posts: 4
- Joined: Wed Nov 28, 2012 3:22 pm
Re: Adafruit_DHT from Python
Wow, that should be simple. So I post the following commands and responses;
(I putty/SSH into my terminal home directory)
jack@jacksrpi31 ~ $ ls
Adafruit-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-Code
jack@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 $ ls
Adafruit_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 $ ls
Adafruit_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 22
Using 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.
(I putty/SSH into my terminal home directory)
jack@jacksrpi31 ~ $ ls
Adafruit-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-Code
jack@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 $ ls
Adafruit_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 $ ls
Adafruit_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 22
Using 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 = 'BANNED'
# ===========================================================================
# 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)
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: Adafruit_DHT from Python
remove the "./" from the command list in python, its probably confusing it
- alfonso82
- Posts: 2
- Joined: Sun Feb 17, 2013 6:56 am
Re: Adafruit_DHT from Python
Hi, I´m new here but I´m getting the same problem and removing the "./" did not resolve the problem, I don´t know if jack2333 got pass this or not, if you did please post your solution, and thank you.
-
- Posts: 6
- Joined: Tue Oct 23, 2012 5:08 am
Re: Adafruit_DHT from Python
I am having the exact same issue.
The problem first occurred when I switched from Raspbian to XBian.
I've tried the above suggestions but it is still throwing the following error.
I notice that the last line is different to that in OPs first post. Has anyone managed to solve this issue?
The problem first occurred when I switched from Raspbian to XBian.
I've tried the above suggestions but it is still throwing the following error.
Code: Select all
Traceback (most recent call last):
File "DHT_googledocs.py", line 44, in <module>
output = subprocess.check_output("sudo /home/scripts/dht/Adafruit_DHT", "2302", "4", shell=True);
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 629, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/