Jump to content


Photo

Wiring of DHT22 to pcduino v1


  • Please log in to reply
36 replies to this topic

#21 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 31 March 2015 - 10:47 AM

Hello,
no way to have a measure corresponding to the checksum. I think it's because "111" or "1111" is always "1", but sometimes "11" is "1" and the other "0".
Yet the values of humidity and temperature  returned are relatively correct (without checksum).
In c it work(http://learn.linkspr...t11-on-pcduino/). Is it possible to create a library in c compiled and called using python? I think so but I do not know how.
Frank

Frank


#22 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 31 March 2015 - 10:56 AM

I was worried that the pcDuino1 would not be fast enough. When I wrote that I was working with pcDuino3.

 

You could use the arduino ide that is on the pcDuino1 to write the c code.

 

I searched the forums and came up with this discussion. With a few modifications it could be used as a command line utility and then called from python.

 

Odd. In my testing on the pcDuino3 my python code was just as fast at reading the bits as compiled c was.



#23 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 31 March 2015 - 11:00 AM

I'm working on pcduino3 too.

Thank's for the link.


Frank


#24 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 31 March 2015 - 11:04 AM

I'm working on pcduino3 too.

Thank's for the link.

 

Then something else is wrong. That code works fine on pcDuino3. Do you have anything else running on the pcDuino?



#25 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 31 March 2015 - 11:07 AM

No nothing.

 

I took a logic analyzer in my work to see if it's not from the component. I come back to this post after measurements.


Frank


#26 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 31 March 2015 - 11:09 AM

You should be able to see the dht response on a scope as I used my DSO for testing when I wrote the code.

 

It could be that your pullup is to strong.



#27 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 01 April 2015 - 01:03 PM

It works.
My gnd pin was a fold.
 
Thank's cwilt.

Frank


#28 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 01 April 2015 - 01:04 PM

I am glad you got it working.

#29 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 01 April 2015 - 04:39 PM

sometime it work fine and sometime not. I don't understand.

The error is at the begining of mesurement. First bit are not "catch".

 

logic analyser always ok.


Frank


#30 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 01 April 2015 - 10:32 PM

The reason it sometimes fails is simply because the interface is bitbanged and the combination of python and linux are not always fast enough. Sometimes the OS requires more cpu time during the reading and causes it to miss a bit which throws an error. The compiled c version does the same thing. I spent a fair amount of time trying to get as much speed as possible from the python code. You are more than welcome to try get it faster.



#31 AndrewDoc99

AndrewDoc99

    Member

  • Members
  • PipPip
  • 11 posts

Posted 10 May 2015 - 11:30 AM

Hi all

 

I have a pcduino1 and dht11

Used the code given above, but receiving zeros for tem–∑ and humidity with due point -112.

What i'm doing wrong?

 

ubuntu@ubuntu:/media/5E5F-E641/python-pcduino-master/Samples/blink_led$ python test.py
3
temp is:
0
humidity is:
0
-112.00


#32 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 10 May 2015 - 02:40 PM

I wrote that code for the DHT22 sensors. The DHT11's do not return the same number of bytes so it will never read it correctly. You will have to study the spec sheet for DHT11 and modify the code to work as I do not have a DHT11 to work with.



#33 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 10 May 2015 - 02:59 PM

I think DHT11 and DHT 22 have same spec but DHT11 return 0000 0000 for decimal.


Frank


#34 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 10 May 2015 - 04:51 PM

No. DHT11 returns half of the bytes that DHT22 does.



#35 Frank

Frank

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts
  • LocationSaint-Nazaire - France

Posted 10 May 2015 - 04:56 PM

Are you sure ?

https://www.sparkfun...ature/DHT22.pdf

 

http://www.micropik.com/PDF/dht11.pdf

 

This datasheet describe same data with decimal data equal to 0. But i have not try with logic analyser with dht11 just with dht22.


Frank


#36 cwilt

cwilt

    Advanced Member

  • Members
  • PipPipPip
  • 1,012 posts

Posted 10 May 2015 - 05:10 PM

If it returns the same number of bits then it should work. Check power and pull up resistor. If it is too strong or too weak it will cause communications issues. 



#37 AndrewDoc99

AndrewDoc99

    Member

  • Members
  • PipPip
  • 11 posts

Posted 02 January 2016 - 01:20 PM

Hello again.

Guys, please help.

I don't want to switch to rasp just due to this stuff fails.

 

Checked twice, my dht 11 works on arduino, but in pcduino using the code above i'm recieving only this(no matter sensor pin is connected to analog or to digital):

3
temp is:
0
humidity is:
0
-112.00





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users