Author Topic: DHT22 library  (Read 2392 times)

0 Members and 1 Guest are viewing this topic.

Offline noname4meTopic starter

  • Regular Contributor
  • *
  • Posts: 93
DHT22 library
« on: July 06, 2018, 01:15:01 pm »
Hi All,

I am looking for a DHT22 library (AM2302 and DHT22 both use the same protocol) that works with STM32F103 - does anyone know of one that works?

I have tried:

https://petoknm.wordpress.com/2015/01/04/dht22-driver-for-stm32/

https://github.com/LonelyWolf/stm32/tree/master/am2302

I've also tried rolling my own, but got stuck trying to set up a timer to make my 1us delay timer (using interrupt on a falling edge and rising edge).

Thanks
 

Offline Naguissa

  • Regular Contributor
  • *
  • Posts: 114
  • Country: es
    • Foro de electricidad, electrónica y DIY / HUM en español
Re: DHT22 library
« Reply #1 on: July 06, 2018, 02:27:50 pm »
Can you use or port Arduino one?

https://github.com/adafruit/DHT-sensor-library
 
The following users thanked this post: noname4me

Offline HoracioDos

  • Frequent Contributor
  • **
  • Posts: 344
  • Country: ar
  • Just an IT monkey with a DSO
 
The following users thanked this post: noname4me

Offline noname4meTopic starter

  • Regular Contributor
  • *
  • Posts: 93
Re: DHT22 library
« Reply #3 on: July 06, 2018, 03:22:21 pm »
OK, I'm trying the one from:

https://github.com/jbagel2/stm32-f103-CortexM3-ESP8266-WeatherStation/tree/master/sensors

but it needs converting to use the HAL libraries instead of the stuff that is already there...

If anyone has already done this, please could I have a copy of your code?  I've been stuck on this for 4 days now :(

(I'm not a programmer).

Thanks

 

Offline noname4meTopic starter

  • Regular Contributor
  • *
  • Posts: 93
Re: DHT22 library
« Reply #4 on: July 06, 2018, 10:57:31 pm »
Thanks - managed to port this one

If anyone wants to see my (very rough and dirty) port, please post below and I'll post it up.
 

Offline noname4meTopic starter

  • Regular Contributor
  • *
  • Posts: 93
Re: DHT22 library
« Reply #5 on: July 08, 2018, 03:43:24 pm »
If anyone else finds the readings unreliable - it appears that the delay_ms(2) line in the dht22.c file may be too short.

The datasheet says that the sensor requires 800us to prepare the sensor to take a reading - this was giving me a low period of sometimes less than 100us.

Increased this to 10, and it seems to work reliably now.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf