0

DHT22 Program won't read sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DHT22 Program won't read sensor

by beeteam on Mon Sep 25, 2017 6:15 pm

Hello,

I am trying to read a dht22 using my beaglebone black. I am using the Adafruit_Python_DHT program. When I run the code it doesn't do anything is just goes back to the command line. I put in print screens in various parts of the code to see where it is failing. It appears to fail at the humidity, temperture = Adafruit_DHT.read_retry(sensor, pin) line of the code. My sensor is on p8_10. If I put in a different pin number in the code say P8_10 it will go through the program and give me the error if it can read the sensor. (Failed to get reading. Try Again!). As soon as I change it back to the GPIO the sensor is on and run the code it just goes back to the command line.

Thanks,

Cory

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by beeteam on Tue Sep 26, 2017 9:58 pm

I have a debugger installed now and this is the output it gives.

File "./humidtest.py", line 39, in <module>
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
File "build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py", line 94, in read_r etry
File "build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py", line 81, in read
File "build/bdist.linux-armv7l/egg/Adafruit_DHT/Beaglebone_Black.py", line 201 , in read
TypeError: cannot concatenate 'str' and 'tuple' objects

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by drewfustini on Fri Sep 29, 2017 9:34 pm

Hi, sorry for the delay, I've been traveling recently.

Could you please paste or attach humidtest.py?

I will then attempt to reproduce the issue.

Also please paste output of the following commands:
cat /etc/debian_version
cat /etc/dogtag
cat /proc/cmdline
uname -a

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: DHT22 Program won't read sensor

by beeteam on Sat Sep 30, 2017 8:43 am

#!/usr/bin/python

# Copyright (c) 2014 Adafruit Industries
# Author: Tony DiCola

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import Adafruit_DHT
print"test"
# Sensor should be set to Adafruit_DHT.DHT11,
# Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.
sensor = Adafruit_DHT.DHT22
print"test1"
# Example using a Beaglebone Black with DHT sensor
# connected to pin P8_11.
pin = 'P8_8'
print"test2"
# Example using a Raspberry Pi with DHT sensor
# connected to GPIO23.
#pin = 23

# Try to grab a sensor reading. Use the read_retry method which will retry up
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
# Note that sometimes you won't get a reading and
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# If this happens try again!
print "Test3"
if humidity is not None and temperature is not None:
print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidit$
else:
print('Failed to get reading. Try again!')

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by beeteam on Sat Sep 30, 2017 8:48 am

Version 8.8
Beagleboard.org Debian Version image 2016-05-13
console=tty0 console=ttyO0,115200n8 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait coherent_pool=1M quiet
Linux beaglebone 4.4.9-ti-r25 #1 SMP Thu May 5 23:08:13 UTC 2016 armv7l GNU/Linux

Thanks for the help

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by drewfustini on Sun Oct 01, 2017 3:58 am

I'd like to verify the mode of the pin you are using. Please paste the output of these commands:

cat /sys/devices/platform/bone_capemgr/slots

config-pin -q p8.8

config-pin -q p8.10


Also please attach a photo of the wiring.

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: DHT22 Program won't read sensor

by beeteam on Sun Oct 01, 2017 8:07 am

cat: slots: No such file or directory
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-W1-P9.12

When I tried the pin config statement this is the response

P8_08 pinmux file not found!
cape-universala overlay not found
run "config-pin overlay cape-universala" to load the cape
ccauvier@beaglebone:~$ config-pin -q p8.10
P8_10 pinmux file not found!
cape-universala overlay not found
run "config-pin overlay cape-universala" to load the cape

I know the wiring is good. I attached it to my arduino and got it sending out both humidity and temperature to the serial screen.

I have pin one of the sensor as vcc. pin two data, pin 4 gnd and a 10k resistor between the data and vcc lines.

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by beeteam on Sun Oct 01, 2017 8:22 am

I have a ds18b20 installed and running on my beaglebone at the moment. I am trying to get a ds2483z working. In the meantime I was going to use the dht22. Does the beaglebone gpio pins need to have an overlay as well? I made a large assumption that the pins would be defaulted to gpio.

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by drewfustini on Sun Oct 01, 2017 1:26 pm

Is it P8_08 or P8_10 that you had the DHT22 connected to?

This file will show the current pinmux mode for each pin:
sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins

This file will indicate the GPIO number for a given pin label (such as P8_08):
sudo cat /sys/kernel/debug/gpio

Here is the output for the two pins mentioned above:
root@beaglebone:/sys/kernel/debug# grep P8_10 gpio
gpio-68 ( |P8_10 ) in lo

root@beaglebone:/sys/kernel/debug# grep P8_08 gpio
gpio-67 ( |P8_08 ) in hi


The mode for gpio 67 and 68 can then be found with:
debian@beaglebone:~$ sudo cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pins |grep 'pin 6[78]'
pin 67 (44e1090c.0) 00000028 pinctrl-single
pin 68 (44e10910.0) 00000030 pinctrl-single


The possible modes for each pin are listed on this eLinux wiki page

To use config-pin, the cape-universala overlay should be loaded. Your /boot/uEnv.txt file should have something similar to:
Code: Select all | TOGGLE FULL SIZE
uname_r=4.4.84-ti-r120
cmdline=coherent_pool=1M net.ifnames=0 cape_universal=enable
cape_enable=bone_capemgr.enable_partno=cape-universala


Alternatively, I see that your Debian image is from 2016, so you may have better results with using the latest BeagleBoard.org Debian image: Debian 9.1 2017-09-21 4GB SD IoT.

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: DHT22 Program won't read sensor

by beeteam on Mon Oct 02, 2017 3:26 pm

ok thanks for your help. Will give me something to work out over the next couple days.

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by beeteam on Sat Oct 07, 2017 9:15 am

Hello,

I managed to get back to working on my circuit. When I try to load the DM-GPIO-Test cape into the slots I get this error in the sys/log.

Oct 7 10:08:43 beaglebone kernel: [1010418.962007] bone_capemgr bone_capemgr: part_number 'DM-GPIO-Test', version 'N/A'
Oct 7 10:08:43 beaglebone kernel: [1010418.962077] bone_capemgr bone_capemgr: slot #16: override
Oct 7 10:08:43 beaglebone kernel: [1010418.962120] bone_capemgr bone_capemgr: Using override eeprom data at slot 16
Oct 7 10:08:43 beaglebone kernel: [1010418.962165] bone_capemgr bone_capemgr: slot #16: 'Override Board Name,00A0,Override Manuf,DM-GPIO-Test'
Oct 7 10:08:43 beaglebone kernel: [1010418.963252] __of_adjust_tree_phandle_references: Illegal property (size) 'fixup' @/__local_fixups__
Oct 7 10:08:43 beaglebone kernel: [1010418.972838] bone_capemgr bone_capemgr: slot #16: Failed to resolve tree


Have you come across this before and do you have a suggestion I may try? I updated the compiler but still no success.

Thanks,

Cory

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by beeteam on Sat Oct 07, 2017 10:04 am

I also tried to load the cape-universala but I can't load it and the one wire cape at the same time.

beeteam
 
Posts: 15
Joined: Mon Sep 25, 2017 5:59 pm

Re: DHT22 Program won't read sensor

by drewfustini on Sun Oct 08, 2017 1:36 pm


drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: DHT22 Program won't read sensor

by drewfustini on Sun Oct 08, 2017 1:50 pm

That error is usually happens when the device tree compiler (dtc) is out of date:
Oct 7 10:08:43 beaglebone kernel: [1010418.963252] __of_adjust_tree_phandle_references: Illegal property (size) 'fixup' @/__local_fixups__


From the bb.org-overlays,
Verify you have the latest (patched) dtc version: (this is only for v4.4.x+ for v3.8.x dtbo's use the older version)

Please run the following command and paste the output here:
Code: Select all | TOGGLE FULL SIZE
dtc --version

Here is what I get when running dtc --version on Debian Jessie 8.9 with Linux 4.4.84-ti-r120 kernel:
Version: DTC 1.4.4

drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Please be positive and constructive with your questions and comments.