Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Read DHT 11 temperature sensor and hum...

    Scheduled Pinned Locked Moved WiPy 2&3
    6 Posts 4 Posters 3.2k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L Offline
      livius
      last edited by sakis

      i try to read data from DHT 11 sensor
      my file dhttest.py looks like

      from machine import Pin
      from machine import UART
      import DHT
      dht_pin=Pin('G4', Pin.OPEN_DRAIN)
      dht_pin(1)
      
      temp, hum = DHT.DHT11(dht_pin)
      # temp = temp * 9 // 5 + 320   # uncomment for Fahrenheit
      temp_str = '{}.{}'.format(temp//10,temp%10)
      hum_str = '{}.{}'.format(hum//10,hum%10)
      
      # Print or upload it
      print(temp_str, hum_str)
      

      but when i do
      execfile('dhttest.py')
      result is
      280.5 280.5
      but second execution
      execfile('dhttest.py')
      cause halt exception

      >>> execfile('dhttest.py')
      280.5 280.5
      >>> execfile('dhttest.py')
      Guru Meditation Error: Core   0 panic'ed (Interrupt wdt timeout on CPU0)
      Register dump:
      PC      :  400d277d  PS      :  00060634  A0      :  80082d94  A1      :  3ffdc2a0  
      A2      :  0006062f  A3      :  00000245  A4      :  00000001  A5      :  00000001  
      A6      :  00000000  A7      :  3ffb0154  A8      :  00000001  A9      :  3ffdc280  
      A10     :  3ffc4bf4  A11     :  0000012c  A12     :  00000122  A13     :  00000000  
      A14     :  00000003  A15     :  00060223  SAR     :  00000004  EXCCAUSE:  00000005  
      EXCVADDR:  00000000  LBEG    :  4000c2e0  LEND    :  4000c2f6  LCOUNT  :  ffffffff  
      CPU halted.
      

      code of dht.py is here
      dht post

      please help with this

      think about people first, then computers

      R 1 Reply Last reply Reply Quote 0
      • L Offline
        livius
        last edited by

        With todays firmware it does not crash :)

        think about people first, then computers

        1 Reply Last reply Reply Quote 0
        • R Offline
          Roberto @livius
          last edited by

          Hi @livius,

          We released a new firmware with updates in stability that i think might help you with your issue, please download it at
          https://www.pycom.io/support/supportdownloads/
          and follow the instructions

          Best,
          Roberto

          1 Reply Last reply Reply Quote 0
          • Y Offline
            yahia
            last edited by

            Hello.

            I bought a grove sensor which contains DHT22 (now called AM2302) and i tried the code mentioned here and it does return 280.5 without crashing but nothing else. Does anyone know how to actually read the sensor data? or point me to the right direction?

            I am using a LoPy by the way.

            Thanks

            1 Reply Last reply Reply Quote 0
            • I Offline
              iber
              last edited by iber

              I got into the same issue with this DHT11 sensor.
              I wonder if it still has to do with the threading issue as mentioned here.

              Secondly, why is the call to dht_pin(1) required?
              If I get it right, this writes a value of 1 to the pin?

              *edit
              Even without any sensor connected, the code still returns a fixed 28.05.

              1 Reply Last reply Reply Quote 0
              • Y Offline
                yahia
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • 1 / 1
                • First post
                  Last post

                Pycom on Twitter

                Pycom