raspberry read temperature from DHT11

43 17107
Edited by tosiara at Wed Nov 5, 2014 06:44

Confirmed, this is WiringBPI issue. I have transferred from Raspbian image and built the program against that library - now all works on Lubuntu too:
  1. root@bpi:/home/bananapi# LD_PRELOAD=/home/bananapi/ ./dht11
  2. Use GPIO1 to read data!
  3. Enter OS-------
  4. Congratulations ! Sensor data read ok!
  5. RH:34.0
  6. TMP:24.0
  7. Congratulations ! Sensor data read ok!
  8. RH:34.0
  9. TMP:24.0
Copy the Code
Filed bug for WiringBPI:

I've rebuild WiringPi from the sources with my Bananian (even if it wasn't necessary).

As for the sources :

Edited by axelf at Mon Dec 8, 2014 13:46

I seem to have the same problem as tosiara using the program with the latest version of bananian.
The CPU-frequency is @ 600MHz. Is that OK? As tosiara mentioned to use of Raspian: where can I get this file?
Thanks a lot!

Edit: Hmm, with another program I found for the Raspberry Pi everything is working fine. As it is also using wiringpi I am a bit confused that it is working.

Edit: Hmm, with another program I found for the Raspberry Pi everything is working fine. As it is also using wiringpi I am a bit confused that it is working.

For some reason that another example works without resistor, but fails with pullup resistor. While the example in this thread works fine no matter if resistor is present or not.

The only issue with the code - infinite "while" loops which may hang forever if sensor does not answer. I have changed those to limited "for", like this:
  1. while(!digitalRead(pinNumber)); //wait to high
Copy the Code
changed to:
  1. #define SENSOR_TIMEOUT_LOOP 5000
  2. int wait;
  3. for (wait = 0; wait < SENSOR_TIMEOUT_LOOP && !digitalRead (pinNumber); wait++);
Copy the Code

如果没有接上拉电阻去掉这个函数 pullUpDnControl(pinNumber,PUD_UP);就正常工作了

Edited by Oleg at Sun Oct 25, 2015 12:04

Pls help me. I want to read data from dht22,BPI M1+Lubuntu , wiringPI was installed from GPIO works well ( gpio readall, tried LED test with command gpio write ).
Build some code:
-Adafruit_Python_DHT by python show me 'Failed to get reading. Try again!'
-This code show error  - checking for wiringPiSetup in -lwiringPi... no
configure: error: Fail to find wiringPi library...Where can i dowload from Raspbian image?

-code below provides incorrect data
  1. #include <wiringPi.h>  
  2. #include <stdio.h>  
  3. #include <stdlib.h>  
  4. #include <stdint.h>  
  5. #define MAX_TIME 85  
  6. #define DHT22PIN 5  
  7. int dht22_val[5]={0,0,0,0,0};  
  9. void dht22_read_val()  
  10. {  
  11.   uint8_t lststate=HIGH;  
  12.   uint8_t counter=0;  
  13.   uint8_t j=0,i;  
  14.   for(i=0;i<5;i++)  
  15.      dht11_val[i]=0;  
  16.   pinMode(DHT22PIN,OUTPUT);  
  17.   digitalWrite(DHT22PIN,LOW);  
  18.   delay(18);  
  19.   digitalWrite(DHT22PIN,HIGH);  
  20.   delayMicroseconds(40);  
  21.   pinMode(DHT22PIN,INPUT);  
  22.   for(i=0;i<MAX_TIME;i++)  
  23.   {  
  24.     counter=0;  
  25.     while(digitalRead(DHT22PIN)==lststate){  
  26.       counter++;  
  27.       delayMicroseconds(1);  
  28.       if(counter==255)  
  29.         break;  
  30.     }  
  31.     lststate=digitalRead(DHT22PIN);  
  32.     if(counter==255)  
  33.        break;  
  34.     // top 3 transistions are ignored  
  35.     if((i>=4)&&(i%2==0)){  
  36.       dht22_val[j/8]<<=1;  
  37.       if(counter>16)  
  38.         dht22_val[j/8]|=1;  
  39.       j++;  
  40.     }  
  41.   }  
  42.   // verify cheksum and print the verified data  
  43.   if((j>=40)&&(dht22_val[4]==((dht22_val[0]+dht22_val[1]+dht22_val[2]+dht22_val[3])& 0xFF)))  
  44.   {   
  45.     printf("Humidity = %d.%d %% Temperature = %d.%d °C\n",dht22_val[0],dht22_val[1],dht22_val[2],dht22_val[3]);  
  46.   }  
  47.   else  
  48.        printf("Invalid Data!!\n");
  49.         printf("Humidity = %d.%d %% Temperature = %d.%d °C\n",dht22_val[0],dht22_val[1],dht22_val[2],dht22_val[3]);   
  50. }  
  52. int main(void)  
  53. {  
  54.   printf("Interfacing Temperature and Humidity Sensor (DHT22) With Banana Pi\n");  
  55.   if(wiringPiSetup()==-1)  
  56.     exit(1);  
  57.   while(1)  
  58.   {  
  59.      dht22_read_val();  
  60.      delay(3000);  
  61.   }  
  62.   return 0;  
  63. }
Copy the Code

Any body visits this forum? For BPI+M1, python and RPi.GPIO python module:

import RPi.GPIO as GPIO
import time

usleep = lambda x: time.sleep(x/1000000.0)
pingpio = 24
maxcycles = 1000

class DHT():
        def read(self):
                return "Timeout waiting for start signal low pulse."
                return "Timeout waiting for start signal high pulse."
            cycles = []
            while (i<80):
            while (i<40):
                lowCycles  = cycles[2*i]
                highCycles = cycles[2*i+1]
                if(((lowCycles == 0) or (highCycles == 0)) and i != 39):
                    #print "error waiting for pulse "+ str(i)+ " L "+str(lowCycles)+ " H "+str(highCycles)
                    return '-'
              return st

        def expectPulse(self,level):
                    return 0
            return count

if __name__ == "__main__":
        dht = DHT()
                GPIO.setup(pingpio, GPIO.OUT)
                GPIO.output(pingpio, GPIO.HIGH)
                GPIO.output(pingpio, GPIO.LOW)
                GPIO.output(pingpio, GPIO.HIGH)
                GPIO.output(pingpio, GPIO.LOW)
                GPIO.setup(pingpio, GPIO.IN)
                res =
                    hum = int(res[:16], 2)
                    t = int(res[17:32], 2)
                    crc = int(res[33:40], 2)
                    crc1 = int(res[:8], 2)
                    crc2 = int(res[9:16], 2)
                    crc3 = int(res[17:24], 2)
                    crc4 = int(res[25:32], 2)
                    hum = float(hum)
                    t = float(t)
                    if((crc1+crc2+crc3+crc4) ==crc ):
                        print "Humidity: "+str(hum/10)
                        print "Temp:"+str(t/10)

Hi, i have been trying for a week to make that thing work on banana pi M1. I wasnt able to get any reading ether with the python scripts or the c programs. I have tried to set up my dht11 sensor on an arduino uno and it worked right away.  I have bananian installed but i also have tried and with raspbian V4. No luck with anything. The gpio pins of my banana are working because i have my doorbell set up on them. Does anyone have any suggestion?

there lal jersey  is nfl chiefs jerseys  always ray ban sunglasses  frustrating when, ralph lauren outlet online  do not swarovski  be michael kors  afraid, jordan  he tory burch  woke chi hair  up north face jackets  to moncler jackets  start cheap oakley  over, free run  smiled, belstaff mens jackets  and ralph lauren uk  so michael kors  spring!March true religion jeans outlet  fireworks, coach factory outlet  pink replica handbags  Ying ralph lauren factory store  and leaves, reebok  spring birkenstock outlet  green nuggets jersey  south. north face  Orioles ray ban  season long grass, cheap michael kors  flowers, moon longchamp outlet  breeze, oakley sunglasses cheap  a jordans for sale  good  spring nike air max 2014  beauty volumes. woolrich clearance  Even polo ralph  if oakley outlet online  there ralph lauren  is oakley vault  rain, mlb jerseys  and skechers  if nike  the air force  smoke levis outlet store  fog, a small nike canada  town prada shoes  south coach outlet online  of ray ban  the dip gucci store  in the north face outlet  the coach outlet online  humid longchamp taschen  air, salomon  propped lacoste  umbrella under armour basketball shoes  walking ray ban outlet online  in tommy hilfiger  the bluestone hermes birkin  lanes, ecco outlet store  leisurely celine bags  past polo ralph lauren outlet  curtain minnesota timberwolves jerseys  curtain surfaced nfl broncos jerseys  in are mizuno running  various rolex  memories, burberry outlet online  searching jack wolfskin ca  the michael kors bags  past. air max 90  Kissed mizuno running  spring burberry handbags  shower in nfl titans jerseys  the warm nike free run  spring, nfl panthers jerseys  the air jordans  world swarovski jewelry  appreciate red bottom shoes  the sweets softball bats  March.A ferragamo shoes  person,  lonely for ralph lauren  company, roshe runs  a nike air max  city, belstaff womens jackets  a large burberry handbags  boundless coach outlet store  promise. nfl steelers jerseys  Discard cheap hoodies  tedious cheap nfl jerseys  work, vans  break ralph lauren  the louboutin shoes  shackles orlando magic jerseys  of tn requin pas cher  reality, c.c beanies outlet  toward retro jordans  the hollister kids  embrace air huarache  of nike air  the vans shoes  earth, roshe run  to restore sacramento kings jerseys  the mcm backpack outlet  true new balance shoes  self, pandora canada  free to nike free run  feel salvatore ferragamo  warmth of nature, hogan  such ray ban wayfarer  as nike  the designer handbags  warmth michael kors bags  of swarovski crystal  the oakley sunglasses  mother's Sac Hermes  arms. replica watches  Happy ray ban zonnebril  Hour the north face outlet  end ferragamo  is nfl jerseys  as ray ban prezzi  short basketball shoes  glance, a hilfiger online shop  chance omega watches  to nfl cowboys jerseys  savor nfl jets jerseys  a air jordan retro  taste longchamp handbags  of phoenix suns jersey  everything polo ralph lauren  as nfl lions jerseys  early nfl falcons jerseys  as carmelo anthony jersey  pouring sand, asics gel  lost time!Quietly air max 95  standing nfl giants jerseys  in burberry tracksuits  the replica watches  window, nfl eagles jerseys  watching north face jackets  the louboutin shoes  beautiful chi flat iron  fireworks asics shoes usa  over nfl bengals jerseys  the detroit pistons jerseys  city cheap michael kors  indulge roshe runs  in nike  a mcm bags  foreign abercrombie  land new balance  bloom plein outlet  An polo outlet store  endless purses and handbags  loneliness juicy couture clothings  slowly rising oakley pas cher  from air jordans  the rayban  heart, nfl vikings jerseys  like nhl jerseys  smoke fred perry polos  or mlb jerseys  fog, lingering throughout michael kors outlet  the kate spade outlet  cabin. jack wolfskin outlet online  Pawn youth, trafficking nfl raiders jerseys  soul, exclusive uggs boots  lonely. tommy hilfiger online  This city, oakley  regardless nike outlet  of fidget spinner  the michael kors  night timberland shoes  the day, burberry sale  regardless coach outlet  of michael kors outlet  the true religion jeans men  fall and nike factory  winter heat jerseys  seasons, michael kors  always montre femme  kind cheap oakley sunglasses  of ray bans  want chi jerseys  to air jordan shoes  escape burberry outlet online  the cheap oakley sunglasses  panic, asics  and no converse sneakers  place coach factory  to supra shoes  place nike outlet  wistful.With toms outlet  recall pandora charms  once young michael kors outlet online  and frivolous, ray ban outlet  alone bile ray ban outlet  hesitate bottega veneta  to defect adidas  to marc jacobs outlet  the thomas sabo  South guciheaven shoes  of pandora bracelet  the city, eyeglasses frames  this coach factory outlet online  all iphone cases  aspire. Back north face backpacks  pack, ralph lauren  to red bottom shoes  pursue michael kors handbags  a reebok outlet online  dream, leisurely atl jerseys  time puma shoes  off, bottega bags  still philipp plein  can not hermes bags  get adidas  around ralph lauren polos  the oakley sunglasses  glossy true religion outlet  surface washington wizards jerseys  of  the nfl bears jerseys  bustling rolex watches for sale  city, oklahoma city thunder  like air yeezy shoes  an hermes outlet  outsider tommy hilfiger outlet  like himself nfl texans jerseys  watching michael kors bags  everything nike soccer shoes  changing rolex watches  clouds, indiana pacers jerseys  flashing polo ralph lauren  Nihong, pandora  dazzling fireworks givenchy outlet online  and air max  not cheap jerseys  mine. uhren shop  Once burberry outlet  as like nfl jaguars jerseys  a lost fred perry  child, under armour outlet  they nike huarache  lost themselves mcm backpack  in the guess  city, ray ban outlet  nowhere burberry  to barbour jackets  find.Familiar longchamp  and puma online shop  unfamiliar city, portland trail blazers jerseys  dubious michael kors  taste, versace shoes outlet  charm ferragamo shoes outlet  atmosphere, hou jerseys  Guys hollister clothing store  and new balance  Dolls barbour factory  busy cheap nba shoes  with ralph lauren outlet  their oakley sunglasses  busy long champ  combing their christian louboutin shoes  thoughts, ray ban sunglasses outlet  chewing prada  their loneliness, air max  their hollister online shop deutschland  taste michael kors handbags  bitterness. designer handbags  One michael kors outlet  from philadelphia 76ers  the ed hardy  distant warriors jersey  border ray ban pas cher  town, jimmy choo  village, thomas sabo outlet  catch christian louboutin  a northface  train toms outlet  tour christian louboutin outlet online  of the adidas  times, nike roche run  starting nhl jerseys  toward coach factory  the watches  dream. ralph lauren polo  As babyliss  countless memphis grizzlies jerseys  wellhead dsquared2 outlet  splendor skechers outlet   desire nba jerseys sale  to nike mercurial  inspire nfl ravens jerseys  in parajumpers coats  Shenzhen over, pandora charms  the ralph lauren outlet  eyes nfl rams jerseys  filled mcm handbags  with mcm backpack  dreams, toms shoes outlet  no oakley sunglasses  longer nba jerseys sale  shiny gloss, tory burch sandals  any nfl seahawks jerseys  dark night adidas mens  sky lit coach factory  the air max 1  fireworks.Time, iphone 4s cases  such valentino shoes  as nike air max  flow, years bcbg max  such uggs  as ferragamo  sand, brooklyn nets jerseys  pouring prada outlet  from nfl chargers jerseys  between ray-ban sunglasses  the fingers, michael kors handbags  if coach outlet store  meandering stone island polos  circling nike roshe  the mountain, oakley sunglasses cheap  twists nfl azcardinals jerseys  and relojes  turns, toms outlet  but barbour outlet  no nike mercurial  flowers prada outlet  are burberry outlet  blooming. michael kors taschen  Life is swarovski online  like coach bags outlet  a toms shoes outlet  circle, north face  years new orleans pelicans jerseys  removed toronto raptors jerseys  from oakley sunglasses cheap  play back to the end, like the ralph lauren online shop  death timberland femme  of air max 2015  a nike air max  dream. huarache  Carding kate spade outlet  Cantabile nike free run  years, cheap barbour jackets  the burberry outlet online  memories sas jersey  of those burberry outlet  green years moncler jackets outlet  there chh jerseys  anymore, supra footwear  but swarovski jewelry  unfortunately tommy hilfiger outlet stores  the&nbsp; kate spade  floating versace shoes outlet  flowers into nfl bills jerseys  the nfl browns jerseys  eye, links of london necklaces  like nfl buccaneers jerseys  a nfl packers jerseys  dream, le coach des sacs à main  a swarovski canada  fantasy, drunk soccer shoes  in this great burberry outlet store  fantasy, adidas schuhe  never want to jimmy choo  wake up. cleveland cavaliers  Bow, a air max schoenen  flower fog nfl saints jerseys  hit juicy couture  the face, michael kors  hitting giuseppe zanotti  a chrome hearts outlet  nose lunette ray ban pas cher  aroma, nfl jerseys  two belstaff leather jackets  faces, hearts, flowers adidas  across bcbg max azria  the distance, air max  just nfl 49ers jerseys  far rolex watches  enough true religion jeans women  away fitflop outlet  from nfl patriots jerseys  each replica watches  other vibram five fingers  audible dansko  heartbeat roshe run  sound. converse shoes  Perhaps, nike huarache  you armani outlet  do hollister co  not mbt shoes sale  need to north face  hear, new balance canada  needed  just a timberland outlet  feeling.Walking fendi belts  on oakley vault  the polo ralph lauren outlet online  road, scarpe hogan  I heard hollister  a marc jacobs  marvel: birkenstock taschen outlet  a adidas shoes  few coach outlet online  days chris paul jersey  ago milwaukee bucks jerseys  also michael kors outlet online  chill, ralph lauren  cold coach outlet  rain, vans  never mlb jerseys  shy bud, michael kors purses  only cheap true religion  a true religion  few hazy ray ban  opened skechers shoes  his air max  eyes. coach outlet online canada  A nfl dolphins jerseys  quick michael kors purses  night oakley outlet  on hogan  Benny Chazi converse outlet  of burberry sale  it, tods  outside lacoste shirts  the oakley sbocco  streets, michael kors handbags  fields, new balance outlet  mountains barbour jacket outlet  and plains longchamp handbags  ...... adidas  hospital mlb jerseys  yard, cheap eyeglasses  how guess outlet  to nfl colts jerseys  Xinghuoliaoyuan nba jerseys  of gucci shoes outlet  it. nike free  In  addition thomas sabo uk  to nike free run 5.0  surprise, coach purses factory  what kate spade outlet online  else? michael kors canada  Only tommy hilfiger outlet stores  two giuseppe shoes  eyes christian louboutin  widened pandora charms  in calvin klein underwear  surprise, utah jazz jerseys  staring, mont blanc  daydream, facing boston celtics jerseys  the hollister clothing  new nike  tree flowers, dal jerseys  suddenly hugo boss outlet  overnight ray ban wayfarer  long dsquared2  out ralph lauren polos  of burberry online shop  temptation, softball bats  in mont blanc  addition birkenstock taschen deutschland  to the north face  open shoes outlet  mouth, ralph lauren  but converse  also longchamp  what oakley outlet online  to pandora jewellery australia  say nfl redskins jerseys  it.In timberland shoes  fact, prada handbags

moncler jackets
mont blanc pens
timberland boots
rolex watches
nike outlet
pandora jewelry official site
kate spade handbag
moncler outlet
coach outlet
nike air max outlet
canada goose outlet
air jordans
coach factory outlet
ecco shoes
yeezy boost
toms shoes
ultra boost
salvatore ferragamo
oakley sunglasses outlet
tory burch outlet online
coach outlet store
coach factory outlet online
nike shox
nike cortez
adidas yeezy
salvatore ferragamo shoes
pandora jewelry official site
yeezy boost
ugg boots
new balance outlet
nike shoes
mulberry bags
supreme clothing
ralph lauren outlet
louis vuitton outlet online
supra shoes
converse shoes
kate spade bags
adidas stan smith
kate spade outlet store
jordan retro
ralph lauren
dansko shoes
kate spade outlet store
pandora charms
coach outlet online
michael kors outlet
ugg outlet
coach outlet online
tiffany outlet
ray ban sunglasses discount
kate spade
nmd adidas
pandora charms
christian louboutin
coach factory outlet
nike air max 95
toms outlet
cheap jordans
kate spade outlet
michael kors handbags
air jordans
ecco shoes
michael kors outlet canada
coach outlet online
nike air force 1
cheap jordans
underarmour shoes
birkenstock sandals
adidas yeezy
longchamp outlet
coach factory outlet
michael kors outlet clearance
nike epic react flyknit
hermes handbags
kobe bryant shoes
nike shoes
kate spade outlet
ysl handbags
cheap nfl jerseys
adidas nmd
nike air max shoes
polo ralph lauren outlet
adidas originals
timberland boots
michael kors outlet
jordan shoes
salvatore ferragamo shoes
pandora charms
birkenstock outlet
cheap jordans
canada goose
pandora jewelry
dr martens outlet
pandora charms sale clearance
nike outlet
nike react shoes
birkenstock shoes
pandora jewelry
christian louboutin outlet
coach outlet
adidas yeezy
nike air max 270
michael kors outlet online
coach outlet
ralph lauren sale
ralph lauren outlet
ralph lauren
mulberry outlet
ferragamo shoes
adidas superstar
michael kors outlet

You have to log in before you can reply Login | Sign Up

Points Rules