DHT-11 Humidity/temperature sensor and PIC16F628


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: DHT-11 Humidity/temperature sensor and PIC16F628

    Many experiments later it is still not working...
    The problem is that the DHT-11 is not recognised and the code jumps to the label "subloop".
    Nobody got an idea or experience with the DHT-11 sensor?

    (I have programmed the PIC16F628 with this hexfile https://github.com/candrian/Thermome.../ThermometerV2 and then it is working, so the DHT-11 isn't the problem. It is even working with a 4 MHz resonator. But I would like to add some other functions in PicBasic.)

  2. #2
    Join Date
    Oct 2013
    Location
    Québec, Canada
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: DHT-11 Humidity/temperature sensor and PIC16F628

    Here is my code and it works.

    Good luck!



    dht var byte[32]
    humidite var byte
    haut var byte
    bas var byte
    temp var byte
    x var byte
    dht11 var portb.0


    main:
    TRISB.0 = 0 ' portb.0 = output
    dht11 = 1 ' sortie à 1
    pause 2000 ' wait 2 sec
    dht11 = 0 : pause 25 ' send 20ms low
    dht11 = 1 : pauseus 40 ' send 40us hi

    PulsIn PORTB.0, 1, haut 'reponse du dht-11
    if haut < 15 then goto main

    for x = 31 to 0 step-1 'capture des 8 bits entier humidite
    PulsIn PORTB.0, 1, dht[x] ' 1
    next x

    For x = 31 to 0 step-1 'conversion en 1 ou 0: 14 ou 5
    if dht[x] > 9 then
    dht[x]=1 'partie décimale de la temp toujours à 0
    else
    dht[x]=0
    endif
    next x

    humidite=dht[31]*128+dht[30]*64+dht[29]*32+dht[28]*16+dht[27]*8+dht[26]*4+dht[25]*2+dht[24]*1
    temp=dht[15]*128+ dht[14]*64+dht[13]*32+dht[12]*16+dht[11]*8+dht[10]*4+dht[9]*2+dht[8]*1
    LCDOUT $FE,$80,"Humidite = ",#humidite,"% "
    LCDOUT $FE,$C0,"Temperature = ",#temp,"C "
    goto main

Members who have read this thread : 2

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts