Using DHT12 with alternate IO pins on ESP8266

Home Forums The libraries hosted on the site DHT12 complete library (Adafruit DHT clone) Using DHT12 with alternate IO pins on ESP8266

Viewing 6 reply threads
  • Author
    Posts
    • #7474
      Dave C.

        I’m probably being really stupid here, I’ve got the I2C example working fine on my NodeMcu, perfect.

        I need to use an alternative pair of IO pins (IO-0 and IO-2) with an ESP01, I’ve already got an I2C display working on those pins so I just want the DHT to run in parallel.

        I just can’t work out how to persuade the DHT to work on the alternate pins, nothing clever.

        I’ve looked at the examples and the .pdf file but I’m missing something as my attempts either won’t compile or simply fail to communicate with the DHT.

        Thoughts please, multiple attemps with Mr Google haven’t really revealed the mystery.

         

      • #7476
        Renzo Mischianti
        Keymaster

          Hi Dave,

          I think you don’t need to use alternate pins, you can connect more than one device to the same 2 pins, you must only put the a different address.

          Usually there is one master and one or multiple slaves on the line, although there can be multiple masters, but we’ll talk about that later.

          Both masters and slaves can transmit or receive data, therefore, a device can be in one of these four states: master transmit, master receive, slave transmit, slave receive.

          You must pay attention only if you manage i2c with interrupt.

           

          Tell me if this can be a solution.

          Bye Renzo

        • #7477
          Dave C.

            Hi Renzo. Yeah, I think I can run in parallel, my problem is that I need to use non-default IO pins.

            The LCD is already running just fine on these pins but I can’t get the DHT to talk.

            Like I said, I’m being stupid somewhere.

          • #7479
            Dave C.

              It’s working fine using your example sketch and the default pins.

              What do I need to do to the example to use other pins (IO-0 and IO-2)?

              I’m really pretty new to this software game, still finding my way around stuff.

               

            • #7480
              Renzo Mischianti
              Keymaster

                Hehehhe,

                no no, sorry, I did not understand, and I have not included examples that use pins different from the standard.

                Instead of use this constructor

                DHT12 dht12;

                you can use this

                DHT12 dht12(D1, D2);

                and you can specify the alternati pins you want.

                I think It’s what you need.

                Bye Renzo

              • #7481
                Dave C.

                  Thanks I’ll try that and get back to you.

                  It’s 4.30 PM here in Thailand and it’s a celebration called Loy Kratong, got to take my good lady out to dinner.

                   

                • #7483
                  Dave C.

                    Perfect!!

                    I’m using this:

                    uint8_t sda = 0;
                    uint8_t scl = 2;

                    // Set dht12 i2c comunication on default Wire pin
                    DHT12 dht12(sda, scl);

                    Thanks very much for being kind to a noob.

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.
                Exit mobile version